Class: VMC::Route::Unmap
- Inherits:
-
Base
- Object
- Mothership
- CLI
- V2CheckCLI
- Base
- VMC::Route::Unmap
- Defined in:
- lib/vmc/cli/route/unmap.rb
Constant Summary
Constants inherited from Mothership
Instance Attribute Summary
Attributes inherited from Mothership
Instance Method Summary collapse
Methods inherited from Base
Methods inherited from V2CheckCLI
Methods inherited from CLI
#check_logged_in, #check_target, #client, client, client=, #client_target, #color_enabled?, #debug?, #default_action, #ensure_config_dir, #err, #execute, #fail, #fail_unknown, #force?, #invalidate_client, #log_error, #name_list, #no_v2, #normalize_targets_info, #one_of, #precondition, #quiet?, #remove_target_info, #sane_target_url, #save_target_info, #save_targets, #save_token_if_it_changes, #set_target, #table, #target_file, #target_info, #targets_info, #tokens_file, #user_colors, #v2?, #verbose?, #wrap_errors
Methods included from Spacing
#indented, #justify, #line, #lines, #quiet?, #spaced, #start_line, #tabular, #text_width, #trim_escapes
Methods included from Interactive
#ask, #handler, #input_state, #list_choices, #prompt, #show_default
Methods inherited from Mothership
add_input, after, alias_command, around, before, change_argument, commands, #default_action, desc, #execute, #exit_status, #filter, filter, global_option, group, #help, #initialize, input, #interact, interactions, #invoke, method_added, option, #run, start, #unknown_command, #with_filters
Constructor Details
This class inherits a constructor from Mothership
Instance Method Details
#unmap ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/vmc/cli/route/unmap.rb', line 15 def unmap return invoke :v1_unmap, input.inputs, input.given unless v2? if input[:all] if input.has?(:app) app = target = input[:app] return unless !input[:delete] || input[:really, "ALL URLS bound to #{target.name}", :bad] else target = client return unless !input[:delete] || input[:really, "ALL URLS", :bad] end target.routes.each do |r| begin invoke :unmap, :delete => input[:delete], :url => r, :really => true, :app => app rescue CFoundry::APIError => e err "#{e.class}: #{e.}" end end return end app = input[:app] url = input[:url, app ? app.routes : client.routes] if input[:delete] with_progress("Deleting route #{c(url.name, :name)}") do url.delete! end elsif app with_progress("Unbinding #{c(url.name, :name)} from #{c(app.name, :name)}") do app.remove_route(url) end else fail "Missing either --delete or --app." end end |
#v1_unmap ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/vmc/cli/route/unmap.rb', line 61 def v1_unmap app = input[:app] url = input[:url, app.urls] unless input[:all] with_progress("Updating #{c(app.name, :name)}") do |s| if input[:all] app.urls = [] else simple = url.sub(/^https?:\/\/(.*)\/?/i, '\1') unless app.urls.delete(simple) fail "URL #{url} is not mapped to this application." end end app.update! end end |