teapot 1.0.3 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4b9985b5523ab61e6016f73b9d1a7de0a424317
4
- data.tar.gz: f699a936b8c6f38b761b80902c628ba054eaa8c1
3
+ metadata.gz: b4d8190d7c6fa80774a4dc2395bf8afd49605de7
4
+ data.tar.gz: 5414eda9fba4aa24848fa61e33251dd76ec06679
5
5
  SHA512:
6
- metadata.gz: 5da3b8ebc748e36b9bedc8731c6c42c5e783061bc30dc3f77f003af4001b7f8076ee5b9cebd4154325af554a4125cba6e12c308419a4688935b277bd589ca7a6
7
- data.tar.gz: 14f418012735d4e469f919779ed8c5ab4f7048ac33cf0357ae7d8f6f7603e0699b29a41021389a982e6401c8a649a05ded1539bc90954ca9459c2aba8a8211ba
6
+ metadata.gz: 0ae6edbfbab5bcf88d745e845d5b940a7214945bb38689b71cec621bdbe16f33fdfd2a74a97c1b29becd0a1fb93100e256a268675e37be10931065ab59bacc4f
7
+ data.tar.gz: 69e7f188c5c01771f968fe974ff6c19f85d71dfbd513e89be0b28b9e9606f38ca0e7af2d9ddaf065c5e764ad54606e8649ea1a9d757276c18c208f2c7e82bd60
data/bin/teapot CHANGED
@@ -20,84 +20,8 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
22
 
23
- require 'teapot/controller'
24
- require 'teapot/controller/build'
25
- require 'teapot/controller/clean'
26
- require 'teapot/controller/create'
27
- require 'teapot/controller/fetch'
28
- require 'teapot/controller/generate'
29
- require 'teapot/controller/list'
30
- require 'teapot/controller/visualize'
31
-
32
- require 'teapot/repository'
33
-
23
+ require 'teapot/command'
34
24
  require 'time'
35
- require 'trollop'
36
-
37
- def make_controller(root = nil)
38
- root ||= OPTIONS[:in] || Dir.getwd
39
- Teapot::Controller.new(root, OPTIONS)
40
- end
41
-
42
- # It would be nice to make this code a bit simpler, perhaps moving some parts of it to lib/teapot/application/{function}.rb
43
- module Application
44
- def self.clean
45
- make_controller.clean
46
- end
47
-
48
- def self.fetch
49
- make_controller.fetch
50
- end
51
-
52
- def self.build(targets = ARGV.slice!(0..-1))
53
- make_controller.build(targets)
54
- end
55
-
56
- def self.exec(target = ARGV.shift)
57
- make_controller.build([target])
58
- end
59
-
60
- def self.list(only = ARGV)
61
- if only.size > 0
62
- make_controller.list(Set.new(only))
63
- else
64
- make_controller.list
65
- end
66
- end
67
-
68
- def self.visualize(targets = ARGV)
69
- make_controller.visualize(targets)
70
- end
71
-
72
- def self.create
73
- project_name = ARGV.shift
74
- project_directory = project_name.gsub(/\s+/, '-').downcase
75
- source = ARGV.shift
76
- packages = ARGV.slice!(0..-1)
77
-
78
- root = Build::Files::Path.join(Dir.getwd, project_directory)
79
-
80
- if root.exist?
81
- abort "#{root} already exists!".color(:red)
82
- end
83
-
84
- # Make the path:
85
- root.create
86
-
87
- Teapot::Repository.new(root).init!
88
-
89
- make_controller(root).create(project_name, source, packages)
90
- end
91
-
92
- def self.generate(arguments = ARGV)
93
- generator_name = arguments.shift
94
- make_controller.generate(generator_name, arguments, OPTIONS[:force])
95
- end
96
- end
97
-
98
- def valid_actions
99
- (Application.public_methods - Module.methods).collect(&:to_s)
100
- end
101
25
 
102
26
  def track_time
103
27
  start_time = Time.now
@@ -111,9 +35,20 @@ ensure
111
35
  $stderr.puts Rainbow("Elapsed Time: %0.3fs" % elapsed_time).magenta
112
36
  end
113
37
 
114
- OPTIONS = Trollop::options do
38
+ def parse_argv
39
+ if split_index = ARGV.index('--')
40
+ ARGV.shift(split_index).tap{ARGV.shift}
41
+ else
42
+ ARGV.slice!(0..-1)
43
+ end
44
+ end
45
+
46
+ # Get the arguments up until "--"
47
+ ARGUMENTS = parse_argv
48
+
49
+ OPTIONS = Trollop::options(ARGUMENTS) do
115
50
  banner Rainbow("Teapot: a decentralised package manager and build tool.").bright.blue
116
- version "teapot v#{Teapot::VERSION}"
51
+ version "teapot #{Teapot::VERSION}"
117
52
 
118
53
  opt :configuration, "Specify a specific build configuration.", :type => :string
119
54
 
@@ -122,29 +57,20 @@ OPTIONS = Trollop::options do
122
57
  opt :only, "Only compiled direct dependencies."
123
58
  opt :continuous, "Run the build graph continually (experimental).", :type => :boolean, :short => :n
124
59
 
125
- opt :in, "Work in the given directory.", :type => :string
60
+ opt :in, "Work in the given directory.", :type => :string, :default => Dir.getwd
126
61
  opt :unlock, "Don't use package lockfile when fetching."
127
62
 
128
63
  opt :force, "Force the operation if it would otherwise be be stopped due to a warning."
129
64
 
130
65
  opt :verbose, "Verbose output and error backtraces.", :type => :boolean
131
- opt :version, "Print version and exit", :short => :none
132
66
 
67
+ opt :version, "Print version and exit", :short => :none
133
68
  opt :help, "Show this message"
134
69
  end
135
70
 
136
- action = ARGV.shift
137
-
138
- # Check that the command was invoked correctly...
139
- unless action and valid_actions.include?(action)
140
- puts "You must specify an action from: #{valid_actions.join(', ')}".color(:red)
141
-
142
- exit -1
143
- end
144
-
145
71
  track_time do
146
72
  begin
147
- Application.send(action.to_sym)
73
+ Teapot::Command.new(ARGUMENTS, OPTIONS).invoke
148
74
  rescue Teapot::IncompatibleTeapotError => error
149
75
  $stderr.puts error.message.color(:red)
150
76
  $stderr.puts "Supported minimum version #{Teapot::MINIMUM_LOADER_VERSION.dump} to #{Teapot::LOADER_VERSION.dump}."
@@ -0,0 +1,106 @@
1
+ # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require_relative 'controller'
22
+ require_relative 'controller/build'
23
+ require_relative 'controller/clean'
24
+ require_relative 'controller/create'
25
+ require_relative 'controller/fetch'
26
+ require_relative 'controller/generate'
27
+ require_relative 'controller/list'
28
+ require_relative 'controller/visualize'
29
+
30
+ require_relative 'repository'
31
+
32
+ require 'trollop'
33
+
34
+ module Teapot
35
+ # This module implements all top-level teapot commands.
36
+ class Command
37
+ def initialize(arguments, options)
38
+ @action, *@arguments = arguments
39
+ @options = options
40
+ end
41
+
42
+ def controller(root = nil)
43
+ Teapot::Controller.new(root || @options[:in], @options)
44
+ end
45
+
46
+ def invoke
47
+ if @action == "invoke"
48
+ fail "The meaning of life is 42."
49
+ end
50
+
51
+ self.send(@action)
52
+ end
53
+
54
+ def clean
55
+ controller.clean
56
+ end
57
+
58
+ def fetch
59
+ controller.fetch
60
+ end
61
+
62
+ def list
63
+ only = nil
64
+
65
+ if @arguments.any?
66
+ only = Set.new(@arguments)
67
+ end
68
+
69
+ controller.list(only)
70
+ end
71
+
72
+ def generate
73
+ generator_name, *arguments = @arguments
74
+
75
+ controller.generate(generator_name, arguments, @options[:force])
76
+ end
77
+
78
+ def build
79
+ controller.build(@arguments)
80
+ end
81
+
82
+ alias brew build
83
+
84
+ def visualize
85
+ controller.visualize(@arguments)
86
+ end
87
+
88
+ def create
89
+ project_name, source, *packages = @arguments
90
+ project_path = @options.fetch(:in) {project_name.gsub(/\s+/, '-').downcase}
91
+
92
+ root = Build::Files::Path.join(Dir.getwd, project_path)
93
+
94
+ if root.exist?
95
+ abort "#{root} already exists!".color(:red)
96
+ end
97
+
98
+ # Make the path:
99
+ root.create
100
+
101
+ Teapot::Repository.new(root).init!
102
+
103
+ controller(root).create(project_name, source, packages)
104
+ end
105
+ end
106
+ end
@@ -18,10 +18,10 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'teapot/loader'
22
- require 'teapot/package'
21
+ require_relative 'loader'
22
+ require_relative 'package'
23
+ require_relative 'metadata'
23
24
 
