tug 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccbf76dce88befc9a05e706971318dd2f2112b87
4
- data.tar.gz: b29d2ff15d5c65d7a9911cf37682be61f8e8292f
3
+ metadata.gz: 9710a9c58ba0148c3f554af14898d4de0b966091
4
+ data.tar.gz: 35c8f0df420da37a7e73253e8c4df76aa38e82ff
5
5
  SHA512:
6
- metadata.gz: 4d9b5bedcc1d106d8fceb1459fc5fef1a89a83132ad2866aadb6a7e98b9a4747ada8b7d9c91ad033e3d64374f11ec4cb12fc1842724f8dc7f913db206b467339
7
- data.tar.gz: 12d1971bc4a41a5a160cb80472a9b61ec3b305217476f031fcd8caa11c9521c09f5f1eff64000e00bb89173ab627f731f806642ebcde8023b54d4de882d2a53f
6
+ metadata.gz: baa1543c98c85d75f0f7cab80bcf1ab80afc9929e196e30213396f6f3467bb48c6a4ec17c2cac48c988546ff67ec04bbbaccd0a8f30e058637efd18baff8a527
7
+ data.tar.gz: b585022d3be40b825802081c9127ca4feffc9c4e198c357f4d0fa0ecfb48048f0157f1f8769c60c165cd0d0affc7007acc8aa332f2e33d6b5cb8e40af9456ce4
data/bin/tug CHANGED
@@ -1,5 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
1
3
  require "tug"
2
4
 
3
- parser = Parser.parser_for_args(*ARGV)
4
- command = Command.command_for_string(parser.command)
5
- command.execute(parser.options)
5
+ Tug::Interface.start(ARGV)
@@ -1,13 +1,10 @@
1
- class BuildCommand < Command
1
+ module Tug
2
+ class BuildCommand < Command
2
3
 
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")
4
+ def execute(project)
5
+ project.schemes.each do |scheme|
6
+ system("xctool -workspace #{project.workspace} -scheme #{scheme} -sdk iphonesimulator")
7
+ end
11
8
  end
12
9
  end
13
10
  end
@@ -1,16 +1,18 @@
1
- class Command
1
+ module Tug
2
+ class Command
2
3
 
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
4
+ class << self
5
+ def command_for_string(command_string)
6
+ case command_string
7
+ when "build"
8
+ Tug::BuildCommand.new
9
+ else
10
+ Tug::Command.new
11
+ end
10
12
  end
11
13
  end
12
- end
13
14
 
14
- def execute(options)
15
+ def execute(project)
16
+ end
15
17
  end
16
18
  end
@@ -1,28 +1,30 @@
1
- class ConfigFile
1
+ module Tug
2
+ class ConfigFile
2
3
 
3
- attr_reader :project
4
+ attr_reader :project
4
5
 
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
6
+ class << self
7
+ def config_file(path=nil)
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
12
+ else
13
+ Tug::MissingConfigFile.new
14
+ end
13
15
  end
14
16
  end
15
- end
16
17
 
17
- def initialize(path=nil)
18
- config = YAML::load_file(File.join(Dir.pwd, '.tug.yml'))
19
- @project = project_from_config(config)
20
- end
18
+ def initialize(path=nil)
19
+ config = YAML::load_file(File.join(Dir.pwd, '.tug.yml'))
20
+ @project = project_from_config(config)
21
+ end
21
22
 
22
- private
23
+ private
23
24
 
24
- def project_from_config(config)
25
- project_yaml = config['project']
26
- Project.new(project_yaml['workspace'], project_yaml['schemes'])
25
+ def project_from_config(config)
26
+ project_yaml = config['project']
27
+ Tug::Project.new(project_yaml['workspace'], project_yaml['schemes'])
28
+ end
27
29
  end
28
30
  end
@@ -1,6 +1,8 @@
1
- class ExternalConfigFile < ConfigFile
1
+ module Tug
2
+ class ExternalConfigFile < ConfigFile
2
3
 
3
- def initialize(path=nil)
4
- @config = YAML::load_file(path)
4
+ def initialize(path=nil)
5
+ @config = YAML::load_file(path)
6
+ end
5
7
  end
6
8
  end
@@ -1,14 +1,16 @@
1
- class MissingConfigFile < ConfigFile
1
+ module Tug
2
+ class MissingConfigFile < ConfigFile
2
3
 
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
4
+ def initialize(path=nil)
5
+ puts "Config file missing:\n" +
6
+ " Try specifying a path to your config file with the --config option"
7
+ abort
8
+ end
8
9
 
9
- private
10
+ private
10
11
 
11
- def abort
12
- exit 1
12
+ def abort
13
+ exit 1
14
+ end
13
15
  end
14
16
  end
@@ -0,0 +1,18 @@
1
+ module Tug
2
+ class Interface < Thor
3
+
4
+ desc "build", "build a project"
5
+ option :config
6
+ def build
7
+ config_file = Tug::ConfigFile.config_file(options[:config])
8
+ execute(__method__.to_s, config_file.project)
9
+ end
10
+
11
+ no_commands do
12
+ def execute(command, project)
13
+ command = Tug::Command.command_for_string(command)
14
+ command.execute(project)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,10 +1,12 @@
1
- class Project
1
+ module Tug
2
+ class Project
2
3
 
3
- attr_reader :schemes
4
- attr_reader :workspace
4
+ attr_reader :schemes
5
+ attr_reader :workspace
5
6
 
6
- def initialize(workspace, schemes)
7
- @schemes = schemes
8
- @workspace = workspace
7
+ def initialize(workspace, schemes)
8
+ @schemes = schemes
9
+ @workspace = workspace
10
+ end
9
11
  end
10
12
  end
data/lib/tug/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tug
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/tug.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  require "optparse"
2
2
  require 'yaml'
3
+ require 'thor'
3
4
 
4
5
  require "tug/version"
5
6
 
6
7
  require "tug/command/command"
7
8
  require "tug/command/build_command"
8
9
 
9
- require "tug/parser/parser"
10
- require "tug/parser/empty_parser"
10
+ require "tug/interface/interface"
11
11
 
12
12
  require "tug/config/config_file"
13
13
  require "tug/config/missing_config_file"
@@ -1,27 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BuildCommand do
3
+ describe Tug::BuildCommand do
4
4
 
5
5
  describe "when executing" do
6
6
 
7
7
  before(:each) do
8
- @buld_command = BuildCommand.new
9
- @project = Project.new('workspace', ['scheme'])
8
+ @build_command = Tug::BuildCommand.new
9
+ @project = Tug::Project.new('workspace', ['scheme'])
10
10
  end
11
11
 
12
12
  it "should run xctool" do
13
- expect(@buld_command).to receive(:system).with(/xctool/)
14
- @buld_command.build(@project)
13
+ expect(@build_command).to receive(:system).with(/xctool/)
14
+ @build_command.execute(@project)
15
15
  end
16
16
 
17
17
  it "should set the workspace" do
18
- expect(@buld_command).to receive(:system).with(/-workspace workspace/)
19
- @buld_command.build(@project)
18
+ expect(@build_command).to receive(:system).with(/-workspace workspace/)
19
+ @build_command.execute(@project)
20
20
  end
21
21
 
22
22
  it "should set the scheme" do
23
- expect(@buld_command).to receive(:system).with(/-scheme scheme/)
24
- @buld_command.build(@project)
23
+ expect(@build_command).to receive(:system).with(/-scheme scheme/)
24
+ @build_command.execute(@project)
25
25
  end
26
26
  end
27
27
  end
data/spec/command_spec.rb CHANGED
@@ -1,20 +1,20 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Command do
3
+ describe Tug::Command do
4
4
 
5
5
  before :each do
6
- @command = Command.new
6
+ @command = Tug::Command.new
7
7
  end
8
8
 
9
9
  describe "when returning a command" do
10
10
  it "should return a build command" do
11
- command = Command.command_for_string("build")
12
- expect(command).to be_kind_of(BuildCommand)
11
+ command = Tug::Command.command_for_string("build")
12
+ expect(command).to be_kind_of(Tug::BuildCommand)
13
13
  end
14
14
 
15
15
  it "should return a default command" do
16
- command = Command.command_for_string("hello")
17
- expect(command).to be_kind_of(Command)
16
+ command = Tug::Command.command_for_string("hello")
17
+ expect(command).to be_kind_of(Tug::Command)
18
18
  end
19
19
  end
20
20
  end
@@ -1,31 +1,31 @@
1
1
  require "spec_helper"
2
2
 
3
- describe ConfigFile do
3
+ describe Tug::ConfigFile do
4
4
 
5
5
  before(:each) do
6
6
  config = {'project' => {'workspace' => 'hello', 'schemes' => ["world"]}}
7
7
  allow(YAML).to receive(:load_file).and_return(config)
8
- @config_file = ConfigFile.new
8
+ @config_file = Tug::ConfigFile.new
9
9
  end
10
10
 
11
11
  describe "when returning a config file" do
12
12
  it "should return a config file for no path" do
13
13
  expect(File).to receive(:file?).and_return(true)
14
- config_file = ConfigFile.config_file
15
- expect(config_file).to be_kind_of(ConfigFile)
14
+ config_file = Tug::ConfigFile.config_file
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
- allow_any_instance_of(MissingConfigFile).to receive(:abort)
19
+ allow_any_instance_of(Tug::MissingConfigFile).to receive(:abort)
20
20
  expect(File).to receive(:file?).and_return(false)
21
- config_file = ConfigFile.config_file
22
- expect(config_file).to be_kind_of(MissingConfigFile)
21
+ config_file = Tug::ConfigFile.config_file
22
+ expect(config_file).to be_kind_of(Tug::MissingConfigFile)
23
23
  end
24
24
 
25
25
  it "should return an external config file for a path" do
26
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)
27
+ config_file = Tug::ConfigFile.config_file("path")
28
+ expect(config_file).to be_kind_of(Tug::ExternalConfigFile)
29
29
  end
30
30
  end
31
31
 
data/spec/output.txt CHANGED
@@ -0,0 +1,2 @@
1
+ Config file missing:
2
+ Try specifying a path to your config file with the --config option
data/spec/project_spec.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Project do
3
+ describe Tug::Project do
4
4
 
5
5
  describe "when created" do
6
6
 
7
7
  before(:each) do
8
- @project = Project.new("workspace", ["scheme"])
8
+ @project = Tug::Project.new("workspace", ["scheme"])
9
9
  end
10
10
 
11
11
  it "should have a workspace" do
data/tug.gemspec CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "thor"
21
22
  spec.add_development_dependency "bundler", "~> 1.3"
22
23
  spec.add_development_dependency "rake"
23
24
  spec.add_development_dependency "rspec"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-12 00:00:00.000000000 Z
11
+ date: 2014-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -91,15 +105,13 @@ files:
91
105
  - lib/tug/config/config_file.rb
92
106
  - lib/tug/config/external_config_file.rb
93
107
  - lib/tug/config/missing_config_file.rb
94
- - lib/tug/parser/empty_parser.rb
95
- - lib/tug/parser/parser.rb
108
+ - lib/tug/interface/interface.rb
96
109
  - lib/tug/project/project.rb
97
110
  - lib/tug/version.rb
98
111
  - spec/build_command_spec.rb
99
112
  - spec/command_spec.rb
100
113
  - spec/config_file_spec.rb
101
114
  - spec/output.txt
102
- - spec/parser_spec.rb
103
115
  - spec/project_spec.rb
104
116
  - spec/spec_helper.rb
105
117
  - tug.gemspec
@@ -132,6 +144,5 @@ test_files:
132
144
  - spec/command_spec.rb
133
145
  - spec/config_file_spec.rb
134
146
  - spec/output.txt
135
- - spec/parser_spec.rb
136
147
  - spec/project_spec.rb
137
148
  - spec/spec_helper.rb
@@ -1,12 +0,0 @@
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
@@ -1,47 +0,0 @@
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
data/spec/parser_spec.rb DELETED
@@ -1,27 +0,0 @@
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