tug 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9710a9c58ba0148c3f554af14898d4de0b966091
4
- data.tar.gz: 35c8f0df420da37a7e73253e8c4df76aa38e82ff
3
+ metadata.gz: 08744a632238e996beb4a29db85fa89e7ee20faf
4
+ data.tar.gz: bc0865da0127107943b503ae3fc0a47fd9dbc649
5
5
  SHA512:
6
- metadata.gz: baa1543c98c85d75f0f7cab80bcf1ab80afc9929e196e30213396f6f3467bb48c6a4ec17c2cac48c988546ff67ec04bbbaccd0a8f30e058637efd18baff8a527
7
- data.tar.gz: b585022d3be40b825802081c9127ca4feffc9c4e198c357f4d0fa0ecfb48048f0157f1f8769c60c165cd0d0affc7007acc8aa332f2e33d6b5cb8e40af9456ce4
6
+ metadata.gz: 5487f7da527020af59fbde33153f96fe9db0b0f7fe91c764ccb6ed590e3306c9c771916f60abcf460a7ad70d61bd86d46804b524535e6306f7d1fbb780d05b4d
7
+ data.tar.gz: 55f6d92f1d195674df38b819a81220bf9881303b248572c4310467e277c43cee02888cd141c33c358f24549fc484275f8f34f028dbd326f124c88d30d08bf1f7
data/README.md CHANGED
@@ -25,7 +25,11 @@ Or install it yourself as:
25
25
 
26
26
  ### Build
27
27
 
28
- Run `tug build` from your Xcode projects root directory.
28
+ Run `tug build` from your Xcode projects root directory. Each scheme in the scheme config array will be built.
29
+
30
+ ### IPA
31
+
32
+ Run `tug ipa` from your Xcode projects root directory, see the example config below for details on how to set a configuration and profile name. An ipa will be generated for each scheme in the config's scheme array.
29
33
 
30
34
  ### Config
31
35
 
@@ -35,9 +39,10 @@ A sample config file:
35
39
 
36
40
  ```
37
41
  project:
38
- workspace: tug.xcworkspace
39
- schemes:
42
+ workspace: tug.xcworkspace # Path to the project workspace
43
+ schemes: # An array of schemes to build
40
44
  - tug
45
+ ipa_config: Release # The configuration to use to build ipas
41
46
  ```
42
47
 
43
48
  ## Contributing
@@ -1,10 +1,10 @@
1
1
  module Tug
2
2
  class BuildCommand < Command
3
3
 
4
- def execute(project)
5
- project.schemes.each do |scheme|
6
- system("xctool -workspace #{project.workspace} -scheme #{scheme} -sdk iphonesimulator")
7
- end
4
+ private
5
+
6
+ def xctool(config)
7
+ xctool = Tug::XCTool.tool_for_config("Debug")
8
8
  end
9
9
  end
10
10
  end
@@ -6,6 +6,8 @@ module Tug
6
6
  case command_string
7
7
  when "build"
8
8
  Tug::BuildCommand.new
9
+ when "ipa"
10
+ Tug::IpaCommand.new
9
11
  else
10
12
  Tug::Command.new
11
13
  end
@@ -13,6 +15,16 @@ module Tug
13
15
  end
14
16
 
15
17
  def execute(project)
18
+ @xctool = xctool(project.ipa_config)
19
+ project.schemes.each do |scheme|
20
+ @xctool.build(project.workspace, scheme)
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def xctool(config)
27
+ xctool = Tug::XCTool.tool_for_config(config)
16
28
  end
17
29
  end
18
30
  end
