sim_launcher 0.3.3 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/bin/sim_launcher CHANGED
@@ -33,7 +33,9 @@ get '/launch_ipad_app' do
33
33
  raise 'no app_path provided' if app_path.nil?
34
34
 
35
35
  sdk = params[:sdk]
36
+ restart_requested = ("true" == params[:restart])
36
37
 
38
+ shared_simulator.quit_simulator if restart_requested
37
39
  shared_simulator.launch_ipad_app( app_path, sdk )
38
40
  end
39
41
 
@@ -42,6 +44,8 @@ get '/launch_iphone_app' do
42
44
  raise 'no app_path provided' if app_path.nil?
43
45
 
44
46
  sdk = params[:sdk]
47
+ restart_requested = ("true" == params[:restart])
45
48
 
49
+ shared_simulator.quit_simulator if restart_requested
46
50
  shared_simulator.launch_iphone_app( app_path, sdk )
47
51
  end
@@ -25,15 +25,15 @@ module SimLauncher
25
25
  @server_uri = URI.parse( uri.to_s )
26
26
  end
27
27
 
28
- def launch
29
- full_request_uri = launch_uri
28
+ def launch(restart=false)
29
+ full_request_uri = launch_uri(restart)
30
30
  puts "requesting #{full_request_uri}" if $DEBUG
31
31
  response = Net::HTTP.get( full_request_uri )
32
32
  puts "iphonesim server reponded with:\n#{response}" if $DEBUG
33
33
  end
34
34
 
35
35
  def relaunch
36
- launch
36
+ launch(true)
37
37
  end
38
38
 
39
39
  # check that there appears to be a server ready for us to send commands to
@@ -53,10 +53,12 @@ module SimLauncher
53
53
 
54
54
  private
55
55
 
56
- def launch_uri
56
+ def launch_uri(requesting_restart)
57
57
  full_request_uri = @server_uri.dup
58
58
  full_request_uri.path = "/launch_#{@family}_app"
59
- full_request_uri.query = "app_path=" + CGI.escape( @app_path ) + "&sdk=" + CGI.escape(@sdk)
59
+ full_request_uri.query = "app_path=" + CGI.escape( @app_path )
60
+ full_request_uri.query += "&sdk=" + CGI.escape( @sdk ) unless @sdk.nil?
61
+ full_request_uri.query += "&restart=" + (!!requesting_restart).to_s
60
62
  full_request_uri
61
63
  end
62
64
 
@@ -19,7 +19,9 @@ module SimLauncher
19
19
  end
20
20
 
21
21
  def relaunch
22
- launch
22
+ simulator = SimLauncher::Simulator.new
23
+ simulator.quit_simulator
24
+ simulator.launch_ios_app( @app_path, @sdk, @family )
23
25
  end
24
26
  end
25
27
  end
@@ -1,15 +1,18 @@
1
- require 'singleton'
2
-
3
1
  module SimLauncher
4
2
  class SdkDetector
5
- include Singleton
3
+
4
+ def initialize(simulator = Simulator.new)
5
+ @simulator = simulator
6
+ end
7
+
8
+ def available_sdk_versions
9
+ @simulator.showsdks.split("\n").map { |sdk_line|
10
+ sdk_line[/\(([\d.]+)\)$/,1] # grab any "(x.x)" part at the end of the line
11
+ }.compact
12
+ end
6
13
 
7
14
  def latest_sdk_version
8
- unless @latest_sdk_version
9
- latest_iphone_sdk = `xcodebuild -showsdks | grep -o "iphonesimulator.*$"`.split.sort.last
10
- @latest_sdk_version = latest_iphone_sdk[/iphonesimulator(.*)/,1]
11
- end
12
- @latest_sdk_version
15
+ available_sdk_versions.sort.last
13
16
  end
14
17
 
15
18
  end
@@ -10,7 +10,7 @@ class Simulator
10
10
  end
11
11
 
12
12
  def launch_ios_app(app_path, sdk_version, device_family)
13
- sdk_version ||= SdkDetector.instance.latest_sdk_version
13
+ sdk_version ||= SdkDetector.new(self).latest_sdk_version
14
14
  run_synchronous_command( :launch, app_path, sdk_version, device_family )
15
15
  end
16
16
 
@@ -22,6 +22,10 @@ class Simulator
22
22
  launch_ios_app( app_path, sdk, 'iphone' )
23
23
  end
24
24
 
25
+ def quit_simulator
26
+ `echo 'application "iPhone Simulator" quit' | osascript`
27
+ end
28
+
25
29
  def run_synchronous_command( *args )
26
30
  cmd = cmd_line_with_args( args )
27
31
  puts "executing #{cmd}" if $DEBUG
@@ -1,3 +1,3 @@
1
1
  module SimLauncher
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.5"
3
3
  end
metadata CHANGED
@@ -1,44 +1,35 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sim_launcher
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 3
9
- version: 0.3.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.5
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Pete Hodgson
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-08-22 00:00:00 -07:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-14 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: sinatra
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
16
+ requirement: &2160168080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
30
22
  type: :runtime
31
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: *2160168080
32
25
  description:
33
- email:
26
+ email:
34
27
  - rubygems@thepete.net
35
- executables:
28
+ executables:
36
29
  - sim_launcher
37
30
  extensions: []
38
-
39
31
  extra_rdoc_files: []
40
-
41
- files:
32
+ files:
42
33
  - .gitignore
43
34
  - .gitmodules
44
35
  - Gemfile
@@ -52,35 +43,28 @@ files:
52
43
  - lib/sim_launcher/version.rb
53
44
  - native/iphonesim
54
45
  - sim_launcher.gemspec
55
- has_rdoc: true
56
46
  homepage: http://rubygems.org/gems/sim_launcher
57
47
  licenses: []
58
-
59
48
  post_install_message:
60
49
  rdoc_options: []
61
-
62
- require_paths:
50
+ require_paths:
63
51
  - lib
64
- required_ruby_version: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- segments:
69
- - 0
70
- version: "0"
71
- required_rubygems_version: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- segments:
76
- - 0
77
- version: "0"
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
78
64
  requirements: []
79
-
80
65
  rubyforge_project:
81
- rubygems_version: 1.3.6
66
+ rubygems_version: 1.8.10
82
67
  signing_key:
83
68
  specification_version: 3
84
69
  summary: tiny HTTP server to launch an app in the iOS simulator
85
70
  test_files: []
86
-