ios-box 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Rakefile +1 -1
  2. data/VERSION +1 -1
  3. data/ios-box.gemspec +4 -4
  4. data/lib/ios_box.rb +43 -4
  5. metadata +3 -3
data/Rakefile CHANGED
@@ -23,7 +23,7 @@ Jeweler::Tasks.new do |gem|
23
23
  gem.files.include %w(lib/**/*.rb)
24
24
  # Include your dependencies below. Runtime dependencies are required when using your gem,
25
25
  # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
26
- gem.add_runtime_dependency 'pbxproject'
26
+ gem.add_runtime_dependency 'pbxproject', '>=0.1.4'
27
27
  gem.add_runtime_dependency 'plist'
28
28
  gem.add_runtime_dependency 'grit'
29
29
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/ios-box.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ios-box}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mikko Kokkonen"]
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
51
51
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
52
52
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
53
53
  s.add_development_dependency(%q<rcov>, [">= 0"])
54
- s.add_runtime_dependency(%q<pbxproject>, [">= 0"])
54
+ s.add_runtime_dependency(%q<pbxproject>, [">= 0.1.4"])
55
55
  s.add_runtime_dependency(%q<plist>, [">= 0"])
56
56
  s.add_runtime_dependency(%q<grit>, [">= 0"])
57
57
  s.add_development_dependency(%q<rspec>, ["> 1.2.3"])
@@ -62,7 +62,7 @@ Gem::Specification.new do |s|
62
62
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
63
63
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
64
64
  s.add_dependency(%q<rcov>, [">= 0"])
65
- s.add_dependency(%q<pbxproject>, [">= 0"])
65
+ s.add_dependency(%q<pbxproject>, [">= 0.1.4"])
66
66
  s.add_dependency(%q<plist>, [">= 0"])
67
67
  s.add_dependency(%q<grit>, [">= 0"])
68
68
  s.add_dependency(%q<rspec>, ["> 1.2.3"])
@@ -74,7 +74,7 @@ Gem::Specification.new do |s|
74
74
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
75
75
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
76
76
  s.add_dependency(%q<rcov>, [">= 0"])
77
- s.add_dependency(%q<pbxproject>, [">= 0"])
77
+ s.add_dependency(%q<pbxproject>, [">= 0.1.4"])
78
78
  s.add_dependency(%q<plist>, [">= 0"])
79
79
  s.add_dependency(%q<grit>, [">= 0"])
80
80
  s.add_dependency(%q<rspec>, ["> 1.2.3"])
data/lib/ios_box.rb CHANGED
@@ -18,11 +18,23 @@ module IosBox
18
18
 
19
19
  # Load build cache
20
20
  @buildCache = BuildCache.load(@config.buildCache) || BuildCache.new
21
+ @buildCache.init(@config)
22
+
21
23
  @namespace = namespace
22
24
  define
23
25
  end
24
26
 
25
27
  class BuildCache
28
+ def init config
29
+ # Fill our config object
30
+ # But only if it hasn't been initialized yet and not in XCode env
31
+ if (config.project_dir.nil? && ENV['XCODE_VERSION_ACTUAL'].nil?)
32
+ config.project_dir = @project_dir
33
+ config.infoplist_file= @infoplist_file
34
+ config.plist = File.join(@project_dir, @infoplist_file)
35
+ end
36
+ end
37
+
26
38
  def self.load file = ".buildCache"
27
39
  return unless File.file?(file)
28
40
  YAML.load_file(file)
@@ -36,7 +48,13 @@ module IosBox
36
48
  class Config < OpenStruct
37
49
  def initialize args
38
50
  super
39
- self.plist = File.join(ENV['PROJECT_DIR'] || '', ENV['INFOPLIST_FILE'] || '')
51
+ # Do we have XCode environment?
52
+ if (ENV['XCODE_VERSION_ACTUAL'])
53
+ self.project_dir = ENV['PROJECT_DIR']
54
+ self.infoplist_file = ENV['INFOPLIST_FILE']
55
+ self.plist = File.join(self.project_dir, self.infoplist_file)
56
+ # Else delay variable initialization until we have build cache
57
+ end
40
58
  end