@@ -0,0 +1,25 @@
1
+ module Tug
2
+ class IpaCommand < Command
3
+
4
+ def execute(project)
5
+ super
6
+ export_ipa(project)
7
+ move_ipa(project)
8
+ end
9
+
10
+ private
11
+
12
+ def export_ipa(project)
13
+ xcodebuild = Tug::XcodeBuild.new
14
+ project.schemes.each do |scheme|
15
+ xcodebuild.export_ipa(scheme)
16
+ end
17
+ end
18
+
19
+ def move_ipa(project)
20
+ project.schemes.each do |scheme|
21
+ FileUtils.mv "/tmp/#{scheme}.ipa", "#{project.ipa_export_path}/#{scheme}.ipa"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,4 +1,5 @@
1
1
  project:
2
2
  workspace: tug.xcworkspace
3
3
  schemes:
4
- - tug
4
+ - tug
5
+ ipa_config: InHouse
@@ -4,27 +4,24 @@ module Tug
4
4
  attr_reader :project
5
5
 
6
6
  class << self
7
- def config_file(path=nil)
7
+ def config_file(path=default_path)
8
8
  if path and File.file?(path)
9
- Tug::ExternalConfigFile.new(path)
10
- elsif File.file?(File.join(Dir.pwd, '.tug.yml'))
11
- Tug::ConfigFile.new
9
+ Tug::ConfigFile.new(path)
12
10
  else
13
11
  Tug::MissingConfigFile.new
14
12
  end
15
13
  end
16
14
  end
17
15
 
18
- def initialize(path=nil)
19
- config = YAML::load_file(File.join(Dir.pwd, '.tug.yml'))
20
- @project = project_from_config(config)
16
+ def initialize(path)
17
+ config = YAML::load_file(path)
18
+ @project = Tug::Project.new(config['project'])
21
19
  end
22
20
 
23
21
  private
24
22
 
25
- def project_from_config(config)
26
- project_yaml = config['project']
27
- Tug::Project.new(project_yaml['workspace'], project_yaml['schemes'])
23
+ def default_path
24
+ File.join(Dir.pwd, '.tug.yml')
28
25
  end
29
26
  end
30
27
  end
@@ -2,12 +2,22 @@ module Tug
2
2
  class Interface < Thor
3
3
 
4
4
  desc "build", "build a project"
5
- option :config
5
+ option :config, :default => "#{Dir.pwd}/.tug.yml"
6
6
  def build
7
7
  config_file = Tug::ConfigFile.config_file(options[:config])
8
8
  execute(__method__.to_s, config_file.project)
9
9
  end
10
10
 
11
+ desc "ipa", "generate an ipa"
12
+ option :config, :default => "#{Dir.pwd}/.tug.yml"
13
+ option :export, :default => "#{Dir.pwd}"
14
+ def ipa
15
+ config_file = Tug::ConfigFile.config_file(options[:config])
16
+ project = config_file.project
17
+ project.ipa_export_path = options[:export]
18
+ execute(__method__.to_s, project)
19
+ end
20
+
11
21
  no_commands do
12
22
  def execute(command, project)
13
23
  command = Tug::Command.command_for_string(command)
@@ -1,12 +1,16 @@
1
1
  module Tug
2
2
  class Project
3
3
 
4
- attr_reader :schemes
5
- attr_reader :workspace
4
+ attr_reader :schemes
5
+ attr_reader :workspace
6
+ attr_reader :ipa_config
7
+ attr_accessor :ipa_export_path
6
8
 
7
- def initialize(workspace, schemes)
8
- @schemes = schemes
9
- @workspace = workspace
9
+ def initialize(project_yaml)
10
+ @schemes = project_yaml['schemes']
11
+ @workspace = project_yaml['workspace']
12
+ @ipa_config = project_yaml['ipa_config']
13
+ @ipa_export_path = Dir.pwd
10
14
  end
11
15
  end
12
16
  end
