israkel 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.md +10 -0
  2. data/VERSION +1 -1
  3. data/israkel.gemspec +2 -2
  4. data/lib/israkel/tasks.rb +36 -3
  5. metadata +3 -3
data/README.md CHANGED
@@ -11,6 +11,16 @@ for the iPhone Simulator on Mac OS like ...
11
11
 
12
12
  Some of them are stolen from [RestKit](https://github.com/RestKit/RestKit).
13
13
 
14
+ ## Dependencies
15
+
16
+ Besides the gem dependencies, that are automatically resolved and
17
+ installed via bundler, there's only one external dependency to the
18
+ [ios-sim](https://github.com/phonegap/ios-sim) binary. The most
19
+ convenient way to install it is via
20
+ [homebrew](http://mxcl.github.com/homebrew/):
21
+
22
+ brew install ios-sim
23
+
14
24
  ## Example Usage
15
25
 
16
26
  You will need to install the gem:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.2.0
data/israkel.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "israkel"
8
- s.version = "0.1.3"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Johannes Plunien"]
12
- s.date = "2013-02-04"
12
+ s.date = "2013-02-07"
13
13
  s.description = "Collection of common rake tasks for the iPhone Simulator like start/stop and some more."
14
14
  s.email = "plu@pqpq.de"
15
15
  s.extra_rdoc_files = [
data/lib/israkel/tasks.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'fileutils'
2
+ require 'highline/import'
2
3
  require 'json'
3
4
  require 'rake'
4
5
  require 'rake/tasklib'
@@ -11,12 +12,12 @@ module ISRakel
11
12
 
12
13
  def initialize(name = :simulator)
13
14
  @name = name
14
- @sdk_version = ENV['IOS_SDK_VERSION'] || '6.0'
15
15
 
16
16
  yield self if block_given?
17
17
 
18
18
  # Make sure all external commands are in the PATH.
19
19
  xcode_path
20
+ ios_sim_path
20
21
 
21
22
  define_reset_task
22
23
  define_set_language_task
@@ -25,13 +26,23 @@ module ISRakel
25
26
  end
26
27
 
27
28
  def edit_global_preferences(&block)
29
+ unless sdk_version.to_f >= 6.0
30
+ abort "ERROR: edit_global_preferences is only supported for iOS SDK >= 6.0"
31
+ end
28
32
  edit_file( File.join(simulator_preferences_path, '.GlobalPreferences.plist'), &block )
29
33
  end
30
34
 
31
35
  def edit_preferences(&block)
36
+ unless sdk_version.to_f >= 6.0
37
+ abort "ERROR: edit_preferences is only supported for iOS SDK >= 6.0"
38
+ end
32
39
  edit_file( File.join(simulator_preferences_path, 'com.apple.Preferences.plist'), &block )
33
40
  end
34
41
 
42
+ def sdk_version
43
+ @sdk_version ||= select_sdk_version
44
+ end
45
+
35
46
  private
36
47
 
37
48
  def edit_file(file)
@@ -43,7 +54,7 @@ module ISRakel
43
54
  def define_reset_task
44
55
  desc "Reset content and settings of the iPhone Simulator"
45
56
  task "#{name}:reset" do
46
- rm_rf simulator_support_path
57
+ rm_rf File.join(simulator_support_path)
47
58
  end
48
59
  end
49
60
 
@@ -66,7 +77,7 @@ module ISRakel
66
77
  def define_start_task
67
78
  desc "Start the iPhone Simulator"
68
79
  task "#{name}:start" do
69
- sh 'open', '-g', simulator_path
80
+ sh 'ios-sim', 'start', '--sdk', sdk_version
70
81
  end
71
82
  end
72
83
 
@@ -83,10 +94,32 @@ module ISRakel
83
94
  cmd.puts hash.to_json
84
95
  end
85
96
 
97
+ def ios_sim_path
98
+ @ios_sim_path ||= `which ios-sim`.chomp
99
+ end
100
+
86
101
  def plist_to_hash(path)
87
102
  JSON.parse( IO.popen(['plutil', '-convert', 'json', '-o', '-', path]) {|f| f.read} )
88
103
  end
89
104
 
105
+ def sdk_versions
106
+ versions = `#{ios_sim_path} showsdks 2>&1`.split("\n").find_all {|version| version =~ /Simulator - iOS (\d\.\d)/ }
107
+ versions.each {|version| version.gsub!(/.*?Simulator - iOS (\d.\d).*?$/, '\1')}
108
+ versions
109
+ end
110
+
111
+ def select_sdk_version
112
+ result = ENV['IOS_SDK_VERSION']
113
+ return result unless result.nil?
114
+ choose do |menu|
115
+ menu.prompt = "Please select an SDK version"
116
+ menu.choices(*sdk_versions) do |version|
117
+ result = version
118
+ end
119
+ end
120
+ result
121
+ end
122
+
90
123
  def simulator_path
91
124
  @simulator_path ||= File.join(xcode_path, 'Platforms', 'iPhoneSimulator.platform', 'Developer', 'Applications', 'iPhone Simulator.app')
92
125
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: israkel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-04 00:00:00.000000000 Z
12
+ date: 2013-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline
@@ -106,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  segments:
108
108
  - 0
109
- hash: -3949644857566582738
109
+ hash: 860845025074019815
110
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  none: false
112
112
  requirements: