teapot 1.3.1 → 2.0.0.pre.rc1
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 +4 -4
- data/.rspec +0 -1
- data/.travis.yml +6 -0
- data/Gemfile +1 -1
- data/bin/teapot +3 -3
- data/lib/teapot/command/build.rb +123 -0
- data/lib/teapot/{metadata.rb → command/clean.rb} +19 -20
- data/lib/teapot/command/create.rb +112 -0
- data/lib/teapot/command/fetch.rb +183 -0
- data/lib/teapot/command/list.rb +97 -0
- data/lib/teapot/command/status.rb +74 -0
- data/lib/teapot/command/visualize.rb +70 -0
- data/lib/teapot/command.rb +52 -132
- data/lib/teapot/context.rb +27 -11
- data/lib/teapot/loader.rb +6 -22
- data/lib/teapot/target.rb +2 -2
- data/lib/teapot/version.rb +1 -1
- data/spec/teapot/command_spec.rb +20 -12
- data/spec/teapot/context_spec.rb +13 -16
- data/teapot.gemspec +6 -4
- metadata +35 -45
- data/PLANNING.md +0 -20
- data/lib/teapot/controller/build.rb +0 -107
- data/lib/teapot/controller/clean.rb +0 -35
- data/lib/teapot/controller/create.rb +0 -73
- data/lib/teapot/controller/fetch.rb +0 -173
- data/lib/teapot/controller/generate.rb +0 -45
- data/lib/teapot/controller/list.rb +0 -82
- data/lib/teapot/controller/visualize.rb +0 -50
- data/lib/teapot/controller.rb +0 -81
- data/lib/teapot/dependency.rb +0 -25
- data/lib/teapot/generator.rb +0 -138
- data/lib/teapot/merge.rb +0 -142
- data/lib/teapot/repository.rb +0 -135
- data/lib/teapot/substitutions.rb +0 -258
- data/spec/teapot/generator_spec/teapot.rb +0 -54
- data/spec/teapot/generator_spec/template/$NAME.txt +0 -1
- data/spec/teapot/generator_spec.rb +0 -46
- data/spec/teapot/merge_spec.rb +0 -50
- data/spec/teapot/metadata_spec.rb +0 -31
- data/spec/teapot/substitutions_spec.rb +0 -65
- data/spec/teapot/wait_spec/teapot.rb +0 -41
- data/spec/teapot/wait_spec.rb +0 -53
@@ -0,0 +1,74 @@
|
|
1
|
+
# Copyright, 2012, 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 'samovar'
|
22
|
+
require 'rugged'
|
23
|
+
|
24
|
+
module Teapot
|
25
|
+
module Command
|
26
|
+
class Status < Samovar::Command
|
27
|
+
self.description = "List the git status of the specified package(s)."
|
28
|
+
|
29
|
+
many :packages, "Limit the listing to only these packages, or all packages if none specified."
|
30
|
+
|
31
|
+
def only
|
32
|
+
if @packages.any?
|
33
|
+
Set.new(@packages)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def invoke(parent)
|
38
|
+
context = parent.context
|
39
|
+
logger = parent.logger
|
40
|
+
|
41
|
+
# Should this somehow consider context.root_package?
|
42
|
+
context.configuration.packages.each do |package|
|
43
|
+
# The root package is the local package for this context:
|
44
|
+
next unless only == nil or only.include?(package.name)
|
45
|
+
|
46
|
+
repository = Rugged::Repository.new(package.path.to_s)
|
47
|
+
|
48
|
+
changes = {}
|
49
|
+
repository.status do |file, status|
|
50
|
+
unless status == [:ignored]
|
51
|
+
changes[file] = status
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
next if changes.empty?
|
56
|
+
|
57
|
+
logger.info "Package #{package.name} (from #{package.path}):".bright
|
58
|
+
|
59
|
+
changes.each do |file, status|
|
60
|
+
if status == [:worktree_new]
|
61
|
+
logger.info "\t#{file}".color(:blue)
|
62
|
+
elsif status == [:worktree_modified]
|
63
|
+
logger.info "\t#{file}".color(:orange)
|
64
|
+
elsif status == [:worktree_deleted]
|
65
|
+
logger.info "\t#{file}".color(:red)
|
66
|
+
else
|
67
|
+
logger.info "\t#{file} #{status.inspect}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,70 @@
|
|
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 'samovar'
|
22
|
+
require 'graphviz'
|
23
|
+
|
24
|
+
module Teapot
|
25
|
+
module Command
|
26
|
+
class Visualize < Samovar::Command
|
27
|
+
self.description = "Generate a picture of the dependency graph."
|
28
|
+
|
29
|
+
options do
|
30
|
+
option '-o/--output-path <path>', "The output path for the visualization.", default: "dependency.svg"
|
31
|
+
option '-d/--dependency-name <name>', "Show the partial chain for the given named dependency."
|
32
|
+
end
|
33
|
+
|
34
|
+
many :targets, "Visualize these targets, or use them to help the dependency resolution process."
|
35
|
+
|
36
|
+
def dependency_names
|
37
|
+
@targets || []
|
38
|
+
end
|
39
|
+
|
40
|
+
def dependency_name
|
41
|
+
@options[:dependency_name]
|
42
|
+
end
|
43
|
+
|
44
|
+
def invoke(parent)
|
45
|
+
context = parent.context
|
46
|
+
|
47
|
+
configuration = context.configuration
|
48
|
+
|
49
|
+
chain = context.dependency_chain(dependency_names, context.configuration)
|
50
|
+
|
51
|
+
if dependency_name
|
52
|
+
provider = context.dependencies[dependency_name]
|
53
|
+
|
54
|
+
# TODO The visualisation generated isn't quite right. It's introspecting too much from the packages and not reflecting #ordered and #provisions.
|
55
|
+
chain = chain.partial(provider)
|
56
|
+
end
|
57
|
+
|
58
|
+
visualization = ::Build::Dependency::Visualization.new
|
59
|
+
|
60
|
+
graph = visualization.generate(chain)
|
61
|
+
|
62
|
+
if output_path = @options[:output_path]
|
63
|
+
Graphviz::output(graph, :path => output_path)
|
64
|
+
end
|
65
|
+
|
66
|
+
return graph
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/teapot/command.rb
CHANGED
@@ -18,138 +18,31 @@
|
|
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_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
|
-
# For IncompatibleTeapotError
|
33
|
-
require_relative 'loader'
|
34
|
-
|
35
21
|
require 'samovar'
|
36
22
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
many :packages, "Any additional packages you'd like to include in the project."
|
45
|
-
|
46
|
-
def invoke(parent)
|
47
|
-
project_path = parent.root || project_name.gsub(/\s+/, '-').downcase
|
48
|
-
root = ::Build::Files::Path.expand(project_path)
|
49
|
-
|
50
|
-
if root.exist?
|
51
|
-
raise ArgumentError.new("#{root} already exists!")
|
52
|
-
end
|
53
|
-
|
54
|
-
# Make the path:
|
55
|
-
root.create
|
56
|
-
|
57
|
-
Teapot::Repository.new(root).init!
|
58
|
-
|
59
|
-
parent.controller(root).create(@project_name, @source, @packages)
|
60
|
-
end
|
61
|
-
end
|
23
|
+
require_relative 'command/build'
|
24
|
+
require_relative 'command/clean'
|
25
|
+
require_relative 'command/create'
|
26
|
+
require_relative 'command/fetch'
|
27
|
+
require_relative 'command/list'
|
28
|
+
require_relative 'command/status'
|
29
|
+
require_relative 'command/visualize'
|
62
30
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
options do
|
67
|
-
option '-f/--force', "Force the generator to run even if the current work-tree is dirty."
|
68
|
-
end
|
69
|
-
|
70
|
-
one :generator_name, "The name of the generator to be invoked."
|
71
|
-
many :arguments, "The arguments that will be passed to the generator."
|
72
|
-
|
73
|
-
def invoke(parent)
|
74
|
-
generator_name, *arguments = @arguments
|
75
|
-
|
76
|
-
parent.controller.generate(@generator_name, @arguments, @options[:force])
|
77
|
-
end
|
78
|
-
end
|
31
|
+
require_relative 'context'
|
32
|
+
require_relative 'configuration'
|
33
|
+
require_relative 'version'
|
79
34
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
# - fetch current packages according to lockfile
|
85
|
-
# - write current pacakges into lockfile
|
86
|
-
# - update packages and update lockfile
|
87
|
-
|
88
|
-
options do
|
89
|
-
option '--update', "Update dependencies to the latest versions."
|
90
|
-
option '--local', "Don't update from source, assume updated local packages."
|
91
|
-
end
|
92
|
-
|
93
|
-
def invoke(parent)
|
94
|
-
parent.controller.fetch(**@options)
|
95
|
-
end
|
96
|
-
end
|
35
|
+
require 'uri'
|
36
|
+
require 'rainbow'
|
37
|
+
require 'rainbow/ext/string'
|
38
|
+
require 'fileutils'
|
97
39
|
|
98
|
-
|
99
|
-
self.description = "List provisions and dependencies of the specified package."
|
100
|
-
|
101
|
-
many :packages, "Limit the listing to only these packages, or all packages if none specified."
|
102
|
-
|
103
|
-
def invoke(parent)
|
104
|
-
if @packages.any?
|
105
|
-
only = Set.new(@packages)
|
106
|
-
end
|
107
|
-
|
108
|
-
parent.controller.list(only)
|
109
|
-
end
|
110
|
-
end
|
40
|
+
require 'build/logger'
|
111
41
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
option '-j/-l/--limit <n>', "Limit the build to <n> concurrent processes."
|
117
|
-
option '--only', "Only compile direct dependencies."
|
118
|
-
option '-c/--continuous', "Run the build graph continually (experimental)."
|
119
|
-
end
|
120
|
-
|
121
|
-
many :targets, "Build these targets, or use them to help the dependency resolution process."
|
122
|
-
split :argv, "Arguments passed to child process(es) of build if any."
|
123
|
-
|
124
|
-
def invoke(parent)
|
125
|
-
# TODO: This is a bit of a hack, figure out a way to pass it directly through to build subsystem.
|
126
|
-
ARGV.replace(@argv) if @argv
|
127
|
-
|
128
|
-
parent.controller.build(@targets)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
class Visualize < Samovar::Command
|
133
|
-
self.description = "Generate a picture of the dependency graph."
|
134
|
-
|
135
|
-
options do
|
136
|
-
option '-o/--output-path <path>', "The output path for the visualization.", default: "dependency.svg"
|
137
|
-
option '-d/--dependency-name <name>', "Show the partial chain for the given named dependency."
|
138
|
-
end
|
139
|
-
|
140
|
-
many :targets, "Visualize these targets, or use them to help the dependency resolution process."
|
141
|
-
|
142
|
-
def invoke(parent)
|
143
|
-
parent.controller.visualize(@targets, **@options)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
class Clean < Samovar::Command
|
148
|
-
self.description = "Delete everything in the teapot directory."
|
149
|
-
|
150
|
-
def invoke(parent)
|
151
|
-
parent.controller.clean
|
152
|
-
end
|
42
|
+
module Teapot
|
43
|
+
module Command
|
44
|
+
def self.parse(*args)
|
45
|
+
Top.parse(*args)
|
153
46
|
end
|
154
47
|
|
155
48
|
class Top < Samovar::Command
|
@@ -157,7 +50,7 @@ module Teapot
|
|
157
50
|
|
158
51
|
options do
|
159
52
|
option '-c/--configuration <name>', "Specify a specific build configuration.", default: ENV['TEAPOT_CONFIGURATION']
|
160
|
-
option '
|
53
|
+
option '--root <path>', "Work in the given root directory.", default: Dir.getwd
|
161
54
|
option '--verbose | --quiet', "Verbosity of output for debugging.", key: :logging
|
162
55
|
option '-h/--help', "Print out help information."
|
163
56
|
option '-v/--version', "Print out the application version."
|
@@ -165,19 +58,46 @@ module Teapot
|
|
165
58
|
|
166
59
|
nested '<command>',
|
167
60
|
'create' => Create,
|
168
|
-
'generate' => Generate,
|
169
61
|
'fetch' => Fetch,
|
170
62
|
'list' => List,
|
63
|
+
'status' => Status,
|
171
64
|
'build' => Build,
|
172
65
|
'visualize' => Visualize,
|
173
|
-
'clean' => Clean
|
66
|
+
'clean' => Clean,
|
67
|
+
default: 'build'
|
174
68
|
|
175
69
|
def root
|
176
|
-
@options[:root]
|
70
|
+
::Build::Files::Path.expand(@options[:root])
|
71
|
+
end
|
72
|
+
|
73
|
+
def verbose?
|
74
|
+
@options[:logging] == :verbose
|
75
|
+
end
|
76
|
+
|
77
|
+
def quiet?
|
78
|
+
@options[:logging] == :quiet
|
79
|
+
end
|
80
|
+
|
81
|
+
def logger
|
82
|
+
@logger ||= Logger.new($stderr).tap do |logger|
|
83
|
+
logger.formatter = ::Build::CompactFormatter.new(verbose: verbose?)
|
84
|
+
|
85
|
+
if verbose?
|
86
|
+
logger.level = Logger::DEBUG
|
87
|
+
elsif quiet?
|
88
|
+
logger.level = Logger::WARN
|
89
|
+
else
|
90
|
+
logger.level = Logger::INFO
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def configuration
|
96
|
+
@options[:configuration]
|
177
97
|
end
|
178
98
|
|
179
|
-
def
|
180
|
-
|
99
|
+
def context(root = self.root)
|
100
|
+
Context.new(root, configuration: configuration)
|
181
101
|
end
|
182
102
|
|
183
103
|
def invoke(program_name: File.basename($0))
|
data/lib/teapot/context.rb
CHANGED
@@ -20,9 +20,10 @@
|
|
20
20
|
|
21
21
|
require_relative 'loader'
|
22
22
|
require_relative 'package'
|
23
|
-
require_relative 'metadata'
|
24
23
|
|
25
24
|
require 'build/rulebook'
|
25
|
+
require 'build/text/substitutions'
|
26
|
+
require 'build/text/merge'
|
26
27
|
|
27
28
|
module Teapot
|
28
29
|
TEAPOT_FILE = 'teapot.rb'.freeze
|
@@ -47,10 +48,7 @@ module Teapot
|
|
47
48
|
@root = Path[root]
|
48
49
|
@options = options
|
49
50
|
|
50
|
-
@metadata = Metadata.new(self)
|
51
|
-
|
52
51
|
@targets = {}
|
53
|
-
@generators = {}
|
54
52
|
@configurations = {}
|
55
53
|
@projects = {}
|
56
54
|
@rules = Build::Rulebook.new
|
@@ -69,7 +67,6 @@ module Teapot
|
|
69
67
|
attr :options
|
70
68
|
|
71
69
|
attr :targets
|
72
|
-
attr :generators
|
73
70
|
attr :projects
|
74
71
|
|
75
72
|
# Context metadata
|
@@ -89,6 +86,29 @@ module Teapot
|
|
89
86
|
attr :dependencies
|
90
87
|
attr :selection
|
91
88
|
|
89
|
+
def repository
|
90
|
+
@repository ||= Rugged::Repository.new(@root.to_s)
|
91
|
+
end
|
92
|
+
|
93
|
+
def substitutions
|
94
|
+
substitutions = Build::Text::Substitutions.new
|
95
|
+
|
96
|
+
if @project
|
97
|
+
substitutions['PROJECT_NAME'] = @project.name
|
98
|
+
substitutions['LICENSE'] = @project.license
|
99
|
+
end
|
100
|
+
|
101
|
+
# The user's current name:
|
102
|
+
substitutions['AUTHOR_NAME'] = repository.config['user.name']
|
103
|
+
substitutions['AUTHOR_EMAIL'] = repository.config['user.email']
|
104
|
+
|
105
|
+
current_date = Time.new
|
106
|
+
substitutions['DATE'] = current_date.strftime("%-d/%-m/%Y")
|
107
|
+
substitutions['YEAR'] = current_date.strftime("%Y")
|
108
|
+
|
109
|
+
return substitutions
|
110
|
+
end
|
111
|
+
|
92
112
|
def select(names)
|
93
113
|
names.each do |name|
|
94
114
|
if @targets.key? name
|
@@ -104,7 +124,7 @@ module Teapot
|
|
104
124
|
|
105
125
|
select(dependency_names)
|
106
126
|
|
107
|
-
Dependency::Chain.expand(@dependencies, @targets.values, @selection)
|
127
|
+
Build::Dependency::Chain.expand(@dependencies, @targets.values, @selection)
|
108
128
|
end
|
109
129
|
|
110
130
|
def direct_targets(ordered)
|
@@ -120,10 +140,6 @@ module Teapot
|
|
120
140
|
AlreadyDefinedError.check(definition, @targets)
|
121
141
|
|
122
142
|
@targets[definition.name] = definition
|
123
|
-
when Generator
|
124
|
-
AlreadyDefinedError.check(definition, @generators)
|
125
|
-
|
126
|
-
@generators[definition.name] = definition
|
127
143
|
when Configuration
|
128
144
|
# We define configurations in two cases, if they are public, or if they are part of the root package of this context.
|
129
145
|
if definition.public? or definition.package == @root_package
|
@@ -202,7 +218,7 @@ module Teapot
|
|
202
218
|
end
|
203
219
|
|
204
220
|
if @configuration.nil?
|
205
|
-
raise ArgumentError.new("Could not load configuration: #{configuration_name}")
|
221
|
+
raise ArgumentError.new("Could not load configuration: #{configuration_name.inspect}")
|
206
222
|
end
|
207
223
|
|
208
224
|
# Materialize the configuration:
|
data/lib/teapot/loader.rb
CHANGED
@@ -20,7 +20,6 @@
|
|
20
20
|
|
21
21
|
require_relative 'project'
|
22
22
|
require_relative 'target'
|
23
|
-
require_relative 'generator'
|
24
23
|
require_relative 'configuration'
|
25
24
|
|
26
25
|
require 'build/rule'
|
@@ -30,7 +29,8 @@ require 'build/files'
|
|
30
29
|
module Teapot
|
31
30
|
# Cannot load packages newer than this.
|
32
31
|
# Version 1.3: Added support for build-dependency library which allows options for `#depends`. The primary use case is private dependencies.
|
33
|
-
|
32
|
+
# Version 2.0: Generators removed and refactored into build.
|
33
|
+
LOADER_VERSION = "2.0"
|
34
34
|
|
35
35
|
# Cannot load packages older than this.
|
36
36
|
MINIMUM_LOADER_VERSION = "1.0"
|
@@ -51,18 +51,6 @@ module Teapot
|
|
51
51
|
attr :path
|
52
52
|
end
|
53
53
|
|
54
|
-
# This is a quick hack so that we can avoid using the system gem.. it's used in build-make package.
|
55
|
-
# TODO Remove this and also the dependency on facets, or fix facets.
|
56
|
-
module System
|
57
|
-
module CPU
|
58
|
-
def self.count
|
59
|
-
require 'etc'
|
60
|
-
|
61
|
-
Etc.nprocessors rescue 4
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
54
|
class Loader
|
67
55
|
Files = Build::Files
|
68
56
|
Rule = Build::Rule
|
@@ -114,14 +102,6 @@ module Teapot
|
|
114
102
|
@defined << target
|
115
103
|
end
|
116
104
|
|
117
|
-
def define_generator(*args)
|
118
|
-
generator = Generator.new(@context, @package, *args)
|
119
|
-
|
120
|
-
yield generator
|
121
|
-
|
122
|
-
@defined << generator
|
123
|
-
end
|
124
|
-
|
125
105
|
def define_configuration(*args)
|
126
106
|
configuration = Configuration.new(@context, @package, *args)
|
127
107
|
|
@@ -131,6 +111,10 @@ module Teapot
|
|
131
111
|
|
132
112
|
@defined << configuration
|
133
113
|
end
|
114
|
+
|
115
|
+
def define_generator(*args)
|
116
|
+
warn "define_generator(#{args.inspect}) is deprecated and will have no effect. Please use define_target."
|
117
|
+
end
|
134
118
|
|
135
119
|
# Checks the host patterns and executes the block if they match.
|
136
120
|
def host(*args, &block)
|
data/lib/teapot/target.rb
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
21
|
require 'pathname'
|
22
|
-
|
22
|
+
require 'build/dependency'
|
23
23
|
require_relative 'definition'
|
24
24
|
|
25
25
|
require 'build/environment'
|
@@ -30,7 +30,7 @@ module Teapot
|
|
30
30
|
end
|
31
31
|
|
32
32
|
class Target < Definition
|
33
|
-
include Dependency
|
33
|
+
include Build::Dependency
|
34
34
|
|
35
35
|
def initialize(context, package, name)
|
36
36
|
super context, package, name
|
data/lib/teapot/version.rb
CHANGED
data/spec/teapot/command_spec.rb
CHANGED
@@ -20,22 +20,30 @@
|
|
20
20
|
|
21
21
|
require 'teapot/command'
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
RSpec.describe Teapot::Command, order: :defined do
|
24
|
+
let!(:source) {"https://github.com/kurocha"}
|
25
|
+
let!(:root) {Build::Files::Path.new(__dir__) + "command_spec"}
|
26
|
+
let!(:project_name) {"Test Project"}
|
27
|
+
let!(:project_path) {root + 'test-project'}
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
after do
|
33
|
-
PROJECT_PATH.delete
|
34
|
-
end
|
29
|
+
let(:top) {Teapot::Command::Top["--root", project_path.to_s]}
|
30
|
+
|
31
|
+
context Teapot::Command::Create do
|
32
|
+
subject {top["create", project_name, source.to_s, "project"]}
|
35
33
|
|
36
34
|
it "should create a new project" do
|
35
|
+
root.delete
|
36
|
+
|
37
|
+
expect{subject.invoke}.to_not raise_error
|
38
|
+
expect(project_path + "teapot.rb").to be_exist
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context Teapot::Command::Build do
|
43
|
+
subject {top["build", "Run/TestProject"]}
|
44
|
+
|
45
|
+
it "should build project" do
|
37
46
|
expect{subject.invoke}.to_not raise_error
|
38
|
-
expect(PROJECT_PATH + "teapot.rb").to be_exist
|
39
47
|
end
|
40
48
|
end
|
41
49
|
end
|
data/spec/teapot/context_spec.rb
CHANGED
@@ -20,22 +20,19 @@
|
|
20
20
|
|
21
21
|
require 'teapot/context'
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
RSpec.describe Teapot::Context do
|
24
|
+
let(:root) {Build::Files::Path.new(__dir__) + "context_spec"}
|
25
|
+
let(:context) {Teapot::Context.new(root)}
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# 13 defined packages + 1 implicit package.
|
38
|
-
expect(default_configuration.packages.count).to be == 14
|
39
|
-
end
|
27
|
+
it "should load teapot.rb file" do
|
28
|
+
# There is one configuration:
|
29
|
+
expect(context.configurations.count).to be == 1
|
30
|
+
|
31
|
+
expect(context.targets.count).to be == 1
|
32
|
+
|
33
|
+
default_configuration = context.configuration
|
34
|
+
|
35
|
+
# 13 defined packages + 1 implicit package.
|
36
|
+
expect(default_configuration.packages.count).to be == 14
|
40
37
|
end
|
41
38
|
end
|
data/teapot.gemspec
CHANGED
@@ -30,18 +30,20 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_dependency "graphviz", "~> 0.4"
|
32
32
|
|
33
|
-
spec.add_dependency "
|
33
|
+
spec.add_dependency "rugged"
|
34
|
+
|
35
|
+
spec.add_dependency "build", "~> 1.1"
|
34
36
|
spec.add_dependency "build-files", "~> 1.0"
|
35
37
|
spec.add_dependency "build-dependency", "~> 1.1"
|
36
38
|
spec.add_dependency "build-uri", "~> 1.0"
|
39
|
+
spec.add_dependency "build-text", "~> 1.0"
|
37
40
|
|
38
|
-
spec.add_dependency "
|
39
|
-
spec.add_dependency "samovar", "~> 1.2"
|
41
|
+
spec.add_dependency "samovar", "~> 1.6"
|
40
42
|
|
41
43
|
# This could be a good option in the future for teapot fetch:
|
42
44
|
#spec.add_dependency "rugged"
|
43
45
|
|
44
46
|
spec.add_development_dependency "bundler", "~> 1.3"
|
45
|
-
spec.add_development_dependency "rspec", "~> 3.
|
47
|
+
spec.add_development_dependency "rspec", "~> 3.6"
|
46
48
|
spec.add_development_dependency "rake"
|
47
49
|
end
|