tug 0.0.1 → 0.0.2

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: e44056e57bfca531e39f084b7fcf3bf5318e36ba
4
- data.tar.gz: b4afebebc2fec796cef83a56da015cffb2b4f069
3
+ metadata.gz: ccbf76dce88befc9a05e706971318dd2f2112b87
4
+ data.tar.gz: b29d2ff15d5c65d7a9911cf37682be61f8e8292f
5
5
  SHA512:
6
- metadata.gz: 1faed7d99a7b8208e8632446b1b335db93a3775907893c901aafc8082a386f6e8f0fee71b91e1805db8625d6ece662f6298479b5288c2c21a3544877f42232a7
7
- data.tar.gz: b2534e8a41a3beb4ed837518dee0a738177b505d53dd541efae7e995239616ea4c477561fa677dee8ff4b0c6dacd5874ad3ff05318bd6f246f280012032529cd
6
+ metadata.gz: 4d9b5bedcc1d106d8fceb1459fc5fef1a89a83132ad2866aadb6a7e98b9a4747ada8b7d9c91ad033e3d64374f11ec4cb12fc1842724f8dc7f913db206b467339
7
+ data.tar.gz: 12d1971bc4a41a5a160cb80472a9b61ec3b305217476f031fcd8caa11c9521c09f5f1eff64000e00bb89173ab627f731f806642ebcde8023b54d4de882d2a53f
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: rspec spec
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in tug.gemspec
4
- gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard :rspec, :cmd => 'bundle exec rspec --color' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 alexfish
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Tug
2
2
 
