bozo 0.3.3 → 0.3.4

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.3
1
+ 0.3.4
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/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,300 @@
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
+ @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
+
300
300
  end
@@ -1,17 +1,17 @@
1
- module Bozo
2
-
3
- module ClassNameHelpers
4
-
5
- # Converts a symbol into a Pascal Case class name.
6
- #
7
- # eg. `:single` => `"Single"`, `:two_words` => `"TwoWords"`.
8
- #
9
- # @param [Symbol] type
10
- # The name of a step executor.
11
- def to_class_name(type)
12
- type.to_s.split('_').map{|word| word.capitalize}.join
13
- end
14
-
15
- end
16
-
1
+ module Bozo
2
+
3
+ module ClassNameHelpers
4
+
5
+ # Converts a symbol into a Pascal Case class name.
6
+ #
7
+ # eg. `:single` => `"Single"`, `:two_words` => `"TwoWords"`.
8
+ #
9
+ # @param [Symbol] type
10
+ # The name of a step executor.
11
+ def to_class_name(type)
12
+ type.to_s.split('_').map{|word| word.capitalize}.join
13
+ end
14
+
15
+ end
16
+
17
17
  end