@@ -0,0 +1,22 @@
1
+ module Tug
2
+ class XcodeBuild
3
+
4
+ def export_ipa(name)
5
+ system("xcodebuild #{archive_options(name)} #{export_options(name)} #{profile_options}")
6
+ end
7
+
8
+ private
9
+
10
+ def profile_options
11
+ "-exportWithOriginalSigningIdentity"
12
+ end
13
+
14
+ def export_options(name)
15
+ "-exportPath /tmp/#{name}.ipa -exportFormat ipa -exportArchive"
16
+ end
17
+
18
+ def archive_options(name)
19
+ "-archivePath /tmp/#{name}.xcarchive"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,31 @@
1
+ module Tug
2
+ class XCTool
3
+
4
+ attr_reader :config
5
+
6
+ class << self
7
+ def tool_for_config(config)
8
+ case config.downcase
9
+ when "inhouse", "release"
10
+ Tug::XCToolArchive.new(config)
11
+ else
12
+ Tug::XCToolBuild.new(config)
13
+ end
14
+ end
15
+ end
16
+
17
+ def initialize(config)
18
+ @config = config
19
+ end
20
+
21
+ def build(workspace, scheme)
22
+ system("xctool #{build_options(workspace, scheme)}")
23
+ end
24
+
25
+ private
26
+
27
+ def build_options(workspace, scheme)
28
+ "-workspace #{workspace} -scheme #{scheme} -configuration #{config}"
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,10 @@
1
+ module Tug
2
+ class XCToolArchive < XCTool
3
+
4
+ private
5
+
6
+ def build_options(workspace, scheme)
7
+ super + " archive -archivePath /tmp/#{scheme}.xcarchive"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Tug
2
+ class XCToolBuild < XCTool
3
+
4
+ private
5
+
6
+ def build_options(workspace, scheme)
7
+ super + " -sdk iphonesimulator"
8
+ end
9
+ end
10
+ end
data/lib/tug/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tug
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/tug.rb CHANGED
@@ -6,11 +6,16 @@ require "tug/version"
6
6
 
7
7
  require "tug/command/command"
8
8
  require "tug/command/build_command"
9
+ require "tug/command/ipa_command"
9
10
 
10
11
  require "tug/interface/interface"
11
12
 
12
13
  require "tug/config/config_file"
13
14
  require "tug/config/missing_config_file"
14
- require "tug/config/external_config_file"
15
15
 
16
- require "tug/project/project"
16
+ require "tug/project/project"
17
+
18
+ require "tug/tool/xcode_build"
19
+ require "tug/tool/xctool"
20
+ require "tug/tool/xctool_build"
21
+ require "tug/tool/xctool_archive"
@@ -5,23 +5,14 @@ describe Tug::BuildCommand do
5
5
  describe "when executing" do
6
6
 
7
7
  before(:each) do
8
- @build_command = Tug::BuildCommand.new
9
- @project = Tug::Project.new('workspace', ['scheme'])
8
+ @command = Tug::BuildCommand.new
9
+ allow(@command).to receive(:system)
10
+ @project = Tug::Project.new(project_yaml)
10
11
  end
11
12
 
12
- it "should run xctool" do
13
- expect(@build_command).to receive(:system).with(/xctool/)
14
- @build_command.execute(@project)
15
- end
16
-
17
- it "should set the workspace" do
18
- expect(@build_command).to receive(:system).with(/-workspace workspace/)
19
- @build_command.execute(@project)
20
- end
21
-
22
- it "should set the scheme" do
23
- expect(@build_command).to receive(:system).with(/-scheme scheme/)
24
- @build_command.execute(@project)
13
+ it "should build using xctool" do
14
+ expect_any_instance_of(Tug::XCTool).to receive(:system).with("xctool -workspace workspace -scheme scheme -configuration Debug -sdk iphonesimulator")
15
+ @command.execute(@project)
25
16
  end
26
17
  end
27
18
  end
data/spec/command_spec.rb CHANGED
@@ -12,6 +12,11 @@ describe Tug::Command do
12
12
  expect(command).to be_kind_of(Tug::BuildCommand)
13
13
  end
14
14
 
15
+ it "should return an ipa command" do
16
+ command = Tug::Command.command_for_string("ipa")
17
+ expect(command).to be_kind_of(Tug::IpaCommand)
18
+ end
19
+
15
20
  it "should return a default command" do
