Class: EPC::Command::TargetCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- EPC::Command::TargetCommand
- Defined in:
- lib/epc/command/target_command.rb
Constant Summary
Constants inherited from BaseCommand
BaseCommand::GIVEUP_TICKS, BaseCommand::SLEEP_TIME, BaseCommand::TICKER_TICKS
Instance Attribute Summary
Attributes inherited from BaseCommand
#client, #klass_name, #object_id, #object_type, #options, #target_id, #target_type
Instance Method Summary collapse
Methods inherited from BaseCommand
#check_options, #context_params, #context_params=, #go, include_module, inherited, #initialize, required_options, #say_err
Methods included from PersistentAttributes
#auth_token, #caller_id, #target_url
Constructor Details
This class inherits a constructor from EPC::Command::BaseCommand
Instance Method Details
#execute(target_url = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/epc/command/target_command.rb', line 5 def execute(target_url = nil) if blank?(target_url) say("TARGET: " + EPC::Config.target_url) return 1 end target_url = "http://#{target_url}" unless target_url =~ /^https?/ target_url = target_url.gsub(/\/+$/, '') begin URI.parse(target_url) status, response, headers = client.get(target_url + "/api/v1/tokens/status", true) raise Exception if status.failure? EPC::Config.store_target_url(target_url) say("Successfully targeted to [#{target_url}]") rescue => ex say("The URL you entered [#{target_url}] is not valid. Please try again.") end return status end |