3
- TODO: Write a gem description
3
+ ![icon](icon.png)
4
+
5
+ Build and deploy iOS applications
6
+
7
+ [![Build Status](https://travis-ci.org/alexfish/tug.svg?branch=feature%2Fbuild)](https://travis-ci.org/alexfish/tug)
8
+ [![Code Climate](https://codeclimate.com/github/alexfish/tug.png)](https://codeclimate.com/github/alexfish/tug)
4
9
 
5
10
  ## Installation
6
11
 
@@ -18,7 +23,22 @@ Or install it yourself as:
18
23
 
19
24
  ## Usage
20
25
 
21
- TODO: Write usage instructions here
26
+ ### Build
27
+
28
+ Run `tug build` from your Xcode projects root directory.
29
+
30
+ ### Config
31
+
32
+ tug will look in the currenty directory for a `.tug.yml` config file by default, use the `--config` option to pass a path to your config file if it's in a different folder.
33
+
34
+ A sample config file:
35
+
36
+ ```
37
+ project:
38
+ workspace: tug.xcworkspace
39
+ schemes:
40
+ - tug
41
+ ```
22
42
 
23
43
  ## Contributing
24
44
 
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require "bundler/gem_tasks"
data/bin/tug ADDED
@@ -0,0 +1,5 @@
1
+ require "tug"
2
+
3
+ parser = Parser.parser_for_args(*ARGV)
4
+ command = Command.command_for_string(parser.command)
5
+ command.execute(parser.options)
data/icon.png ADDED
Binary file
@@ -0,0 +1,13 @@
1
+ class BuildCommand < Command
2
+
3
+ def execute(options)
4
+ config_file = ConfigFile.config_file(options[:config])
5
+ build(config_file.project)
6
+ end
7
+
8
+ def build(project)
9
+ project.schemes.each do |scheme|
10
+ system("xctool -workspace #{project.workspace} -scheme #{scheme} -sdk iphonesimulator")
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ class Command
2
+
3
+ class << self
4
+ def command_for_string(command_string)
5
+ case command_string
6
+ when "build"
7
+ BuildCommand.new
8
+ else
9
+ Command.new
10
+ end
11
+ end
12
+ end
13
+
14
+ def execute(options)
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ project:
2
+ workspace: tug.xcworkspace
3
+ schemes:
4
+ - tug
@@ -0,0 +1,28 @@
1
+ class ConfigFile
2
+
3
+ attr_reader :project
4
+
5
+ class << self
6
+ def config_file(path=nil)
7
+ if path and File.file?(path)
8
+ ExternalConfigFile.new(path)
9
+ elsif File.file?(File.join(Dir.pwd, '.tug.yml'))
10
+ ConfigFile.new
11
+ else
12
+ MissingConfigFile.new
13
+ end
14
+ end
15
+ end
16
+
17
+ def initialize(path=nil)
18
+ config = YAML::load_file(File.join(Dir.pwd, '.tug.yml'))
19
+ @project = project_from_config(config)
20
+ end
21
+
22
+ private
23
+
24
+ def project_from_config(config)
25
+ project_yaml = config['project']
26
+ Project.new(project_yaml['workspace'], project_yaml['schemes'])
27
+ end
28
+ end
@@ -0,0 +1,6 @@
1
+ class ExternalConfigFile < ConfigFile
2
+
3
+ def initialize(path=nil)
4
+ @config = YAML::load_file(path)
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ class MissingConfigFile < ConfigFile
2
+
3
+ def initialize(path=nil)
4
+ puts "Config file missing 😱\n" +
5
+ "Try specifying a path to your config with the -c option"
6
+ abort
7
+ end
8
+
9
+ private
10
+
11
+ def abort
12
+ exit 1
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ class EmptyParser < Parser
2
+
3
+ def initialize(*options)
4
+ super([])
5
+ end
6
+
7
+ private
8
+
9
+ def parsed_options(*options)
10
+ puts banner
11
+ end
12
+ end
@@ -0,0 +1,47 @@
1
+ class Parser
2
+
3
+ attr_reader :options
4
+ attr_reader :command
5
+
6
+ class << self
7
+ def parser_for_args(*options)
8
+ if options.size > 0
9
+ Parser.new(*options)
10
+ else
11
+ EmptyParser.new
12
+ end
13
+ end
14
+ end
15
+
16
+ def initialize(*options)
17
+ @command = options.shift
18
+ @options = parsed_options(*options)
19
+ end
20
+
21
+ private
22
+
23
+ def banner
24
+ "\n" +
25
+ "Commands:\n" +
26
+ " build - Build an xcode project\n\n" +
27
+ "Options:\n" +
28
+ " --config - Path to a .tug.yml config file"
29
+ end
30
+
31
+ def parsed_options(*options)
32
+ parsed_options = {}
33
+
34
+ o = OptionParser.new do |opts|
35
+ opts.on("-c", "--config CONFIG", "Configuration file path") do |config|
36
+ parsed_options[:config] = config
37
+ end
38
+ end
39
+
40
+ begin o.parse! options
41
+ rescue OptionParser::InvalidOption => e
42
+ puts banner
43
+ end
44
+
45
+ parsed_options
46
+ end
47
+ end
@@ -0,0 +1,10 @@
1
+ class Project
2
+
3
+ attr_reader :schemes
4
+ attr_reader :workspace
5
+
6
+ def initialize(workspace, schemes)
7
+ @schemes = schemes
8
+ @workspace = workspace
9
+ end
10
+ end
data/lib/tug/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tug
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/tug.rb CHANGED
@@ -1,5 +1,16 @@
1
+ require "optparse"
2
+ require 'yaml'
3
+
1
4
  require "tug/version"
2
5
 
3
- module Tug
4
- # Your code goes here...
5
- end
6
+ require "tug/command/command"
7
+ require "tug/command/build_command"
8
+
9
+ require "tug/parser/parser"
10
+ require "tug/parser/empty_parser"
11
+
12
+ require "tug/config/config_file"
13
+ require "tug/config/missing_config_file"
14
+ require "tug/config/external_config_file"
15
+
16
+ require "tug/project/project"
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe BuildCommand do
4
+
5
+ describe "when executing" do
6
+
7
+ before(:each) do
8
+ @buld_command = BuildCommand.new
9
+ @project = Project.new('workspace', ['scheme'])
10
+ end
11
+
12
+ it "should run xctool" do
13
+ expect(@buld_command).to receive(:system).with(/xctool/)
14
+ @buld_command.build(@project)
15
+ end
16
+
17
+ it "should set the workspace" do
18
+ expect(@buld_command).to receive(:system).with(/-workspace workspace/)
19
+ @buld_command.build(@project)
20
+ end
21
+
22
+ it "should set the scheme" do
23
+ expect(@buld_command).to receive(:system).with(/-scheme scheme/)
24
+ @buld_command.build(@project)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ require "spec_helper"
2
+
3
+ describe Command do
4
+
5
+ before :each do
6
+ @command = Command.new
7
+ end
8
+
9
+ describe "when returning a command" do
10
+ it "should return a build command" do
11
+ command = Command.command_for_string("build")
12
+ expect(command).to be_kind_of(BuildCommand)
13
+ end
14
+
15
+ it "should return a default command" do
16
+ command = Command.command_for_string("hello")
17
+ expect(command).to be_kind_of(Command)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,37 @@
1
+ require "spec_helper"
2
+
3
+ describe ConfigFile do
4
+
5
+ before(:each) do
6
+ config = {'project' => {'workspace' => 'hello', 'schemes' => ["world"]}}
7
+ allow(YAML).to receive(:load_file).and_return(config)
8
+ @config_file = ConfigFile.new
9
+ end
10
+
11
+ describe "when returning a config file" do
12
+ it "should return a config file for no path" do
13
+ expect(File).to receive(:file?).and_return(true)
14
+ config_file = ConfigFile.config_file
15
+ expect(config_file).to be_kind_of(ConfigFile)
16
+ end
17
+
18
+ it "should return a missing config file for no file found" do
19
+ allow_any_instance_of(MissingConfigFile).to receive(:abort)
20
+ expect(File).to receive(:file?).and_return(false)
21
+ config_file = ConfigFile.config_file
22
+ expect(config_file).to be_kind_of(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
+ config_file = ConfigFile.config_file("path")
28
+ expect(config_file).to be_kind_of(ExternalConfigFile)
29
+ end
30
+ end
31
+
32
+ describe "when loading config" do
33
+ it "should load a project" do
34
+ expect(@config_file.project).to be
35
+ end
36
+ end
37
+ end
data/spec/output.txt ADDED
File without changes
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ describe Parser do
4
+ describe "when returning parsers" do
5
+ it "should return an option parser for options" do
6
+ parser = Parser.parser_for_args(["options"])
7
+ expect(parser).to be_a_kind_of(Parser)
8
+ end
9
+
10
+ it "should return an empty option parser for no options" do
11
+ parser = Parser.parser_for_args
12
+ expect(parser).to be_a_kind_of(EmptyParser)
13
+ end
14
+ end
15
+
16
+ describe "when parsing options" do
17
+ it "should parse the command" do
18
+ parser = Parser.parser_for_args("build")
19
+ expect(parser.command).to match("build")
20
+ end
21
+
22
+ it "should parse the config file option" do
23
+ parser = Parser.new("build", "-c", "path")
24
+ expect(parser.options[:config]).to match("path")
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Project do
4
+
5
+ describe "when created" do
6
+
7
+ before(:each) do
8
+ @project = Project.new("workspace", ["scheme"])
9
+ end
10
+
11
+ it "should have a workspace" do
12
+ expect(@project.workspace).to match("workspace")
13
+ end
14
+
15
+ it "should have a scheme" do
16
+ expect(@project.schemes).to include("scheme")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ require "tug"
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:suite) do
5
+ $stderr = File.new(File.join(File.dirname(__FILE__), 'output.txt'), 'w')
6
+ $stdout = File.new(File.join(File.dirname(__FILE__), 'output.txt'), 'w')
7
+ end
8
+ end
data/tug.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["alex@alexefish.com"]
11
11
  spec.description = "Build and deploy iOS project"
12
12
  spec.summary = "iOS project builder and depoloyer"
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/alexfish/tug"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -20,4 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "guard-rspec"
23
25
  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.1
4
+ version: 0.0.2
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-10 00:00:00.000000000 Z
11
+ date: 2014-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,22 +38,72 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  description: Build and deploy iOS project
42
70
  email:
43
71
  - alex@alexefish.com
44
- executables: []
72
+ executables:
73
+ - tug
45
74
  extensions: []
46
75
  extra_rdoc_files: []
47
76
  files:
48
77
  - .gitignore
78
+ - .travis.yml
49
79
  - Gemfile
80
+ - Guardfile
81
+ - LICENSE
50
82
  - LICENSE.txt
51
83
  - README.md
52
84
  - Rakefile
85
+ - bin/tug
86
+ - icon.png
53
87
  - lib/tug.rb
88
+ - lib/tug/command/build_command.rb
89
+ - lib/tug/command/command.rb
90
+ - lib/tug/config/.tug.yml
91
+ - lib/tug/config/config_file.rb
92
+ - lib/tug/config/external_config_file.rb
93
+ - lib/tug/config/missing_config_file.rb
94
+ - lib/tug/parser/empty_parser.rb
95
+ - lib/tug/parser/parser.rb
96
+ - lib/tug/project/project.rb
54
97
  - lib/tug/version.rb
98
+ - spec/build_command_spec.rb
99
+ - spec/command_spec.rb
100
+ - spec/config_file_spec.rb
101
+ - spec/output.txt
102
+ - spec/parser_spec.rb
103
+ - spec/project_spec.rb
104
+ - spec/spec_helper.rb
55
105
  - tug.gemspec
56
- homepage: ''
106
+ homepage: https://github.com/alexfish/tug
57
107
  licenses:
58
108
  - MIT
59
109
  metadata: {}
@@ -77,4 +127,11 @@ rubygems_version: 2.0.3
77
127
  signing_key:
78
128
  specification_version: 4
79
129
  summary: iOS project builder and depoloyer
80
- test_files: []
130
+ test_files:
131
+ - spec/build_command_spec.rb
132
+ - spec/command_spec.rb
133
+ - spec/config_file_spec.rb
134
+ - spec/output.txt
135
+ - spec/parser_spec.rb
136
+ - spec/project_spec.rb
137
+ - spec/spec_helper.rb