16
21
  command = Tug::Command.command_for_string("hello")
17
22
  expect(command).to be_kind_of(Tug::Command)
@@ -3,29 +3,23 @@ require "spec_helper"
3
3
  describe Tug::ConfigFile do
4
4
 
5
5
  before(:each) do
6
- config = {'project' => {'workspace' => 'hello', 'schemes' => ["world"]}}
6
+ config = {'project' => {'workspace' => 'hello', 'schemes' => ["world"], 'ipa_config' => 'config'}}
7
7
  allow(YAML).to receive(:load_file).and_return(config)
8
- @config_file = Tug::ConfigFile.new
8
+ @config_file = Tug::ConfigFile.new("path")
9
9
  end
10
10
 
11
11
  describe "when returning a config file" do
12
- it "should return a config file for no path" do
12
+ it "should return a config file for a path" do
13
13
  expect(File).to receive(:file?).and_return(true)
14
- config_file = Tug::ConfigFile.config_file
14
+ config_file = Tug::ConfigFile.config_file("path")
15
15
  expect(config_file).to be_kind_of(Tug::ConfigFile)
16
16
  end
17
17
 
18
18
  it "should return a missing config file for no file found" do
19
19
  allow_any_instance_of(Tug::MissingConfigFile).to receive(:abort)
20
20
  expect(File).to receive(:file?).and_return(false)
21
- config_file = Tug::ConfigFile.config_file
22
- expect(config_file).to be_kind_of(Tug::MissingConfigFile)
23
- end
24
-
25
- it "should return an external config file for a path" do
26
- allow(File).to receive(:file?).and_return(true)
27
21
  config_file = Tug::ConfigFile.config_file("path")
28
- expect(config_file).to be_kind_of(Tug::ExternalConfigFile)
22
+ expect(config_file).to be_kind_of(Tug::MissingConfigFile)
29
23
  end
30
24
  end
31
25
 
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Tug::IpaCommand do
4
+
5
+ describe "when executing" do
6
+ before(:each) do
7
+ @command = Tug::IpaCommand.new
8
+ allow_any_instance_of(Tug::XcodeBuild).to receive(:system)
9
+ allow_any_instance_of(Tug::XCTool).to receive(:system)
10
+ allow(FileUtils).to receive(:mv)
11
+
12
+ yaml = project_yaml
13
+ yaml["ipa_config"] = "InHouse"
14
+ @project = Tug::Project.new(yaml)
15
+ end
16
+
17
+ it "should generate an archive using xctool" do
18
+ expect_any_instance_of(Tug::XCTool).to receive(:system).with("xctool -workspace workspace -scheme scheme -configuration InHouse archive -archivePath /tmp/scheme.xcarchive")
19
+ @command.execute(@project)
20
+ end
21
+
22
+ it "should export an ipa using xcode build" do
23
+ expect_any_instance_of(Tug::XcodeBuild).to receive(:system).with("xcodebuild -archivePath /tmp/scheme.xcarchive -exportPath /tmp/scheme.ipa -exportFormat ipa -exportArchive -exportWithOriginalSigningIdentity")
24
+ @command.execute(@project)
25
+ end
26
+
27
+ it "should move the ipa file into the export path location" do
28
+ @project.ipa_export_path = "/hello/world"
29
+ expect(FileUtils).to receive(:mv).with(anything, /hello\/world/)
30
+ @command.execute(@project)
31
+ end
32
+ end
33
+ end
data/spec/output.txt CHANGED
@@ -1,2 +0,0 @@
1
- Config file missing:
2
- Try specifying a path to your config file with the --config option
data/spec/project_spec.rb CHANGED
@@ -5,7 +5,7 @@ describe Tug::Project do
5
5
  describe "when created" do
6
6
 
7
7
  before(:each) do
8
- @project = Tug::Project.new("workspace", ["scheme"])
8
+ @project = Tug::Project.new(project_yaml)
9
9
  end
10
10
 