24
- require 'teapot/metadata'
25
25
  require 'build/rulebook'
26
26
 
27
27
  module Teapot
@@ -18,8 +18,8 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'teapot/configuration'
22
- require 'teapot/version'
21
+ require_relative 'configuration'
22
+ require_relative 'version'
23
23
 
24
24
  require 'uri'
25
25
  require 'rainbow'
@@ -18,10 +18,9 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'teapot/controller'
21
+ require_relative '../controller'
22
22
  require 'build/controller'
23
23
 
24
-
25
24
  module Teapot
26
25
  class Controller
27
26
  class BuildFailedError < StandardError
@@ -18,7 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'teapot/controller'
21
+ require_relative '../controller'
22
22
 
23
23
  module Teapot
24
24
  class Controller
@@ -18,8 +18,8 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'teapot/controller'
22
- require 'teapot/controller/fetch'
21
+ require_relative '../controller'
22
+ require_relative 'fetch'
23
23
 
24
24
  require 'build/name'
25
25
 
@@ -18,8 +18,8 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'teapot/controller'
22
- require 'teapot/repository'
21
+ require_relative '../controller'
22
+ require_relative '../repository'
23
23
 
24
24
  module Teapot
25
25
  class Controller
@@ -18,7 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'teapot/controller'
21
+ require_relative '../controller'
22
22
 
23
23
  module Teapot
24
24
  class Controller
@@ -18,7 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'teapot/controller'
21
+ require_relative '../controller'
22
22
 
23
23
  module Teapot
24
24
  class Controller
@@ -18,7 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'teapot/controller'
21
+ require_relative '../controller'
22
22
 
23
23
  require 'graphviz'
24
24
  require 'yaml'
@@ -18,9 +18,9 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'teapot/definition'
22
- require 'teapot/substitutions'
23
- require 'teapot/merge'
21
+ require_relative 'definition'
22
+ require_relative 'substitutions'
23
+ require_relative 'merge'
24
24
 
25
25
  require 'tempfile'
26
26
 
data/lib/teapot/loader.rb CHANGED
@@ -18,10 +18,10 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'teapot/project'
22
- require 'teapot/target'
23
- require 'teapot/generator'
24
- require 'teapot/configuration'
21
+ require_relative 'project'
22
+ require_relative 'target'
23
+ require_relative 'generator'
24
+ require_relative 'configuration'
25
25
 
26
26
  require 'build/rule'
27
27
  require 'build/name'
@@ -20,8 +20,8 @@
20
20
 
21
21
  require 'build/files'
22
22
 
23
- require 'teapot/context'
24
- require 'teapot/definition'
23
+ require_relative 'context'
24
+ require_relative 'definition'
25
25
 
26
26
  module Teapot
27
27
  Path = Build::Files::Path
@@ -18,7 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'teapot/definition'
21
+ require_relative 'definition'
22
22
 
23
23
  module Teapot
24
24
  class Project < Definition
data/lib/teapot/target.rb CHANGED
@@ -19,8 +19,8 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  require 'pathname'
22
- require 'teapot/dependency'
23
- require 'teapot/definition'
22
+ require_relative 'dependency'
23
+ require_relative 'definition'
24
24
 
25
25
  require 'build/environment'
26
26
  require 'build/rulebook'
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Teapot
22
- VERSION = "1.0.3"
22
+ VERSION = "1.1.0"
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teapot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-10 00:00:00.000000000 Z
11
+ date: 2016-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -143,6 +143,7 @@ files:
143
143
  - Rakefile
144
144
  - bin/teapot
145
145
  - lib/teapot.rb
146
+ - lib/teapot/command.rb
146
147
  - lib/teapot/configuration.rb
147
148
  - lib/teapot/context.rb
148
149
  - lib/teapot/controller.rb
@@ -205,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
206
  version: '0'
206
207
  requirements: []
207
208
  rubyforge_project:
208
- rubygems_version: 2.2.2
209
+ rubygems_version: 2.5.1
209
210
  signing_key:
210
211
  specification_version: 4
211
212
  summary: Teapot is a tool for managing complex cross-platform builds.