bozo 0.3.8 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.8
1
+ 0.4.0
data/bin/bozo CHANGED
@@ -1,9 +1,9 @@
1
- #!/usr/bin/env ruby
2
- $:.push File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
3
-
4
- require "bundler/setup"
5
- require "rainbow"
6
- require "bozo"
7
-
8
- # Invoke the command
1
+ #!/usr/bin/env ruby
2
+ $:.push File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
3
+
4
+ require "bundler/setup"
5
+ require "rainbow"
6
+ require "bozo"
7
+
8
+ # Invoke the command
9
9
  exit GLI.run(ARGV)
data/lib/bozo.rb CHANGED
@@ -1,131 +1,132 @@
1
- $:.push File.expand_path(File.dirname(__FILE__))
2
-
3
- require 'rubygems'
4
- require 'rainbow'
5
- require 'rainbow/ext/string'
6
- require 'gli'
7
- require 'gli_version'
8
- require 'bozo/bozo'
9
- require 'bozo/class_name_helpers'
10
- require 'bozo/logging'
11
- require 'bozo/runner'
12
- require 'bozo/executor'
13
- require 'bozo/bozo_configuration'
14
- require 'bozo/configuration_error'
15
- require 'bozo/execution_error'
16
- require 'bozo/versioning/version'
17
- require 'bozo/versioning/version_bumper'
18
- require 'bozo/versioning/version_bump_error'
19
-
20
- include GLI
21
-
22
- # Set the location of the bozo runtime configuration file
23
- config_file '.bozorc'
24
-
25
- version Bozo::VERSION
26
-
27
- desc 'Run as a build server, allows more destructive actions'
28
- switch 'build-server'
29
-
30
- default_config_file = 'bozorc.rb'
31
-
32
- desc "The build configuration file (defaults to #{default_config_file})"
33
- default_value default_config_file
34
- arg_name 'path'
35
- flag 'config-file'
36
-
37
- default_environment = 'development'
38
-
39
- desc "The build environment (defaults to #{default_environment})"
40
- default_value default_environment
41
- arg_name 'name'
42
- flag :environment
43
-
44
- pre do |global_options, command, options, arguments|
45
- # Load the configuration file.
46
- config = Bozo::BozoConfiguration.new
47
- config.load global_options[:'config-file']
48
-
49
- puts "Building #{config.version} using Bozo #{Bozo::VERSION}"
50
- puts ''
51
-
52
- # Initialize the executor.
53
- @executor = Bozo::Executor.new config, global_options
54
-
55
- true
56
- end
57
-
58
- # Helper method for defining a command that invokes a bozo task.
59
- #
60
- # The first provided name will be passed on to bozo.
61
- #
62
- # Takes an optional block for defining command-specific flags and switches.
63
- #
64
- # @param [Symbol] command_names
65
- # The names to give the command.
66
- def bozo_command(*command_names)
67
- command_name = command_names.first
68
- command command_names do |c|
69
- yield c if block_given?
70
- c.action do |global_options, options, arguments|
71
- @executor.execute command_name, options, ENV.to_hash
72
- end
73
- end
74
- end
75
-
76
- desc 'Remove bozo and all its artifacts'
77
- bozo_command :uninstall
78
-
79
- desc 'Remove all build artifacts'
80
- bozo_command :clean
81
-
82
- desc 'Retrieve all project dependencies'
83
- bozo_command :dependencies
84
-
85
- desc 'Prepare the project'
86
- bozo_command :prepare
87
-
88
- desc 'Compile the project'
89
- bozo_command :compile, :c
90
-
91
- desc 'Run the tests for the project'
92
- bozo_command :test, :t
93
-
94
- desc 'Create a package'
95
- bozo_command :package, :p do |c|
96
- c.desc 'Force a pre-release package to be created'
97
- c.switch 'pre-release'
98
- end
99
-
100
- desc 'Publish a package'
101
- bozo_command :publish do |c|
102
- c.desc 'Force a pre-release package to be published'
103
- c.switch 'pre-release'
104
- end
105
-
106
- desc 'Bump the version number'
107
- long_desc <<EOS
108
- Specify either 'major', 'minor' or 'patch' as an argument. For example: `bozo bump major`
109
- EOS
110
- command :bump do |c|
111
- c.action do |global_options, options, args|
112
- if args.empty?
113
- puts "Specify either 'major', 'minor' or 'patch' as an argument"
114
- else
115
- version_bumper = Bozo::Versioning::VersionBumper.new
116
- version_bumper.bump args[0].to_sym
117
- end
118
- end
119
- end
120
-
121
- on_error do |exception|
122
- puts exception.inspect.color(:red).bright
123
-
124
- if exception.kind_of? Bozo::ExecutionError or exception.kind_of? Bozo::ConfigurationError
125
- false
126
- else
127
- puts ''
128
- puts exception.backtrace.join("\n").color(:red)
129
- true
130
- end
1
+ $:.push File.expand_path(File.dirname(__FILE__))
2
+
3
+ require 'rubygems'
4
+ require 'rainbow'
5
+ require 'rainbow/ext/string'
6
+ require 'gli'
7
+ require 'gli_version'
8
+ require 'bozo/bozo'
9
+ require 'bozo/class_name_helpers'
10
+ require 'bozo/logging'
11
+ require 'bozo/build_dependency_resolver'
12
+ require 'bozo/runner'
13
+ require 'bozo/executor'
14
+ require 'bozo/bozo_configuration'
15
+ require 'bozo/configuration_error'
16
+ require 'bozo/execution_error'
17
+ require 'bozo/versioning/version'
18
+ require 'bozo/versioning/version_bumper'
19
+ require 'bozo/versioning/version_bump_error'
20
+
21
+ include GLI
22
+
23
+ # Set the location of the bozo runtime configuration file
24
+ config_file '.bozorc'
25
+
26
+ version Bozo::VERSION
27
+
28
+ desc 'Run as a build server, allows more destructive actions'
29
+ switch 'build-server'
30
+
31
+ default_config_file = 'bozorc.rb'
32
+
33
+ desc "The build configuration file (defaults to #{default_config_file})"
34
+ default_value default_config_file
35
+ arg_name 'path'
36
+ flag 'config-file'
37
+
38
+ default_environment = 'development'
39
+
40
+ desc "The build environment (defaults to #{default_environment})"
41
+ default_value default_environment
42
+ arg_name 'name'
43
+ flag :environment
44
+
45
+ pre do |global_options, command, options, arguments|
46
+ # Load the configuration file.
47
+ config = Bozo::BozoConfiguration.new
48
+ config.load global_options[:'config-file']
49
+
50
+ puts "Building #{config.version} using Bozo #{Bozo::VERSION}"
51
+ puts ''
52
+
53
+ # Initialize the executor.
54
+ @executor = Bozo::Executor.new config, global_options
55
+
56
+ true
57
+ end
58
+
59
+ # Helper method for defining a command that invokes a bozo task.
60
+ #
61
+ # The first provided name will be passed on to bozo.
62
+ #
63
+ # Takes an optional block for defining command-specific flags and switches.
64
+ #
65
+ # @param [Symbol] command_names
66
+ # The names to give the command.
67
+ def bozo_command(*command_names)
68
+ command_name = command_names.first
69
+ command command_names do |c|
70
+ yield c if block_given?
71
+ c.action do |global_options, options, arguments|
72
+ @executor.execute command_name, options, ENV.to_hash
73
+ end
74
+ end
75
+ end
76
+
77
+ desc 'Remove bozo and all its artifacts'
78
+ bozo_command :uninstall
79
+
80
+ desc 'Remove all build artifacts'
81
+ bozo_command :clean
82
+
83
+ desc 'Retrieve all project dependencies'
84
+ bozo_command :dependencies
85
+
86
+ desc 'Prepare the project'
87
+ bozo_command :prepare
88
+
89
+ desc 'Compile the project'
90
+ bozo_command :compile, :c
91
+
92
+ desc 'Run the tests for the project'
93
+ bozo_command :test, :t
94
+
95
+ desc 'Create a package'
96
+ bozo_command :package, :p do |c|
97
+ c.desc 'Force a pre-release package to be created'
98
+ c.switch 'pre-release'
99
+ end
100
+
101
+ desc 'Publish a package'
102
+ bozo_command :publish do |c|
103
+ c.desc 'Force a pre-release package to be published'
104
+ c.switch 'pre-release'
105
+ end
106
+
107
+ desc 'Bump the version number'
108
+ long_desc <<EOS
109
+ Specify either 'major', 'minor' or 'patch' as an argument. For example: `bozo bump major`
110
+ EOS
111
+ command :bump do |c|
112
+ c.action do |global_options, options, args|
113
+ if args.empty?
114
+ puts "Specify either 'major', 'minor' or 'patch' as an argument"
115
+ else
116
+ version_bumper = Bozo::Versioning::VersionBumper.new
117
+ version_bumper.bump args[0].to_sym
118
+ end
119
+ end
120
+ end
121
+
122
+ on_error do |exception|
123
+ puts exception.inspect.color(:red).bright
124
+
125
+ if exception.kind_of? Bozo::ExecutionError or exception.kind_of? Bozo::ConfigurationError
126
+ false
127
+ else
128
+ puts ''
129
+ puts exception.backtrace.join("\n").color(:red)
130
+ true
131
+ end
131
132
  end
