ios-box 0.1.0 → 0.2.0

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/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile CHANGED
@@ -1,18 +1,4 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
1
+ source 'http://rubygems.org'
5
2
 
6
- gem "plist"
7
- gem "pbxproject"
8
- gem "plist"
9
- gem "grit"
10
-
11
- # Add dependencies to develop your gem here.
12
- # Include everything needed to run rake, tests, features, etc.
13
- group :development do
14
- gem "rspec", "~> 2.3.0"
15
- gem "bundler", "~> 1.0.0"
16
- gem "jeweler", "~> 1.5.2"
17
- gem "rcov", ">= 0"
18
- end
3
+ # Specify your gem's dependencies in ios-box.gemspec
4
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,37 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ios-box (0.0.1)
5
+ grit
6
+ plist
7
+ thor
8
+
1
9
  GEM
2
10
  remote: http://rubygems.org/
3
11
  specs:
4
- diff-lcs (1.1.2)
5
- git (1.2.5)
12
+ diff-lcs (1.1.3)
6
13
  grit (2.4.1)
7
14
  diff-lcs (~> 1.1)
8
15
  mime-types (~> 1.15)
9
- jeweler (1.5.2)
10
- bundler (~> 1.0.0)
11
- git (>= 1.2.5)
12
- rake
13
16
  mime-types (1.16)
14
- pbxproject (0.1.0)
15
17
  plist (3.1.0)
16
- rake (0.8.7)
17
- rcov (0.9.9)
18
- rspec (2.3.0)
19
- rspec-core (~> 2.3.0)
20
- rspec-expectations (~> 2.3.0)
21
- rspec-mocks (~> 2.3.0)
22
- rspec-core (2.3.1)
23
- rspec-expectations (2.3.0)
24
- diff-lcs (~> 1.1.2)
25
- rspec-mocks (2.3.0)
18
+ thor (0.14.6)
26
19
 
27
20
  PLATFORMS
28
21
  ruby
29
22
 
30
23
  DEPENDENCIES