11
11
  it "should have a workspace" do
@@ -15,5 +15,13 @@ describe Tug::Project do
15
15
  it "should have a scheme" do
16
16
  expect(@project.schemes).to include("scheme")
17
17
  end
18
+
19
+ it "should have an ipa config" do
20
+ expect(@project.ipa_config).to match("config")
21
+ end
22
+
23
+ it "should have an ipa export path" do
24
+ expect(@project.ipa_export_path).to be
25
+ end
18
26
  end
19
27
  end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,18 @@
1
1
  require "tug"
2
2
 
3
+ module Helpers
4
+ def project_yaml
5
+ {"workspace" => "workspace",
6
+ "schemes" => ["scheme"],
7
+ "ipa_config" => "config",
8
+ "ipa_profile" => "profile"}
9
+ end
10
+ end
11
+
3
12
  RSpec.configure do |config|
4
13
  config.before(:suite) do
5
14
  $stderr = File.new(File.join(File.dirname(__FILE__), 'output.txt'), 'w')
6
15
  $stdout = File.new(File.join(File.dirname(__FILE__), 'output.txt'), 'w')
7
16
  end
17
+ config.include Helpers
8
18
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Tug::XCTool do
4
+ describe "when returning an xctool" do
5
+ it "should return a build tool" do
6
+ xctool = Tug::XCTool.tool_for_config("Debug")
7
+ expect(xctool).to be_kind_of(Tug::XCToolBuild)
8
+ end
9
+
10
+ it "should return an archive tool" do
11
+ xctool = Tug::XCTool.tool_for_config("InHouse")
12
+ expect(xctool).to be_kind_of(Tug::XCToolArchive)
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Fish
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-13 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -101,19 +101,25 @@ files:
101
101
  - lib/tug.rb
102
102
  - lib/tug/command/build_command.rb
103
103
  - lib/tug/command/command.rb
104
+ - lib/tug/command/ipa_command.rb
104
105
  - lib/tug/config/.tug.yml
105
106
  - lib/tug/config/config_file.rb
106
- - lib/tug/config/external_config_file.rb
107
107
  - lib/tug/config/missing_config_file.rb
108
108
  - lib/tug/interface/interface.rb
109
109
  - lib/tug/project/project.rb
110
+ - lib/tug/tool/xcode_build.rb
111
+ - lib/tug/tool/xctool.rb
112
+ - lib/tug/tool/xctool_archive.rb
113
+ - lib/tug/tool/xctool_build.rb
110
114
  - lib/tug/version.rb
111
115
  - spec/build_command_spec.rb
112
116
  - spec/command_spec.rb
113
117
  - spec/config_file_spec.rb
118
+ - spec/ipa_command_spec.rb
114
119
  - spec/output.txt
115
120
  - spec/project_spec.rb
116
121
  - spec/spec_helper.rb
122
+ - spec/xctool_spec.rb
117
123
  - tug.gemspec
118
124
  homepage: https://github.com/alexfish/tug
119
125
  licenses:
@@ -135,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
141
  version: '0'
136
142
  requirements: []
137
143
  rubyforge_project:
138
- rubygems_version: 2.0.3
144
+ rubygems_version: 2.0.14
139
145
  signing_key:
140
146
  specification_version: 4
141
147
  summary: iOS project builder and depoloyer
@@ -143,6 +149,8 @@ test_files:
143
149
  - spec/build_command_spec.rb
144
150
  - spec/command_spec.rb
145
151
  - spec/config_file_spec.rb
152
+ - spec/ipa_command_spec.rb
146
153
  - spec/output.txt
147
154
  - spec/project_spec.rb
148
155
  - spec/spec_helper.rb
156
+ - spec/xctool_spec.rb
@@ -1,8 +0,0 @@
1
- module Tug
2
- class ExternalConfigFile < ConfigFile
3
-
4
- def initialize(path=nil)
5
- @config = YAML::load_file(path)
6
- end
7
- end
8
- end