data/lib/bozo/bozo.rb CHANGED
@@ -1,7 +1,7 @@
1
- # The top level module for Bozo's functionality.
2
- module Bozo
3
-
4
- # The version of Bozo in use.
5
- VERSION = File.read(File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../../VERSION')).strip
6
-
1
+ # The top level module for Bozo's functionality.
2
+ module Bozo
3
+
4
+ # The version of Bozo in use.
5
+ VERSION = File.read(File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../../VERSION')).strip
6
+
7
7
  end
@@ -1,300 +1,320 @@
1
- module Bozo
2
-
3
- # Class used for defining the configuration of a build.
4
- class BozoConfiguration
5
-
6
- include Bozo::ClassNameHelpers
7
-
8
- # Creates a new instance
9
- def initialize
10
- @build_tools_location = nil
11
- @compilers = []
12
- @dependency_resolvers = []
13
- @hooks = []
14
- @packagers = []
15
- @preparers = []
16
- @publishers = []
17
- @test_runners = []
18
- @version = nil
19
- end
20
-
21
- # Loads the configuration from the specified file.
22
- #
23
- # @param [String] path
24
- # The path to the configuration file.
25
- def load(path)
26
- instance_eval IO.read(path), path
27
- end
28
-
29
- # The version of the project to build.
30
- def version
31
- @version ||= Versioning::Version.load_from_file
32
- end
33
-
34
- # The location of the base build tools.
35
- #
36
- # Sets and returns the location if a value is provided, otherwise returns
37
- # the current value.
38
- #
39
- # It is expected the build tools will be in sub-directory of this location
40
- # according to the name of the tool and that the runner will be able to
41
- # copy the contents of the sub-directory to a local directory via the
42
- # `FileUtils.cp_r` method.
43
- #
44
- # @param [String] location
45
- # The path to set as the build tools location.
46
- def build_tools_location(location = nil)
47
- @build_tools_location = location if location
48
- @build_tools_location
49
- end
50
-
51
- # Returns the all the build tools required by the specified compilers,
52
- # dependency resolvers, hooks, packagers, publishers and test runners.
53
- def build_tools
54
- build_tools = get_build_tools @compilers
55
- build_tools |= get_build_tools @dependency_resolvers
56
- build_tools |= get_build_tools @hooks
57
- build_tools |= get_build_tools @packagers
58
- build_tools |= get_build_tools @preparers
59
- build_tools |= get_build_tools @publishers
60
- build_tools | (get_build_tools @test_runners)
61
- end
62
-
63
- # Returns the configured dependency resolvers.
64
- attr_reader :dependency_resolvers
65
-
66
- # Adds an instance of the named preparer to the preparer collection and
67
- # yields it to the configuration block when one is specified.
68
- #
69
- # @param [Symbol] type
70
- # The name of the preparer.
71
- # @param [Proc] block
72
- # Optional block to refine the configuration of the preparer.
73
- def prepare(type, &block) # :yields: preparer
74
- add_instance @preparers, Bozo::Preparers, type, block
75
- end
76
-
77
- # Returns the configured preparers.
78
- attr_reader :preparers
79
-
80
- # Adds an instance of the named dependency resolver to the dependency
81
- # resolver collection and yields it to the configuration block when one
82
- # is specified.
83
- #
84
- # @param [Symbol] type
85
- # The name of the dependency resolver.
86
- # @param [Proc] block
87
- # Optional block to refine the configuration of the dependency
88
- # resolver.
89
- def resolve_dependencies_with(type, &block) # :yields: dependency_resolver
90
- add_instance @dependency_resolvers, Bozo::DependencyResolvers, type, block
91
- end
92
-
93
- # Returns the configured compilers.
94
- attr_reader :compilers
95
-
96
- # Adds an instance of the named compiler to the compiler collection and
97
- # yields it to the configuration block when one is specified.
98
- #
99
- # @param [Symbol] type
100
- # The name of the compiler.
101
- # @param [Proc] block
102
- # Optional block to refine the configuration of the compiler.
103
- def compile_with(type, &block) # :yields: compiler
104
- add_instance @compilers, Bozo::Compilers, type, block
105
- end
106
-
107
- # Returns the configured test runners.
108
- attr_reader :test_runners
109
-
110
- # Adds an instance of the named test runner to the test runner collection
111
- # and yields it to the configuration block when one is specified.
112
- #
113
- # @param [Symbol] type
114
- # The name of the test runner.
115
- # @param [Proc] block
116
- # Optional block to refine the configuration of the test runner.
117
- def test_with(type, &block) # :yields: test_runner
118
- add_instance @test_runners, Bozo::TestRunners, type, block
119
- end
120
-
121
- # Returns the configured packagers.
122
- attr_reader :packagers
123
-
124
- # Adds an instance of the named packager to the packager collection and
125
- # yields it to the configuration block when one is specified.
126
- #
127
- # @param [Symbol] type
128
- # The name of the packager.
129
- # @param [Proc] block
130
- # Optional block to refine the configuration of the packager.
131
- def package_with(type, &block) # :yields: packager
132
- add_instance @packagers, Bozo::Packagers, type, block
133
- end
134
-
135
- # Returns the configured publishers.
136
- attr_reader :publishers
137
-
138
- # Adds an instance of the named publisher to the publisher collection and
139
- # yields it to the configuration block when one is specified.
140
- #
141
- # @param [Symbol] type
142
- # The name of the publisher.
143
- # @param [Proc] block
144
- # Optional block to refine the configuration of the publisher.
145
- def publish_with(type, &block) # :yields: publisher
146
- add_instance @publishers, Bozo::Publishers, type, block
147
- end
148
-
149
- # Returns the configured hooks.
150
- attr_reader :hooks
151
-
152
- # Adds an instance of the named hook to the hook collection and yields it
153
- # to the configuration block when one is specified.
154
- #
155
- # @param [Symbol] type
156
- # The name of the hook.
157
- # @param [Proc] block
158
- # Optional block to refine the configuration of the hook.
159
- def with_hook(type, &block) # :yields: hook
160
- add_instance @hooks, Bozo::Hooks, type, block
161
- end
162
-
163
- # Adds an instance of the named hook to the hook collection and yields it
164
- # to the configuration block when one is specified.
165
- alias :pre_build :with_hook
166
-
167
- # Adds an instance of the named hook to the hook collection and yields it
168
- # to the configuration block when one is specified.
169
- alias :pre_clean :with_hook
170
-
171
- # Adds an instance of the named hook to the hook collection and yields it
172
- # to the configuration block when one is specified.
173
- alias :post_clean :with_hook
174
-
175
- # Adds an instance of the named hook to the hook collection and yields it
176
- # to the configuration block when one is specified.
177
- alias :pre_uninstall :with_hook
178
-
179
- # Adds an instance of the named hook to the hook collection and yields it
180
- # to the configuration block when one is specified.
181
- alias :post_uninstall :with_hook
182
-
183
- # Adds an instance of the named hook to the hook collection and yields it
184
- # to the configuration block when one is specified.
185
- alias :pre_dependencies :with_hook
186
-
187
- # Adds an instance of the named hook to the hook collection and yields it
188
- # to the configuration block when one is specified.
189
- alias :post_dependencies :with_hook
190
-
191
- # Adds an instance of the named hook to the hook collection and yields it
192
- # to the configuration block when one is specified.
193
- alias :pre_prepare :with_hook
194
-
195
- # Adds an instance of the named hook to the hook collection and yields it
196
- # to the configuration block when one is specified.
197
- alias :post_prepare :with_hook
198
-
199
- # Adds an instance of the named hook to the hook collection and yields it
200
- # to the configuration block when one is specified.
201
- alias :pre_compile :with_hook
202
-
203
- # Adds an instance of the named hook to the hook collection and yields it
204
- # to the configuration block when one is specified.
205
- alias :post_compile :with_hook
206
-
207
- # Adds an instance of the named hook to the hook collection and yields it
208
- # to the configuration block when one is specified.
209
- alias :pre_test :with_hook
210
-
211
- # Adds an instance of the named hook to the hook collection and yields it
212
- # to the configuration block when one is specified.
213
- alias :post_test :with_hook
214
-
215
- # Adds an instance of the named hook to the hook collection and yields it
216
- # to the configuration block when one is specified.
217
- alias :pre_package :with_hook
218
-
219
- # Adds an instance of the named hook to the hook collection and yields it
220
- # to the configuration block when one is specified.
221
- alias :post_package :with_hook
222
-
223
- # Adds an instance of the named hook to the hook collection and yields it
224
- # to the configuration block when one is specified.
225
- alias :pre_publish :with_hook
226
-
227
- # Adds an instance of the named hook to the hook collection and yields it
228
- # to the configuration block when one is specified.
229
- alias :post_publish :with_hook
230
-
231
- # Adds an instance of the named hook to the hook collection and yields it
232
- # to the configuration block when one is specified.
233
- alias :post_build :with_hook
234
-
235
- private
236
-
237
- # Resolves the named class within the given namespace and then created an
238
- # instance of the class before adding it to the given collection and
239
- # yielding it to the configuration block when one is provided.
240
- #
241
- # @param [Array] collection
242
- # The collection the step executor should be added to once created.
243
- # @param [Module] namespace
244
- # The module the named step executor should be found in.
245
- # @param [Symbol] type
246
- # The name of the step executor.
247
- # @param [Proc] block
248
- # Optional block to refine the configuration of the step executor.
249
- def add_instance(collection, namespace, type, block)
250
- instance = namespace.const_get(to_class_name(type)).new
251
- instance.extend Bozo::Runner
252
- collection << instance
253
- block.call instance if block
254
- end
255
-
256
- # Returns the collection of build tools required for the configuration.
257
- #
258
- # Sourced from the required tools of compilers, dependency resolvers,
259
- # hooks, publishers and test runners.
260
- #
261
- # @param [Array] providers
262
- # Collection of providers that can define required tools.
263
- def get_build_tools(providers)
264
- providers.
265
- select{|p| p.respond_to? :required_tools}.
266
- map{|p| p.required_tools}.
267
- flatten
268
- end
269
-
270
- end
271
-
272
- # Module containing all dependency resolvers.
273
- module DependencyResolvers
274
- end
275
-
276
- # Module containing all compilers.
277
- module Compilers
278
- end
279
-
280
- # Module containing all test runners.
281
- module TestRunners
282
- end
283
-
284
- # Module containing all packagers.
285
- module Packagers
286
- end
287
-
288
- # Module containing all preparers.
289
- module Preparers
290
- end
291
-
292
- # Module containing all publishers.
293
- module Publishers
294
- end
295
-
296
- # Module containing all hooks.
297
- module Hooks
298
- end
299
-
1
+ module Bozo
2
+
3
+ # Class used for defining the configuration of a build.
4
+ class BozoConfiguration
5
+
6
+ include Bozo::ClassNameHelpers
7
+
8
+ # Creates a new instance
9
+ def initialize
10
+ @build_tools_location = nil
11
+ @tools = []
12
+ @compilers = []
13
+ @dependency_resolvers = []
14
+ @hooks = []
15
+ @packagers = []
16
+ @preparers = []
17
+ @publishers = []
18
+ @test_runners = []
19
+ @version = nil
20
+ end
21
+
22
+ # Loads the configuration from the specified file.
23
+ #
24
+ # @param [String] path
25
+ # The path to the configuration file.
26
+ def load(path)
27
+ instance_eval IO.read(path), path
28
+ end
29
+
30
+ # The version of the project to build.
31
+ def version
32
+ @version ||= Versioning::Version.load_from_file
33
+ end
34
+
35
+ # The location of the base build tools.
36
+ #
37
+ # Sets and returns the location if a value is provided, otherwise returns
38
+ # the current value.
39
+ #
40
+ # It is expected the build tools will be in sub-directory of this location
41
+ # according to the name of the tool and that the runner will be able to
42
+ # copy the contents of the sub-directory to a local directory via the
43
+ # `FileUtils.cp_r` method.
44
+ #
45
+ # @param [String] location
46
+ # The path to set as the build tools location.
47
+ def build_tools_location(location = nil)
48
+ @build_tools_location = location if location
49
+ @build_tools_location
50
+ end
51
+
52
+ # Returns the all the build tools required by the specified compilers,
53
+ # dependency resolvers, hooks, packagers, publishers and test runners.
54
+ def build_tools
55
+ build_tools = get_build_tools @compilers
56
+ build_tools |= get_build_tools @dependency_resolvers
57
+ build_tools |= get_build_tools @hooks
58
+ build_tools |= get_build_tools @packagers
59
+ build_tools |= get_build_tools @preparers
60
+ build_tools |= get_build_tools @publishers
61
+ build_tools | (get_build_tools @test_runners)
62
+ end
63
+
64
+ # Returns the configured dependency resolvers.
65
+ attr_reader :dependency_resolvers
66
+
67
+ # Adds an instance of the named preparer to the preparer collection and
68
+ # yields it to the configuration block when one is specified.
69
+ #
70
+ # @param [Symbol] type
71
+ # The name of the preparer.
72
+ # @param [Proc] block
73
+ # Optional block to refine the configuration of the preparer.
74
+ def prepare(type, &block) # :yields: preparer
75
+ add_instance @preparers, Bozo::Preparers, type, block
76
+ end
77
+
78
+ # Returns the configured preparers.
79
+ attr_reader :preparers
80
+
81
+ # Adds an instance of the named dependency resolver to the dependency
82
+ # resolver collection and yields it to the configuration block when one
83
+ # is specified.
84
+ #
85
+ # @param [Symbol] type
86
+ # The name of the dependency resolver.
87
+ # @param [Proc] block
88
+ # Optional block to refine the configuration of the dependency
89
+ # resolver.
90
+ def resolve_dependencies_with(type, &block) # :yields: dependency_resolver
91
+ add_instance @dependency_resolvers, Bozo::DependencyResolvers, type, block
92
+ end
93
+
94
+ # Returns the required tools
95
+ attr_reader :tools
96
+
97
+ # Adds an instance of the named tool to the tools collection and yields it
98
+ # to the configuration block when one is specified.
99
+ #
100
+ # @param [Symbol] type
101
+ # The name of the tool.
102
+ # @param [Proc] block
103
+ # Optional block to refine the configuration of the tool.
104
+ def required_tool(type, &block)
105
+ @tools ||= []
106
+ add_instance @tools, Bozo::Tools, type, block
107
+ end
108
+
109
+ # Returns the configured compilers.
110
+ attr_reader :compilers
111
+
112
+ # Adds an instance of the named compiler to the compiler collection and
113
+ # yields it to the configuration block when one is specified.
114
+ #
115
+ # @param [Symbol] type
116
+ # The name of the compiler.
117
+ # @param [Proc] block
118
+ # Optional block to refine the configuration of the compiler.
119
+ def compile_with(type, &block) # :yields: compiler
120
+ add_instance @compilers, Bozo::Compilers, type, block
121
+ end
122
+
123
+ # Returns the configured test runners.
124
+ attr_reader :test_runners
125
+
126
+ # Adds an instance of the named test runner to the test runner collection
127
+ # and yields it to the configuration block when one is specified.
128
+ #
129
+ # @param [Symbol] type
130
+ # The name of the test runner.
131
+ # @param [Proc] block
132
+ # Optional block to refine the configuration of the test runner.
133
+ def test_with(type, &block) # :yields: test_runner
134
+ add_instance @test_runners, Bozo::TestRunners, type, block
135
+ end
136
+
137
+ # Returns the configured packagers.
138
+ attr_reader :packagers
139
+
140
+ # Adds an instance of the named packager to the packager collection and
141
+ # yields it to the configuration block when one is specified.
142
+ #
143
+ # @param [Symbol] type
144
+ # The name of the packager.
145
+ # @param [Proc] block
146
+ # Optional block to refine the configuration of the packager.
147
+ def package_with(type, &block) # :yields: packager
148
+ add_instance @packagers, Bozo::Packagers, type, block
149
+ end
150
+
151
+ # Returns the configured publishers.
152
+ attr_reader :publishers
153
+
154
+ # Adds an instance of the named publisher to the publisher collection and
155
+ # yields it to the configuration block when one is specified.
156
+ #
157
+ # @param [Symbol] type
158
+ # The name of the publisher.
159
+ # @param [Proc] block
160
+ # Optional block to refine the configuration of the publisher.
161
+ def publish_with(type, &block) # :yields: publisher
162
+ add_instance @publishers, Bozo::Publishers, type, block
163
+ end
164
+
165
+ # Returns the configured hooks.
166
+ attr_reader :hooks
167
+
168
+ # Adds an instance of the named hook to the hook collection and yields it
169
+ # to the configuration block when one is specified.
170
+ #
171
+ # @param [Symbol] type
172
+ # The name of the hook.
173
+ # @param [Proc] block
174
+ # Optional block to refine the configuration of the hook.
175
+ def with_hook(type, &block) # :yields: hook
176
+ add_instance @hooks, Bozo::Hooks, type, block
177
+ end
178
+
179
+ # Adds an instance of the named hook to the hook collection and yields it
180
+ # to the configuration block when one is specified.
181
+ alias :pre_build :with_hook
182
+
183
+ # Adds an instance of the named hook to the hook collection and yields it
184
+ # to the configuration block when one is specified.
185
+ alias :pre_clean :with_hook
186
+
187
+ # Adds an instance of the named hook to the hook collection and yields it
188
+ # to the configuration block when one is specified.
189
+ alias :post_clean :with_hook
190
+
191
+ # Adds an instance of the named hook to the hook collection and yields it
192
+ # to the configuration block when one is specified.
193
+ alias :pre_uninstall :with_hook
194
+
195
+ # Adds an instance of the named hook to the hook collection and yields it
196
+ # to the configuration block when one is specified.
197
+ alias :post_uninstall :with_hook
198
+
199
+ # Adds an instance of the named hook to the hook collection and yields it
200
+ # to the configuration block when one is specified.
201
+ alias :pre_dependencies :with_hook
202
+
203
+ # Adds an instance of the named hook to the hook collection and yields it
204
+ # to the configuration block when one is specified.
205
+ alias :post_dependencies :with_hook
206
+
207
+ # Adds an instance of the named hook to the hook collection and yields it
208
+ # to the configuration block when one is specified.
209
+ alias :pre_prepare :with_hook
210
+
211
+ # Adds an instance of the named hook to the hook collection and yields it
212
+ # to the configuration block when one is specified.
213
+ alias :post_prepare :with_hook
214
+
215
+ # Adds an instance of the named hook to the hook collection and yields it
216
+ # to the configuration block when one is specified.
217
+ alias :pre_compile :with_hook
218
+
219
+ # Adds an instance of the named hook to the hook collection and yields it
220
+ # to the configuration block when one is specified.
221
+ alias :post_compile :with_hook
222
+
223
+ # Adds an instance of the named hook to the hook collection and yields it
224
+ # to the configuration block when one is specified.
225
+ alias :pre_test :with_hook
226
+
227
+ # Adds an instance of the named hook to the hook collection and yields it
228
+ # to the configuration block when one is specified.
229
+ alias :post_test :with_hook
230
+
231
+ # Adds an instance of the named hook to the hook collection and yields it
232
+ # to the configuration block when one is specified.
233
+ alias :pre_package :with_hook
234
+
235
+ # Adds an instance of the named hook to the hook collection and yields it
236
+ # to the configuration block when one is specified.
237
+ alias :post_package :with_hook
238
+
239
+ # Adds an instance of the named hook to the hook collection and yields it
240
+ # to the configuration block when one is specified.
241
+ alias :pre_publish :with_hook
242
+
243
+ # Adds an instance of the named hook to the hook collection and yields it
244
+ # to the configuration block when one is specified.
245
+ alias :post_publish :with_hook
246
+
247
+ # Adds an instance of the named hook to the hook collection and yields it
248
+ # to the configuration block when one is specified.
249
+ alias :post_build :with_hook
250
+
251
+ private
252
+
253
+ # Resolves the named class within the given namespace and then created an
254
+ # instance of the class before adding it to the given collection and
255
+ # yielding it to the configuration block when one is provided.
256
+ #
257
+ # @param [Array] collection
258
+ # The collection the step executor should be added to once created.
259
+ # @param [Module] namespace
260
+ # The module the named step executor should be found in.
261
+ # @param [Symbol] type
262
+ # The name of the step executor.
263
+ # @param [Proc] block
264
+ # Optional block to refine the configuration of the step executor.
265
+ def add_instance(collection, namespace, type, block)
266
+ instance = namespace.const_get(to_class_name(type)).new
267
+ instance.extend Bozo::Runner
268
+ collection << instance
269
+ block.call instance if block
270
+ end
271
+
272
+ # Returns the collection of build tools required for the configuration.
273
+ #
274
+ # Sourced from the required tools of compilers, dependency resolvers,
275
+ # hooks, publishers and test runners.
276
+ #
277
+ # @param [Array] providers
278
+ # Collection of providers that can define required tools.
279
+ def get_build_tools(providers)
280
+ providers.
281
+ select{|p| p.respond_to? :required_tools}.
282
+ map{|p| p.required_tools}.
283
+ flatten
284
+ end
285
+
286
+ end
287
+
288
+ # Module containing all dependency resolvers.
289
+ module DependencyResolvers
290
+ end
291
+
292
+ # Module containing all compilers.
293
+ module Compilers
294
+ end
295
+
296
+ # Module containing all test runners.
297
+ module TestRunners
298
+ end
299
+
300
+ # Module containing all packagers.
301
+ module Packagers
302
+ end
303
+
304
+ # Module containing all preparers.
305
+ module Preparers
306
+ end
307
+
308
+ # Module containing all publishers.
309
+ module Publishers
310
+ end
311
+
312
+ # Module containing all hooks.
313
+ module Hooks
314
+ end
315
+
316
+ # Module containing all tools.
317
+ module Tools
318
+ end
319
+
300
320
  end