sim_launcher 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/sim_launcher CHANGED
@@ -13,9 +13,7 @@ set :port, (ARGV[0] || 8881)
13
13
  set :run, true
14
14
 
15
15
 
16
- IPHONESIM_PATH = File.join( File.dirname(__FILE__), '..', 'native', 'iphonesim' )
17
-
18
- shared_simulator = SimLauncher::Simulator.new( IPHONESIM_PATH )
16
+ shared_simulator = SimLauncher::Simulator.new
19
17
 
20
18
  get '/' do
21
19
  <<EOS
@@ -26,17 +26,44 @@ module SimLauncher
26
26
  end
27
27
 
28
28
  def launch
29
- full_request_uri = @server_uri.dup
30
- full_request_uri.path = "/launch_#{@family}_app"
31
- full_request_uri.query = "app_path=" + CGI.escape( @app_path ) + "&sdk=" + CGI.escape(@sdk)
32
- puts "requesting #{full_request_uri}"
29
+ full_request_uri = launch_uri
30
+ puts "requesting #{full_request_uri}" if $DEBUG
33
31
  response = Net::HTTP.get( full_request_uri )
34
- puts "iphonesim server reponded with:\n#{response}"
32
+ puts "iphonesim server reponded with:\n#{response}" if $DEBUG
35
33
  end
36
34
 
37
35
  def relaunch
38
36
  launch
39
37
  end
40
38
 
39
+ # check that there appears to be a server ready for us to send commands to
40
+ def ping
41
+ # our good-enough solution is just request the list of available iOS sdks and
42
+ # check that we get a 200 response
43
+ begin
44
+ uri = list_sdks_uri
45
+ Net::HTTP.start( uri.host, uri.port) do |http|
46
+ response = http.head(uri.path)
47
+ return response.is_a? Net::HTTPOK
48
+ end
49
+ rescue
50
+ return false
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ def launch_uri
57
+ full_request_uri = @server_uri.dup
58
+ full_request_uri.path = "/launch_#{@family}_app"
59
+ full_request_uri.query = "app_path=" + CGI.escape( @app_path ) + "&sdk=" + CGI.escape(@sdk)
60
+ full_request_uri
61
+ end
62
+
63
+ def list_sdks_uri
64
+ full_request_uri = @server_uri.dup
65
+ full_request_uri.path = "/showsdks"
66
+ full_request_uri
67
+ end
41
68
  end
42
69
  end
@@ -0,0 +1,25 @@
1
+ module SimLauncher
2
+ class DirectClient
3
+ def initialize( app_path, sdk, family )
4
+ @app_path = File.expand_path( app_path )
5
+ @sdk = sdk
6
+ @family = family
7
+ end
8
+
9
+ def self.for_ipad_app( app_path, sdk = '4.2' )
10
+ self.new( app_path, sdk, 'ipad' )
11
+ end
12
+
13
+ def self.for_iphone_app( app_path, sdk = '4.2' )
14
+ self.new( app_path, sdk, 'iphone' )
15
+ end
16
+
17
+ def launch
18
+ SimLauncher::Simulator.new.launch_ios_app( @app_path, @sdk, @family )
19
+ end
20
+
21
+ def relaunch
22
+ launch
23
+ end
24
+ end
25
+ end
@@ -1,8 +1,8 @@
1
1
  module SimLauncher
2
2
  class Simulator
3
3
 
4
- def initialize( iphonesim_path )
5
- @iphonesim_path = iphonesim_path
4
+ def initialize( iphonesim_path = nil )
5
+ @iphonesim_path = iphonesim_path || File.join( File.dirname(__FILE__), '..', '..', 'native', 'iphonesim' )
6
6
  end
7
7
 
8
8
  def showsdks
@@ -25,7 +25,7 @@ class Simulator
25
25
 
26
26
  def run_synchronous_command( *args )
27
27
  cmd = cmd_line_with_args( args )
28
- puts "executing #{cmd}"
28
+ puts "executing #{cmd}" if $DEBUG
29
29
  `#{cmd}`
30
30
  end
31
31
 
@@ -1,3 +1,3 @@
1
1
  module SimLauncher
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,3 @@
1
+ require 'sim_launcher/client'
2
+ require 'sim_launcher/direct_client'
3
+ require 'sim_launcher/simulator'
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Pete Hodgson
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-04 00:00:00 -08:00
17
+ date: 2011-03-20 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -44,7 +44,9 @@ files:
44
44
  - Gemfile
45
45
  - Rakefile
46
46
  - bin/sim_launcher
47
+ - lib/sim_launcher.rb
47
48
  - lib/sim_launcher/client.rb
49
+ - lib/sim_launcher/direct_client.rb
48
50
  - lib/sim_launcher/simulator.rb
49
51
  - lib/sim_launcher/version.rb
50
52
  - native/iphonesim