Class: SimLauncher::Client
- Inherits:
-
Object
- Object
- SimLauncher::Client
- Defined in:
- lib/sim_launcher/client.rb
Constant Summary collapse
- DEFAULT_SERVER_URI =
"http://localhost:8881"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(app_path, sdk, family) ⇒ Client
constructor
A new instance of Client.
- #launch(restart = false) ⇒ Object
-
#ping ⇒ Object
check that there appears to be a server ready for us to send commands to.
- #relaunch ⇒ Object
- #server_uri=(uri) ⇒ Object
Constructor Details
#initialize(app_path, sdk, family) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 |
# File 'lib/sim_launcher/client.rb', line 9 def initialize( app_path, sdk, family ) @app_path = File.( app_path ) @sdk = sdk @family = family self.server_uri = DEFAULT_SERVER_URI end |
Class Method Details
.for_ipad_app(app_path, sdk = nil) ⇒ Object
16 17 18 |
# File 'lib/sim_launcher/client.rb', line 16 def self.for_ipad_app( app_path, sdk = nil ) self.new( app_path, sdk, 'ipad' ) end |
.for_iphone_app(app_path, sdk = nil) ⇒ Object
20 21 22 |
# File 'lib/sim_launcher/client.rb', line 20 def self.for_iphone_app( app_path, sdk = nil ) self.new( app_path, sdk, 'iphone' ) end |
Instance Method Details
#launch(restart = false) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sim_launcher/client.rb', line 28 def launch(restart=false) begin full_request_uri = launch_uri(restart) puts "requesting #{full_request_uri}" if $DEBUG response = Net::HTTP.get( full_request_uri ) puts "iphonesim server reponded with:\n#{response}" if $DEBUG rescue => ex puts "There was an error reaching the sim launcher proxy, which is a little sinatra web app that ships with this Gem. Make sure that it is running and operational.\n" puts "The error was:\n" puts ex.to_s end end |
#ping ⇒ Object
check that there appears to be a server ready for us to send commands to
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/sim_launcher/client.rb', line 46 def ping # our good-enough solution is just request the list of available iOS sdks and # check that we get a 200 response begin uri = list_sdks_uri Net::HTTP.start( uri.host, uri.port) do |http| response = http.head(uri.path) return response.is_a? Net::HTTPOK end rescue return false end end |
#relaunch ⇒ Object
41 42 43 |
# File 'lib/sim_launcher/client.rb', line 41 def relaunch launch(true) end |
#server_uri=(uri) ⇒ Object
24 25 26 |
# File 'lib/sim_launcher/client.rb', line 24 def server_uri=(uri) @server_uri = URI.parse( uri.to_s ) end |