ios-box 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ios-box.rb +1 -1
- data/lib/ios-box/iosbox.rb +9 -2
- metadata +13 -14
- data/lib/ios_box.rb +0 -271
data/lib/ios-box.rb
CHANGED
data/lib/ios-box/iosbox.rb
CHANGED
@@ -53,9 +53,16 @@ module IOSBox
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def git
|
56
|
-
@git ||= Grit::Repo.new(
|
56
|
+
@git ||= Grit::Repo.new(git_dir)
|
57
|
+
end
|
58
|
+
|
59
|
+
def git_dir
|
60
|
+
if File.exists?(File.join(project_dir, ".git"))
|
61
|
+
project_dir
|
62
|
+
else
|
63
|
+
%x{git rev-parse --show-toplevel}.strip
|
64
|
+
end
|
57
65
|
end
|
58
|
-
|
59
66
|
|
60
67
|
class Version
|
61
68
|
attr_reader :iosbox
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ios-box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-21 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70253808104160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70253808104160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: grit
|
27
|
-
requirement: &
|
27
|
+
requirement: &70253808103240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70253808103240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: plist
|
38
|
-
requirement: &
|
38
|
+
requirement: &70253808102420 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70253808102420
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rubyzip
|
49
|
-
requirement: &
|
49
|
+
requirement: &70253808101540 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70253808101540
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rest-client
|
60
|
-
requirement: &
|
60
|
+
requirement: &70253808100340 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70253808100340
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: nokogiri
|
71
|
-
requirement: &
|
71
|
+
requirement: &70253808099700 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70253808099700
|
80
80
|
description: Include atuomatic vesion conrol for you XCode projects.
|
81
81
|
email:
|
82
82
|
- mikko@owlforestry.com
|
@@ -108,7 +108,6 @@ files:
|
|
108
108
|
- lib/ios-box/tools/config.rb
|
109
109
|
- lib/ios-box/tools/deploy.rb
|
110
110
|
- lib/ios-box/tools/version.rb
|
111
|
-
- lib/ios_box.rb
|
112
111
|
- spec/build_cache_spec.rb
|
113
112
|
- spec/ios-box_spec.rb
|
114
113
|
- spec/spec_helper.rb
|
data/lib/ios_box.rb
DELETED
@@ -1,271 +0,0 @@
|
|
1
|
-
require 'rake/tasklib'
|
2
|
-
require 'pbxproject'
|
3
|
-
require 'yaml'
|
4
|
-
require 'ostruct'
|
5
|
-
require 'grit'
|
6
|
-
require 'plist'
|
7
|
-
|
8
|
-
require 'build_cache'
|
9
|
-
|
10
|
-
module IOSBox
|
11
|
-
class Tasks < ::Rake::TaskLib
|
12
|
-
def initialize(namespace = :iosbox, &block)
|
13
|
-
@config = Config.new(
|
14
|
-
:configuration => "Adhoc",
|
15
|
-
:build_style => :months,
|
16
|
-
:bundle_version_style => "V.b",
|
17
|
-
:buildCache => ".buildCache"
|
18
|
-
)
|
19
|
-
yield @config
|
20
|
-
|
21
|
-
# Load build cache
|
22
|
-
@buildCache = BuildCache.load(@config.buildCache) || BuildCache.new
|
23
|
-
@buildCache.init(@config)
|
24
|
-
|
25
|
-
@namespace = namespace
|
26
|
-
define
|
27
|
-
end
|
28
|
-
|
29
|
-
class Config < OpenStruct
|
30
|
-
def initialize args
|
31
|
-
super
|
32
|
-
# Do we have XCode environment?
|
33
|
-
if (ENV['XCODE_VERSION_ACTUAL'])
|
34
|
-
self.project_dir = ENV['PROJECT_DIR']
|
35
|
-
self.infoplist_file = ENV['INFOPLIST_FILE']
|
36
|
-
self.plist = File.join(self.project_dir, self.infoplist_file)
|
37
|
-
# Else delay variable initialization until we have build cache
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def define
|
45
|
-
# General namespace
|
46
|
-
namespace(@namespace) do
|
47
|
-
desc "Integrates IosBox to XCode build phases"
|
48
|
-
task :integrate do
|
49
|
-
# Get our xcodeproject from config or find it
|
50
|
-
xcode = @config.project || Dir["*.xcodeproj"].first
|
51
|
-
|
52
|
-
raise "Cannot find project.pbxproj in #{xcode}" unless File.file? "#{xcode}/project.pbxproj"
|
53
|
-
pbx = PBXProject::PBXProject.new :file => "#{xcode}/project.pbxproj"
|
54
|
-
pbx.parse
|
55
|
-
|
56
|
-
# Add build:prepare task to build phases
|
57
|
-
initPhase = PBXProject::PBXTypes::PBXShellScriptBuildPhase.new :shellPath => '/bin/sh', :shellScript => "\"(cd $PROJECT_DIR; rake #{@namespace}:build:prepare)\""
|
58
|
-
pbx.add_item initPhase
|
59
|
-
|
60
|
-
# Add to target
|
61
|
-
target = pbx.find_item :name => @config.target, :type => PBXProject::PBXTypes::PBXNativeTarget
|
62
|
-
target.add_build_phase initPhase, 0
|
63
|
-
|
64
|
-
# Fix DevelopmentRegion
|
65
|
-
project = pbx.find_item :type => PBXProject::PBXTypes::PBXProject
|
66
|
-
project[0].developmentRegion = "en"
|
67
|
-
|
68
|
-
# Save our project file
|
69
|
-
pbx.write_to :file => "#{xcode}/project.pbxproj"
|
70
|
-
end
|
71
|
-
|
72
|
-
# Version mungle
|
73
|
-
desc "Returns current version string"
|
74
|
-
task :version do
|
75
|
-
@plist = Plist::parse_xml(@config.plist)
|
76
|
-
@config._short_version = @plist["CFBundleShortVersionString"]
|
77
|
-
@config._bundle_version = @plist["CFBundleVersion"]
|
78
|
-
|
79
|
-
# Check if we have defined new version number in XCode
|
80
|
-
if (@plist["CFBundleShortVersionString"] != @plist["CFBundleVersion"])
|
81
|
-
# Do we have human version number?
|
82
|
-
if (m = @plist["CFBundleVersion"].match(/(\d+)\.(\d{1,2})(\.(\d+))?$/))
|
83
|
-
ver_str = "%d.%d%s" % [ m[1], m[2], m[4] ? ".#{m[4]}" : "" ]
|
84
|
-
@plist['CFBundleShortVersionString'] = ver_str
|
85
|
-
@plist.save_plist(@config.plist)
|
86
|
-
puts "Version string updated."
|
87
|
-
@config._short_version = @config._bundle_version
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
puts " Short Version: #{@config._short_version}"
|
92
|
-
end
|
93
|
-
|
94
|
-
namespace :version do
|
95
|
-
@ver = {:major => nil, :minor => nil, :patch => nil}
|
96
|
-
def _prepare
|
97
|
-
if (@config.project_dir.nil? || @config.plist.nil?)
|
98
|
-
raise "Cannot find project dir and/or Info.plist. Aither not running from XCode or missing buildCache."
|
99
|
-
end
|
100
|
-
|
101
|
-
@git = Grit::Repo.new("#{@config.project_dir}")
|
102
|
-
@config._commit = @git.commit("HEAD").id_abbrev
|
103
|
-
|
104
|
-
@plist = Plist::parse_xml(@config.plist)
|
105
|
-
if (m = @plist["CFBundleShortVersionString"].match(/(\d+)\.(\d+)(\.(\d+))?/))
|
106
|
-
@ver[:major] = Integer(m[1]) if m[1]
|
107
|
-
@ver[:minor] = Integer(m[2]) if m[2]
|
108
|
-
@ver[:patch] = Integer(m[4]) if m[4]
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def _write_back
|
113
|
-
@plist = Plist::parse_xml(@config.plist) unless @plist
|
114
|
-
ver_str = "%d.%d%s" % [ @ver[:major], @ver[:minor], @ver[:patch] ? ".#{@ver[:patch]}" : "" ]
|
115
|
-
@plist["CFBundleShortVersionString"] = ver_str # Human redable version string
|
116
|
-
@plist["CFBundleVersion"] = ver_str # XCode uses this version, we override this in prebuild
|
117
|
-
@plist.save_plist(@config.plist)
|
118
|
-
end
|
119
|
-
|
120
|
-
desc "Generates Bundle Version"
|
121
|
-
task :bundlever => ["version", "version:buildnum"] do
|
122
|
-
# Build our components
|
123
|
-
comp = {
|
124
|
-
"M" => @ver[:major],
|
125
|
-
"m" => @ver[:minor],
|
126
|
-
"p" => @ver[:patch],
|
127
|
-
"P" => @ver[:patch] ? ".#{@ver[:patch]}" : "",
|
128
|
-
"b" => @config._build_number,
|
129
|
-
"S" => @config._short_version,
|
130
|
-
"V" => @ver[:major] * 10 + @ver[:minor],
|
131
|
-
"v" => @ver[:major] * 100 + @ver[:minor] * 10 + (@ver[:patch] ? @ver[:patch] : 0),
|
132
|
-
"g" => @config._commit,
|
133
|
-
}
|
134
|
-
compre = Regexp.new("[" + comp.keys.join("") + "]")
|
135
|
-
|
136
|
-
style = case @config.bundle_version_style
|
137
|
-
when :short_version
|
138
|
-
"S"
|
139
|
-
when :buildnum
|
140
|
-
"b"
|
141
|
-
when :githash
|
142
|
-
"g"
|
143
|
-
else
|
144
|
-
@config.bundle_version_style
|
145
|
-
end
|
146
|
-
|
147
|
-
@config._bundle_version = style.gsub(compre) do |s|
|
148
|
-
comp[s]
|
149
|
-
end
|
150
|
-
|
151
|
-
puts "Bundle Version: #{@config._bundle_version}"
|
152
|
-
end
|
153
|
-
|
154
|
-
desc "Generate new build number, depending on selected scheme"
|
155
|
-
task :buildnum do
|
156
|
-
_prepare
|
157
|
-
buildnum = case @config.build_style
|
158
|
-
when :months
|
159
|
-
# Open repository and find out
|
160
|
-
prj_begin = Time.now
|
161
|
-
if (@config.first_revision)
|
162
|
-
prj_begin = @git.commit(@config.first_revision).authored_date
|
163
|
-
elsif (@config.first_date)
|
164
|
-
prj_begin = @config.first_date
|
165
|
-
else
|
166
|
-
prj_begin = @git.log.last.authored_date
|
167
|
-
end
|
168
|
-
|
169
|
-
months = ((Time.now.month + 12 * Time.now.year) - (prj_begin.month + 12 * prj_begin.year))
|
170
|
-
"%d%02d" % [months, Time.now.day]
|
171
|
-
end
|
172
|
-
|
173
|
-
@config._build_number = buildnum
|
174
|
-
puts " Build number: #{buildnum}"
|
175
|
-
end
|
176
|
-
|
177
|
-
desc "Writes exact version number"
|
178
|
-
task :write, :version do |t, args|
|
179
|
-
@plist = Plist::parse_xml(@config.plist)
|
180
|
-
@plist["CFBundleShortVersionString"] = args[:version]
|
181
|
-
@plist.save_plist(@config.plist)
|
182
|
-
puts "Short Version: #{args[:version]}"
|
183
|
-
end
|
184
|
-
|
185
|
-
desc "Bumps version up"
|
186
|
-
task :bump do
|
187
|
-
_prepare
|
188
|
-
|
189
|
-
# if we have patch, bump it up
|
190
|
-
if (@ver[:patch])
|
191
|
-
@ver[:patch] += 1
|
192
|
-
elsif (@ver[:minor])
|
193
|
-
@ver[:minor] += 1
|
194
|
-
else
|
195
|
-
@ver[:major] += 1
|
196
|
-
end
|
197
|
-
_write_back
|
198
|
-
puts "Bumped Version: " + "%d.%d%s" % [ @ver[:major], @ver[:minor], @ver[:patch] ? ".#{@ver[:patch]}" : "" ]
|
199
|
-
end
|
200
|
-
|
201
|
-
namespace :bump do
|
202
|
-
desc "Bumps major version up"
|
203
|
-
task :major do
|
204
|
-
_prepare
|
205
|
-
@ver[:major] = @ver[:major] ? @ver[:major] + 1 : 1
|
206
|
-
@ver[:minor] = 0
|
207
|
-
@ver[:patch] = nil
|
208
|
-
_write_back
|
209
|
-
puts "Bumped Version: " + "%d.%d%s" % [ @ver[:major], @ver[:minor], @ver[:patch] ? ".#{@ver[:patch]}" : "" ]
|
210
|
-
end
|
211
|
-
|
212
|
-
desc "Bumps minor version up"
|
213
|
-
task :minor do
|
214
|
-
_prepare
|
215
|
-
@ver[:minor] = @ver[:minor] ? @ver[:minor] + 1 : 1
|
216
|
-
@ver[:patch] = nil
|
217
|
-
_write_back
|
218
|
-
puts "Bumped Version: " + "%d.%d%s" % [ @ver[:major], @ver[:minor], @ver[:patch] ? ".#{@ver[:patch]}" : "" ]
|
219
|
-
end
|
220
|
-
|
221
|
-
desc "Bumps patch version up"
|
222
|
-
task :patch do
|
223
|
-
_prepare
|
224
|
-
@ver[:patch] = @ver[:patch] ? @ver[:patch] + 1 : 1
|
225
|
-
_write_back
|
226
|
-
puts "Bumped Version: " + "%d.%d%s" % [ @ver[:major], @ver[:minor], @ver[:patch] ? ".#{@ver[:patch]}" : "" ]
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
end
|
231
|
-
|
232
|
-
namespace :build do
|
233
|
-
|
234
|
-
desc "Prepares build environment"
|
235
|
-
task :prepare => ["version:bundlever"] do
|
236
|
-
raise "This task must be run in XCode Environment" unless ENV['XCODE_VERSION_ACTUAL']
|
237
|
-
|
238
|
-
# Save our environment variables
|
239
|
-
["BUILT_PRODUCTS_DIR", "BUILD_DIR", "CONFIGURATION", "CONFIGURATION_BUILD_DIR",
|
240
|
-
"PROJECT_DIR", "INFOPLIST_FILE", "TARGET_NAME"].each { |v|
|
241
|
-
# @buildCache.set v.downcase, ENV[v] unless ENV[v].nil?
|
242
|
-
@buildCache.send("#{v.downcase}=", ENV[v]) unless ENV[v].nil?
|
243
|
-
}
|
244
|
-
|
245
|
-
# Increase buildcounter
|
246
|
-
if (@buildCache.build_counter.nil?)
|
247
|
-
@buildCache.build_counter = 0
|
248
|
-
end
|
249
|
-
|
250
|
-
@buildCache.build_counter += 1
|
251
|
-
@buildCache.save
|
252
|
-
|
253
|
-
# Save version info
|
254
|
-
product_plist = File.join(ENV['BUILT_PRODUCTS_DIR'], ENV['INFOPLIST_PATH'])
|
255
|
-
`/usr/bin/plutil -convert xml1 \"#{product_plist}\"`
|
256
|
-
pl = Plist::parse_xml(product_plist)
|
257
|
-
if (pl)
|
258
|
-
pl["CFBundleVersion"] = @config._bundle_version
|
259
|
-
pl["IBBuildNum"] = @config._build_number
|
260
|
-
pl["IBBuildDate"] = Time.new.strftime("%a %e %b %Y %H:%M:%S %Z %z")
|
261
|
-
pl["IBBuildType"] = ENV['CONFIGURATION']
|
262
|
-
pl["GCGitCommitHash"] = @config._commit # for hoptoadapp
|
263
|
-
pl.save_plist(product_plist)
|
264
|
-
end
|
265
|
-
`/usr/bin/plutil -convert binary1 \"#{product_plist}\"`
|
266
|
-
end
|
267
|
-
end
|
268
|
-
end
|
269
|
-
end
|
270
|
-
end
|
271
|
-
end
|