41
59
  end
42
60
 
@@ -71,13 +89,31 @@ module IosBox
71
89
  task :version do
72
90
  @plist = Plist::parse_xml(@config.plist)
73
91
  @config._short_version = @plist["CFBundleShortVersionString"]
92
+ @config._bundle_version = @plist["CFBundleVersion"]
93
+
94
+ # Check if we have defined new version number in XCode
95
+ if (@plist["CFBundleShortVersionString"] != @plist["CFBundleVersion"])
96
+ # Do we have human version number?
97
+ if (m = @plist["CFBundleVersion"].match(/(\d+)\.(\d{1,2})(\.(\d+))?$/))
98
+ ver_str = "%d.%d%s" % [ m[1], m[2], m[4] ? ".#{m[4]}" : "" ]
99
+ @plist['CFBundleShortVersionString'] = ver_str
100
+ @plist.save_plist(@config.plist)
101
+ puts "Version string updated."
102
+ @config._short_version = @config._bundle_version
103
+ end
104
+ end
105
+
74
106
  puts " Short Version: #{@config._short_version}"
75
107
  end
76
108
 
77
109
  namespace :version do
78
110
  @ver = {:major => nil, :minor => nil, :patch => nil}
79
111
  def _prepare
80
- @git = Grit::Repo.new("#{ENV['PROJECT_DIR']}")
112
+ if (@config.project_dir.nil? || @config.plist.nil?)
113
+ raise "Cannot find project dir and/or Info.plist. Aither not running from XCode or missing buildCache."
114
+ end
115
+
116
+ @git = Grit::Repo.new("#{@config.project_dir}")
81
117
  @config._commit = @git.commit("HEAD").id_abbrev
82
118
 
83
119
  @plist = Plist::parse_xml(@config.plist)
@@ -91,7 +127,8 @@ module IosBox
91
127
  def _write_back
92
128
  @plist = Plist::parse_xml(@config.plist) unless @plist
93
129
  ver_str = "%d.%d%s" % [ @ver[:major], @ver[:minor], @ver[:patch] ? ".#{@ver[:patch]}" : "" ]
94
- @plist["CFBundleShortVersionString"] = ver_str
130
+ @plist["CFBundleShortVersionString"] = ver_str # Human redable version string
131
+ @plist["CFBundleVersion"] = ver_str # XCode uses this version, we override this in prebuild
95
132
  @plist.save_plist(@config.plist)
96
133
  end
97
134
 
@@ -211,10 +248,12 @@ module IosBox
211
248
 
212
249
  desc "Prepares build environment"
213
250
  task :prepare => ["version:bundlever"] do
251
+ raise "This task must be run in XCode Environment" unless ENV['XCODE_VERSION_ACTUAL']
252
+
214
253
  # Save our environment variables
215
254
  ["BUILT_PRODUCTS_DIR", "BUILD_DIR", "CONFIGURATION", "CONFIGURATION_BUILD_DIR",
216
255
  "PROJECT_DIR", "INFOPLIST_FILE", "TARGET_NAME"].each { |v|
217
- @buildCache.instance_variable_set("@#{v.downcase}", ENV[v])
256
+ @buildCache.instance_variable_set("@#{v.downcase}", ENV[v]) unless ENV[v].nil?
218
257
  }
219
258
  @buildCache.save
220
259
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ios-box
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mikko Kokkonen
@@ -86,7 +86,7 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: "0"
89
+ version: 0.1.4
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: *id007
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
160
  requirements:
161
161
  - - ">="
162
162
  - !ruby/object:Gem::Version
163
- hash: 4585312451122071517
163
+ hash: 682603116973402455
164
164
  segments:
165
165
  - 0
166
166
  version: "0"