31
- bundler (~> 1.0.0)
32
- grit
33
- jeweler (~> 1.5.2)
34
- pbxproject
35
- plist
36
- rcov
37
- rspec (~> 2.3.0)
24
+ ios-box!
data/Rakefile CHANGED
@@ -1,58 +1,2 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'rake'
11
-
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gem|
14
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
- gem.name = "ios-box"
16
- gem.homepage = "http://github.com/owl-foresty/ios-box"
17
- gem.license = "MIT"
18
- gem.summary = %Q{Automates some common tasks in iOS development}
19
- gem.description = %Q{ios-box offers automation and easy tasks for some most common tasks in iOS development.}
20
- gem.email = "mikko.kokkonen@me.com"
21
- gem.authors = ["Mikko Kokkonen"]
22
-
23
- gem.files.include %w(lib/**/*.rb)
24
- # Include your dependencies below. Runtime dependencies are required when using your gem,
25
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
26
- gem.add_runtime_dependency 'pbxproject', '>=0.1.4'
27
- gem.add_runtime_dependency 'plist'
28
- gem.add_runtime_dependency 'grit'
29
-
30
- gem.add_development_dependency 'rspec', '> 1.2.3'
31
- gem.add_development_dependency 'pbxproject', '>=0.1.4'
32
- gem.add_development_dependency 'grit'
33
- gem.add_development_dependency 'plist'
34
- end
35
- Jeweler::RubygemsDotOrgTasks.new
36
-
37
- require 'rspec/core'
38
- require 'rspec/core/rake_task'
39
- RSpec::Core::RakeTask.new(:spec) do |spec|
40
- spec.pattern = FileList['spec/**/*_spec.rb']
41
- end
42
-
43
- RSpec::Core::RakeTask.new(:rcov) do |spec|
44
- spec.pattern = 'spec/**/*_spec.rb'
45
- spec.rcov = true
46
- end
47
-
48
- task :default => :spec
49
-
50
- require 'rake/rdoctask'
51
- Rake::RDocTask.new do |rdoc|
52
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
53
-
54
- rdoc.rdoc_dir = 'rdoc'
55
- rdoc.title = "ios-box #{version}"
56
- rdoc.rdoc_files.include('README*')
57
- rdoc.rdoc_files.include('lib/**/*.rb')
58
- end
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/ios-box ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ # $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+
5
+ require 'ios-box/cli'
6
+
7
+ Ios::Box::CLI.start
data/ios-box.gemspec CHANGED
@@ -1,103 +1,21 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/ios-box/version', __FILE__)
5
3
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{ios-box}
8
- s.version = "0.1.0"
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Mikko Kokkonen"]
6
+ gem.email = ["mikko@owlforestry.com"]
7
+ gem.description = %q{Include atuomatic vesion conrol for you XCode projects.}
8
+ gem.summary = %q{Add handy tools to XCode specially for iOS development}
9
+ gem.homepage = "https://github.com/owl-forestry/ios-box"
9
10
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Mikko Kokkonen"]
12
- s.date = %q{2011-05-14}
13
- s.description = %q{ios-box offers automation and easy tasks for some most common tasks in iOS development.}
14
- s.email = %q{mikko.kokkonen@me.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.md"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".rspec",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE.txt",
25
- "README.md",
26
- "Rakefile",
27
- "VERSION",
28
- "dump",
29
- "ios-box.gemspec",
30
- "lib/build_cache.rb",
31
- "lib/ios-box.rb",
32
- "lib/ios_box.rb",
33
- "patch",
34
- "spec/build_cache_spec.rb",
35
- "spec/ios-box_spec.rb",
36
- "spec/spec_helper.rb"
37
- ]
38
- s.homepage = %q{http://github.com/owl-foresty/ios-box}
39
- s.licenses = ["MIT"]
40
- s.require_paths = ["lib"]
41
- s.rubygems_version = %q{1.6.2}
42
- s.summary = %q{Automates some common tasks in iOS development}
43
- s.test_files = [
44
- "spec/build_cache_spec.rb",
45
- "spec/ios-box_spec.rb",
46
- "spec/spec_helper.rb"
47
- ]
48
-
49
- if s.respond_to? :specification_version then
50
- s.specification_version = 3
51
-
52
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
- s.add_runtime_dependency(%q<plist>, [">= 0"])
54
- s.add_runtime_dependency(%q<pbxproject>, [">= 0"])
55
- s.add_runtime_dependency(%q<plist>, [">= 0"])
56
- s.add_runtime_dependency(%q<grit>, [">= 0"])
57
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
58
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
59
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
60
- s.add_development_dependency(%q<rcov>, [">= 0"])
61
- s.add_runtime_dependency(%q<pbxproject>, [">= 0.1.4"])
62
- s.add_runtime_dependency(%q<plist>, [">= 0"])
63
- s.add_runtime_dependency(%q<grit>, [">= 0"])
64
- s.add_development_dependency(%q<rspec>, ["> 1.2.3"])
65
- s.add_development_dependency(%q<pbxproject>, [">= 0.1.4"])
66
- s.add_development_dependency(%q<grit>, [">= 0"])
67
- s.add_development_dependency(%q<plist>, [">= 0"])
68
- else
69
- s.add_dependency(%q<plist>, [">= 0"])
70
- s.add_dependency(%q<pbxproject>, [">= 0"])
71
- s.add_dependency(%q<plist>, [">= 0"])
72
- s.add_dependency(%q<grit>, [">= 0"])
73
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
74
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
75
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
76
- s.add_dependency(%q<rcov>, [">= 0"])
77
- s.add_dependency(%q<pbxproject>, [">= 0.1.4"])
78
- s.add_dependency(%q<plist>, [">= 0"])
79
- s.add_dependency(%q<grit>, [">= 0"])
80
- s.add_dependency(%q<rspec>, ["> 1.2.3"])
81
- s.add_dependency(%q<pbxproject>, [">= 0.1.4"])
82
- s.add_dependency(%q<grit>, [">= 0"])
83
- s.add_dependency(%q<plist>, [">= 0"])
84
- end
85
- else
86
- s.add_dependency(%q<plist>, [">= 0"])
87
- s.add_dependency(%q<pbxproject>, [">= 0"])
88
- s.add_dependency(%q<plist>, [">= 0"])
89
- s.add_dependency(%q<grit>, [">= 0"])
90
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
91
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
92
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
93
- s.add_dependency(%q<rcov>, [">= 0"])
94
- s.add_dependency(%q<pbxproject>, [">= 0.1.4"])
95
- s.add_dependency(%q<plist>, [">= 0"])
96
- s.add_dependency(%q<grit>, [">= 0"])
97
- s.add_dependency(%q<rspec>, ["> 1.2.3"])
98
- s.add_dependency(%q<pbxproject>, [">= 0.1.4"])
99
- s.add_dependency(%q<grit>, [">= 0"])
100
- s.add_dependency(%q<plist>, [">= 0"])
101
- end
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "ios-box"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Ios::Box::VERSION
17
+
18
+ gem.add_runtime_dependency "thor"
19
+ gem.add_runtime_dependency "grit"
20
+ gem.add_runtime_dependency "plist"
102
21
  end
103
-
data/lib/ios-box.rb CHANGED
@@ -1 +1,7 @@
1
- require 'ios_box'
1
+ require "ios-box/version"
2
+
3
+ module Ios
4
+ module Box
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,96 @@
1
+ require 'ios-box/tools'
2
+ require 'ios-box/iosbox'
3
+ require 'thor'
4
+ require 'pbxproject'
5
+
6
+ module Ios
7
+ module Box
8
+ class CLI < Thor
9
+ include Thor::Actions
10
+
11
+ desc "version COMMAND", "Version related subcommands"
12
+ subcommand "version", Tools::Version
13
+
14
+ desc "build COMMAND", "Build related subcommands"
15
+ subcommand "build", Tools::Build
16
+
17
+ desc "integrate [PROJECT]", "Integrates ios-box with project, by default first founded"
18
+ def integrate(project = nil)
19
+ shell = Thor::Shell::Basic.new
20
+
21
+ # Find our project
22
+ if project.nil?
23
+ project = Dir["*.xcodeproj"].first
24
+ end
25
+
26
+ unless File.exists?(project) and File.directory?(project)
27
+ shell.error "Project #{project} is not valid."
28
+ exit
29
+ end
30
+
31
+ shell.say "Integrating to project #{project}"
32
+
33
+ # Find our project file, either from command-line or just using first one
34
+ xcode = project || Dir["*.xcodeproj"].first
35
+ raise "Cannot find project.pbxproj in #{xcode}" unless File.file? "#{xcode}/project.pbxproj"
36
+
37
+ # Load our project file
38
+ pbx = PBXProject::PBXProject.new :file => "#{xcode}/project.pbxproj"
39
+ pbx.parse
40
+
41
+ # If target missing, fetch first target
42
+ # Find all targets
43
+ targets = pbx.find_item :type => PBXProject::PBXTypes::PBXNativeTarget
44
+ if targets.nil? or targets.empty?
45
+ raise "XCode project does not have any targets!"
46
+ end
47
+
48
+ # Generate build phase
49
+ # Try to find build phases
50
+ # prebuilds = pbx.find_item(:type => PBXProject::PBXTypes::PBXShellScriptBuildPhase) || []
51
+ # prebuilds.select! do |c|
52
+ # !c.comment.match(/ios-box prepare/).nil?
53
+ # end
54
+ #
55
+ prebuilds = [] # Always add new build phase
56
+ if prebuilds.empty?
57
+ initPhase = PBXProject::PBXTypes::PBXShellScriptBuildPhase.new(
58
+ :shellPath => '/bin/sh',
59
+ :shellScript => "\"(cd $PROJECT_DIR; ruby ~/Code/ios-box/bin/ios-box build prepare)\"",
60
+ :showEnvVarsInLog => 0,
61
+ :name => '"ios-box prepare"'
62
+ )
63
+ initPhase.comment = "ios-box prepare"
64
+
65
+ pbx.add_item initPhase
66
+ else
67
+ initPhase = prebuilds.first
68
+ end
69
+
70
+ _targets = ""
71
+ targets.each do |target|
72
+ if shell.yes?("Integrate with target #{target.name.value}? [yn]")
73
+ # Inject buildphase to target
74
+ # Add to target
75
+ target.add_build_phase initPhase, 0
76
+ _targets << "config.targets << \"#{target.name.value}\""
77
+ end
78
+ end
79
+
80
+ # Create iosbox configuration file
81
+ create_file ".iosbox" do
82
+ "# ios-box configuration file\n" +
83
+ "# https://github.com/owl-forestry/ios-box\n" +
84
+ "#\n" +
85
+ "config.project = \"#{project}\"\n" +
86
+ "#{_targets}\n"
87
+ end
88
+ # Append buildcache to gitignore
89
+ send((File.exists?(".gitignore") ? :append_to_file : :create_file), ".gitignore", ".buildcache\n")
90
+
91
+ # Write project file
92
+ pbx.write_to :file => "#{xcode}/project.pbxproj"
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,23 @@
1
+ module Ios
2
+ module Box
3
+ class Config
4
+ attr_accessor :project
5
+ attr_reader :targets
6
+
7
+ def self.load(file = ".iosbox")
8
+ config = self.new
9
+ config.instance_eval(File.read(file), file)
10
+ config
11
+ end
12
+
13
+ def initialize
14
+ @targets = []
15
+ @project = nil
16
+ end
17
+
18
+ def config
19
+ self
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,235 @@
1
+ require 'ios-box/config'
2
+ require 'rubygems'
3
+ require 'yaml'
4
+ require 'grit'
5
+ require 'plist'
6
+
7
+ module Ios::Box
8
+ class IOSBox
9
+ attr_reader :config, :cache, :version
10
+
11
+ def initialize
12
+ @config = Config.load
13
+ @cache = Cache.load
14
+ @version = Version.new(self)
15
+ end
16
+
17
+ class Version
18
+ attr_reader :iosbox
19
+
20
+ def initialize(iosbox)
21
+ @iosbox = iosbox
22
+ end
23
+
24
+ def load
25
+ # Return cached version
26
+ return @version if @version
27
+
28
+ # iOS code
29
+ # XCode environment?
30
+ # Load buildcache if exists
31
+ if ENV['XCODE_VERSION_ACTUAL']
32
+ plist_file = File.join(ENV['PROJECT_DIR'], ENV['INFOPLIST_FILE'])
33
+ project_dir = ENV['PROJECT_DIR']
34
+ else
35
+ # Do we have buildcache?
36
+ if iosbox.cache[:latest]
37
+ configuration = iosbox.cache[:latest]
38
+ plist_file = File.join(iosbox.cache[configuration][:project_dir], iosbox.cache[configuration][:infoplist_file])
39
+ project_dir = iosbox.cache[configuration][:project_dir]
40
+ else
41
+ raise "Build cache has not been filled, please build project."
42
+ end
43
+ end
44
+
45
+ # Detect our commit hash
46
+ git = Grit::Repo.new("#{project_dir}")
47
+
48
+ plist = Plist::parse_xml(plist_file)
49
+
50
+ # Build normal version hash
51
+ @version = {
52
+ :short => plist["CFBundleShortVersionString"],
53
+ :bundle => plist["CFBundleVersion"],
54
+ :commit => git.commit("HEAD").id_abbrev,
55
+ }
56
+
57
+ # Build technical version number
58
+ if (m = plist["CFBundleShortVersionString"].match(/(\d+)\.(\d+)(\.(\d+))?/))
59
+ @version[:major] = Integer(m[1]) if m[1]
60
+ @version[:minor] = Integer(m[2]) if m[2]
61
+ @version[:patch] = Integer(m[4]) if m[4]
62
+ @version[:technical] = @version[:major] + ((@version[:minor] * 100) / 1000.0)
63
+ if @version[:patch]
64
+ @version[:technical] += ((@version[:patch] > 10) ? @version[:patch] : @version[:patch] * 10) / 1000.0
65
+ end
66
+ end
67
+
68
+ # Fetch current build number (project version)
69
+ # Check if we have build number in cache
70
+
71
+ @version[:build_number] = fetch_build_number
72
+
73
+ @version
74
+ end
75
+
76
+ def [](v)
77
+ @version ||= load
78
+ @version[v]
79
+ end
80
+
81
+ def []=(v, s)
82
+ @version ||= load
83
+ @version[v] = s
84
+ end
85
+
86
+ def marketing_version
87
+ "%d.%d%s" % [ @version[:major], @version[:minor], @version[:patch] ? ".#{@version[:patch]}" : "" ]
88
+ end
89
+
90
+ def bump_build(buildnum = nil)
91
+ # Fetch current build number (project version)
92
+ # Check if we have build number in cache
93
+ if buildnum.nil?
94
+ build = (fetch_build_number || 0) + 1
95
+ else
96
+ build = buildnum
97
+ end
98
+
99
+ store_build_number(build)
100
+
101
+ puts "Build number increased to #{iosbox.cache[:build_number]}"
102
+ end
103
+
104
+ def set_marketing(verstr)
105
+ pl = Plist::parse_xml(plist)
106
+ pl["CFBundleShortVersionString"] = verstr
107
+ pl.save_plist(plist)
108
+ end
109
+
110
+ def bump_marketing(type = :patch)
111
+ load
112
+
113
+ if type == :major
114
+ @version[:patch] = nil
115
+ @version[:minor] = 0
116
+ @version[:major] += 1
117
+ elsif type == :minor
118
+ @version[:patch] = nil
119
+ @version[:minor] += 1
120
+ elsif type == :patch
121
+ @version[:patch] = (@version[:patch] || 0) + 1
122
+ end
123
+
124
+ pl = Plist::parse_xml(plist)
125
+ pl["CFBundleShortVersionString"] = marketing_version
126
+ pl.save_plist(plist)
127
+
128
+ puts "New marketing version #{marketing_version}"
129
+ end
130
+
131
+ private
132
+ def fetch_build_number
133
+ unless iosbox.cache[:build_number]
134
+ puts "Project: #{iosbox.config.project}"
135
+ pbx = PBXProject::PBXProject.new :file => File.join(iosbox.config.project, "project.pbxproj")
136
+ pbx.parse
137
+
138
+ iosbox.config.targets.each do |target|
139
+ target = pbx.find_item :name => target, :type => PBXProject::PBXTypes::PBXNativeTarget
140
+ cl = pbx.find_item :guid => target.buildConfigurationList.value, :type => PBXProject::PBXTypes::XCConfigurationList
141
+ cl.buildConfigurations.each do |bc|
142
+ bc = pbx.find_item :guid => bc.value, :type => PBXProject::PBXTypes::XCBuildConfiguration
143
+
144
+ if bc.buildSettings["CURRENT_PROJECT_VERSION"]
145
+ iosbox.cache[:build_number] = bc.buildSettings["CURRENT_PROJECT_VERSION"].value
146
+ break
147
+ end
148
+ end
149
+
150
+ break if iosbox.cache[:build_number]
151
+ end
152
+
153
+ # Save build number to cache
154
+ iosbox.cache.save
155
+ end
156
+
157
+ Integer(iosbox.cache[:build_number] || 0)
158
+ end
159
+
160
+ def store_build_number(build)
161
+ puts "Project: #{iosbox.config.project}"
162
+ pbx = PBXProject::PBXProject.new :file => File.join(iosbox.config.project, "project.pbxproj")
163
+ pbx.parse
164
+
165
+ iosbox.config.targets.each do |target|
166
+ target = pbx.find_item :name => target, :type => PBXProject::PBXTypes::PBXNativeTarget
167
+ cl = pbx.find_item :guid => target.buildConfigurationList.value, :type => PBXProject::PBXTypes::XCConfigurationList
168
+ cl.buildConfigurations.each do |bc|
169
+ bc = pbx.find_item :guid => bc.value, :type => PBXProject::PBXTypes::XCBuildConfiguration
170
+
171
+ if bc.buildSettings["CURRENT_PROJECT_VERSION"]
172
+ bc.buildSettings["CURRENT_PROJECT_VERSION"].value = "\"#{build}\""
173
+ else
174
+ bc.buildSettings["CURRENT_PROJECT_VERSION"] = PBXProject::PBXTypes::BasicValue.new :value => "\"#{build}\""
175
+ end
176
+ end
177
+ end
178
+
179
+ # Save build number to pbxproject and to cache
180
+ pbx.write_to :file => File.join(iosbox.config.project, "project.pbxproj")
181
+ iosbox.cache[:build_number] = build
182
+ iosbox.cache.save
183
+ end
184
+
185
+ # Return plist file name
186
+ def plist
187
+ if ENV['XCODE_VERSION_ACTUAL']
188
+ file = File.join(ENV['PROJECT_DIR'], ENV['INFOPLIST_FILE'])
189
+ else
190
+ # Do we have buildcache?
191
+ if iosbox.cache[:latest]
192
+ configuration = iosbox.cache[:latest]
193
+ file = File.join(iosbox.cache[configuration][:project_dir], iosbox.cache[configuration][:infoplist_file])
194
+ else
195
+ raise "Build cache has not been filled, please build project."
196
+ end
197
+ end
198
+
199
+ file
200
+ end
201
+ end
202
+ end
203
+
204
+
205
+
206
+ class Cache
207
+ attr_accessor :cache
208
+
209
+ def self.load(file = ".buildcache")
210
+ cache = Cache.new
211
+
212
+ if File.exists?(file)
213
+ cache.cache = YAML.load(File.read(file))
214
+ end
215
+
216
+ cache
217
+ end
218
+
219
+ def initialize
220
+ @cache = {}
221
+ end
222
+
223
+ def [](v)
224
+ @cache[v]
225
+ end
226
+
227
+ def []=(v, s)
228
+ @cache[v] = s
229
+ end
230
+
231
+ def save(file = ".buildcache")
232
+ File.open(file, 'w') { |io| io.puts @cache.to_yaml }
233
+ end
234
+ end
235
+ end
@@ -0,0 +1,23 @@
1
+ require 'ios-box/config'
2
+ require 'ios-box/iosbox'
3
+
4
+ require 'rake/tasklib'
5
+ require 'rubygems'
6
+ require 'yaml'
7
+ require 'grit'
8
+ require 'plist'
9
+ require 'pbxproject'
10
+
11
+ module Ios
12
+ module Box
13
+ class Tasks < ::Rake::TaskLib
14
+ def initialize(namespace = :iosbox, &block)
15
+ end
16
+
17
+ private
18
+ def require_xcode
19
+ raise "This task must be run in XCode Environment" unless ENV['XCODE_VERSION_ACTUAL']
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ require 'ios-box/iosbox'
2
+ require 'thor'
3
+
4
+ module Ios
5
+ module Box
6
+ module Tools
7
+ autoload :Version, 'ios-box/tools/version'
8
+ autoload :Build, 'ios-box/tools/build'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,62 @@
1
+ module Ios
2
+ module Box
3
+ module Tools
4
+ class Build < Thor
5
+
6
+ desc "prepare", "Prepare build environment from XCode"
7
+ def prepare
8
+ # Make sure we are in XCode environment
9
+ require_xcode
10
+
11
+ # Update build cache
12
+ update_cache
13
+
14
+ version = IOSBox.new.version
15
+
16
+ # Calculate build number (displayed)
17
+ puts "TODO: build number"
18
+
19
+ # Inject information to Info.plist
20
+ product_plist = File.join(ENV['BUILT_PRODUCTS_DIR'], ENV['INFOPLIST_PATH'])
21
+
22
+ # Convert PList to XML
23
+ `/usr/bin/plutil -convert xml1 \"#{product_plist}\"`
24
+ pl = Plist::parse_xml(product_plist)
25
+ if (pl)
26
+ # pl["CFBundleVersion"] = @config._bundle_version
27
+ pl["IBBuildNum"] = version[:build_number]
28
+ pl["IBBuildDate"] = Time.new.strftime("%a %e %b %Y %H:%M:%S %Z %z")
29
+ pl["IBBuildType"] = ENV['CONFIGURATION']
30
+ pl["GCGitCommitHash"] = version[:commit] # for hoptoadapp
31
+ pl.save_plist(product_plist)
32
+ end
33
+ # Convert PList back to binary
34
+ `/usr/bin/plutil -convert binary1 \"#{product_plist}\"`
35
+ end
36
+
37
+ private
38
+
39
+ def update_cache
40
+ cache = IOSBox.new.cache
41
+
42
+ # Save our environment variables
43
+ if ENV["CONFIGURATION"]
44
+ configuration = ENV["CONFIGURATION"].downcase.to_sym
45
+ cache[configuration] ||= {}
46
+ cache[:latest] = configuration
47
+ ["BUILT_PRODUCTS_DIR", "BUILD_DIR", "CONFIGURATION", "CONFIGURATION_BUILD_DIR",
48
+ "PROJECT_DIR", "INFOPLIST_FILE", "TARGET_NAME"].each do |v|
49
+ cache[configuration][v.downcase.to_sym] = ENV[v]
50
+ end
51
+ end
52
+
53
+ cache.save
54
+ end
55
+
56
+ def require_xcode
57
+ raise "This task must be run in XCode Environment" unless ENV['XCODE_VERSION_ACTUAL']
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,33 @@
1
+ module Ios
2
+ module Box
3
+ module Tools
4
+ class Version < Thor
5
+ desc "show", "Displays current version information"
6
+ def show
7
+ version = IOSBox.new.version
8
+
9
+ puts " Short Version: #{version[:short]}"
10
+ puts " Bundle Version: #{version[:bundle]}"
11
+ puts " Technical: %1.3f" % version[:technical]
12
+ puts " Build Number: #{version[:build_number]}"
13
+ puts " Commit: #{version[:commit]}"
14
+ end
15
+
16
+ desc "build [BUILDNUM]", "Increments current build number or sets it to defined."
17
+ def build(buildnum = nil)
18
+ IOSBox.new.version.bump_build(buildnum)
19
+ end
20
+
21
+ desc "set VERSION", "Sets new marketing version"
22
+ def set(ver)
23
+ IOSBox.new.version.set_marketing(ver)
24
+ end
25
+
26
+ desc "bump [major|minor]", "Bumps marketings version by one"
27
+ def bump(type = :patch)
28
+ IOSBox.new.version.bump_marketing(type.downcase.to_sym)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ module Ios
2
+ module Box
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
metadata CHANGED
@@ -1,194 +1,59 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ios-box
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
4
5
  prerelease:
5
- version: 0.1.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Mikko Kokkonen
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-14 00:00:00 +09:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: plist
18
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2011-10-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: &70265489724360 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
24
22
  type: :runtime
25
23
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: pbxproject
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: plist
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
46
- type: :runtime
47
- prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *70265489724360
25
+ - !ruby/object:Gem::Dependency
50
26
  name: grit
51
- requirement: &id004 !ruby/object:Gem::Requirement
27
+ requirement: &70265489723740 !ruby/object:Gem::Requirement
52
28
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
57
33
  type: :runtime
58
34
  prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: rspec
62
- requirement: &id005 !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
65
- - - ~>
66
- - !ruby/object:Gem::Version
67
- version: 2.3.0
68
- type: :development
69
- prerelease: false
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: bundler
73
- requirement: &id006 !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
76
- - - ~>
77
- - !ruby/object:Gem::Version
78
- version: 1.0.0
79
- type: :development
80
- prerelease: false
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: jeweler
84
- requirement: &id007 !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- version: 1.5.2
90
- type: :development
91
- prerelease: false
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: rcov
95
- requirement: &id008 !ruby/object:Gem::Requirement
96
- none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: "0"
101
- type: :development
102
- prerelease: false
103
- version_requirements: *id008
104
- - !ruby/object:Gem::Dependency
105
- name: pbxproject
106
- requirement: &id009 !ruby/object:Gem::Requirement
107
- none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: 0.1.4
112
- type: :runtime
113
- prerelease: false
114
- version_requirements: *id009
115
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *70265489723740
36
+ - !ruby/object:Gem::Dependency
116
37
  name: plist
117
- requirement: &id010 !ruby/object:Gem::Requirement
118
- none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- version: "0"
123
- type: :runtime
124
- prerelease: false
125
- version_requirements: *id010
126
- - !ruby/object:Gem::Dependency
127
- name: grit
128
- requirement: &id011 !ruby/object:Gem::Requirement
38
+ requirement: &70265489723040 !ruby/object:Gem::Requirement
129
39
  none: false
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
134
44
  type: :runtime
135
45
  prerelease: false
136
- version_requirements: *id011
137
- - !ruby/object:Gem::Dependency
138
- name: rspec
139
- requirement: &id012 !ruby/object:Gem::Requirement
140
- none: false
141
- requirements:
142
- - - ">"
143
- - !ruby/object:Gem::Version
144
- version: 1.2.3
145
- type: :development
146
- prerelease: false
147
- version_requirements: *id012
148
- - !ruby/object:Gem::Dependency
149
- name: pbxproject
150
- requirement: &id013 !ruby/object:Gem::Requirement
151
- none: false
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- version: 0.1.4
156
- type: :development
157
- prerelease: false
158
- version_requirements: *id013
159
- - !ruby/object:Gem::Dependency
160
- name: grit
161
- requirement: &id014 !ruby/object:Gem::Requirement
162
- none: false
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: "0"
167
- type: :development
168
- prerelease: false
169
- version_requirements: *id014
170
- - !ruby/object:Gem::Dependency
171
- name: plist
172
- requirement: &id015 !ruby/object:Gem::Requirement
173
- none: false
174
- requirements:
175
- - - ">="
176
- - !ruby/object:Gem::Version
177
- version: "0"
178
- type: :development
179
- prerelease: false
180
- version_requirements: *id015
181
- description: ios-box offers automation and easy tasks for some most common tasks in iOS development.
182
- email: mikko.kokkonen@me.com
183
- executables: []
184
-
46
+ version_requirements: *70265489723040
47
+ description: Include atuomatic vesion conrol for you XCode projects.
48
+ email:
49
+ - mikko@owlforestry.com
50
+ executables:
51
+ - ios-box
185
52
  extensions: []
186
-
187
- extra_rdoc_files:
188
- - LICENSE.txt
189
- - README.md
190
- files:
53
+ extra_rdoc_files: []
54
+ files:
191
55
  - .document
56
+ - .gitignore
192
57
  - .rspec
193
58
  - Gemfile
194
59
  - Gemfile.lock
@@ -196,47 +61,46 @@ files:
196
61
  - README.md
197
62
  - Rakefile
198
63
  - VERSION
199
- - dump
64
+ - bin/ios-box
200
65
  - ios-box.gemspec
201
- - lib/build_cache.rb
202
66
  - lib/ios-box.rb
67
+ - lib/ios-box/cli.rb
68
+ - lib/ios-box/config.rb
69
+ - lib/ios-box/iosbox.rb
70
+ - lib/ios-box/tasks.rb
71
+ - lib/ios-box/tools.rb
72
+ - lib/ios-box/tools/build.rb
73
+ - lib/ios-box/tools/version.rb
74
+ - lib/ios-box/version.rb
203
75
  - lib/ios_box.rb
204
- - patch
205
76
  - spec/build_cache_spec.rb
206
77
  - spec/ios-box_spec.rb
207
78
  - spec/spec_helper.rb
208
- has_rdoc: true
209
- homepage: http://github.com/owl-foresty/ios-box
210
- licenses:
211
- - MIT
79
+ homepage: https://github.com/owl-forestry/ios-box
80
+ licenses: []
212
81
  post_install_message:
213
82
  rdoc_options: []
214
-
215
- require_paths:
83
+ require_paths:
216
84
  - lib
217
- required_ruby_version: !ruby/object:Gem::Requirement
85
+ required_ruby_version: !ruby/object:Gem::Requirement
218
86
  none: false
219
- requirements:
220
- - - ">="
221
- - !ruby/object:Gem::Version
222
- hash: -1478862092490478258
223
- segments:
224
- - 0
225
- version: "0"
226
- required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
227
92
  none: false
228
- requirements:
229
- - - ">="
230
- - !ruby/object:Gem::Version
231
- version: "0"
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
232
97
  requirements: []
233
-
234
98
  rubyforge_project:
235
- rubygems_version: 1.6.2
99
+ rubygems_version: 1.8.10
236
100
  signing_key:
237
101
  specification_version: 3
238
- summary: Automates some common tasks in iOS development
239
- test_files:
102
+ summary: Add handy tools to XCode specially for iOS development
103
+ test_files:
240
104
  - spec/build_cache_spec.rb
241
105
  - spec/ios-box_spec.rb
242
106
  - spec/spec_helper.rb
data/dump DELETED
File without changes
data/lib/build_cache.rb DELETED
@@ -1,44 +0,0 @@
1
- module IosBox
2
- class BuildCache
3
- def init config
4
- # Fill our config object
5
- # But only if it hasn't been initialized yet and not in XCode env
6
- if (config.project_dir.nil? && ENV['XCODE_VERSION_ACTUAL'].nil?)
7
- config.project_dir = @project_dir
8
- config.infoplist_file = @infoplist_file
9
- config.plist = File.join(@project_dir, @infoplist_file) unless @project_dir.nil?
10
- end
11
- end
12
-
13
- def self.load file = ".buildCache"
14
- return unless File.file?(file)
15
- YAML.load_file(file)
16
- end
17
-
18
- def save file = ".buildCache"
19
- File.open(file, 'w') { |io| YAML.dump(self, io) }
20
- end
21
-
22
- def method_missing(m, *args, &block)
23
- if (args.length > 0)
24
- self.class.class_eval do
25
- define_method("#{m.to_s[0, m.to_s.length - 1]}") do
26
- instance_variable_get("@#{m.to_s[0, m.to_s.length - 1]}")
27
- end
28
-
29
- define_method("#{m.to_s[0, m.to_s.length - 1]}=") do |val|
30
- instance_variable_set("@#{m.to_s[0, m.to_s.length - 1]}", val)
31
- end
32
- end
33
- return instance_variable_set("@#{m.to_s[0, m.to_s.length - 1]}", args[0])
34
- end
35
-
36
- self.class.class_eval do
37
- define_method(m) do
38
- instance_variable_get("@#{m}")
39
- end
40
- end
41
- return instance_variable_get("@#{m}")
42
- end
43
- end
44
- end
data/patch DELETED
@@ -1 +0,0 @@
1
- (in /Users/mikko/Documents/ios-box)