tap 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History +35 -1
- data/MIT-LICENSE +1 -1
- data/README +16 -15
- data/bin/tap +1 -1
- data/cmd/console.rb +4 -3
- data/cmd/manifest.rb +2 -2
- data/cmd/run.rb +12 -15
- data/doc/Class Reference +120 -117
- data/doc/Command Reference +27 -27
- data/doc/Syntax Reference +55 -111
- data/doc/Tutorial +69 -26
- data/lib/tap.rb +3 -8
- data/lib/tap/app.rb +122 -146
- data/lib/tap/constants.rb +2 -2
- data/lib/tap/env.rb +178 -252
- data/lib/tap/exe.rb +67 -30
- data/lib/tap/file_task.rb +224 -411
- data/lib/tap/generator/arguments.rb +13 -0
- data/lib/tap/generator/base.rb +112 -30
- data/lib/tap/generator/destroy.rb +36 -13
- data/lib/tap/generator/generate.rb +69 -48
- data/lib/tap/generator/generators/command/templates/command.erb +3 -3
- data/lib/tap/generator/generators/config/config_generator.rb +82 -10
- data/lib/tap/generator/generators/generator/generator_generator.rb +16 -6
- data/lib/tap/generator/generators/generator/templates/task.erb +2 -2
- data/lib/tap/generator/generators/generator/templates/test.erb +26 -0
- data/lib/tap/generator/generators/root/root_generator.rb +24 -13
- data/lib/tap/generator/generators/root/templates/Rakefile +4 -4
- data/lib/tap/generator/generators/root/templates/{tapfile → Rapfile} +6 -6
- data/lib/tap/generator/generators/root/templates/gemspec +0 -1
- data/lib/tap/generator/generators/task/task_generator.rb +3 -3
- data/lib/tap/generator/generators/task/templates/test.erb +1 -1
- data/lib/tap/generator/manifest.rb +7 -1
- data/lib/tap/generator/preview.rb +76 -0
- data/lib/tap/root.rb +222 -156
- data/lib/tap/spec.rb +41 -0
- data/lib/tap/support/aggregator.rb +25 -28
- data/lib/tap/support/audit.rb +278 -357
- data/lib/tap/support/constant.rb +2 -1
- data/lib/tap/support/constant_manifest.rb +28 -25
- data/lib/tap/support/dependency.rb +1 -1
- data/lib/tap/support/executable.rb +52 -183
- data/lib/tap/support/executable_queue.rb +50 -20
- data/lib/tap/support/gems.rb +1 -1
- data/lib/tap/support/intern.rb +0 -6
- data/lib/tap/support/join.rb +49 -83
- data/lib/tap/support/joins.rb +0 -3
- data/lib/tap/support/joins/switch.rb +13 -11
- data/lib/tap/support/joins/sync_merge.rb +25 -50
- data/lib/tap/support/manifest.rb +1 -0
- data/lib/tap/support/node.rb +140 -20
- data/lib/tap/support/parser.rb +56 -42
- data/lib/tap/support/schema.rb +183 -157
- data/lib/tap/support/templater.rb +9 -1
- data/lib/tap/support/versions.rb +39 -0
- data/lib/tap/task.rb +150 -177
- data/lib/tap/tasks/dump.rb +4 -4
- data/lib/tap/tasks/load.rb +29 -29
- data/lib/tap/test.rb +66 -53
- data/lib/tap/test/env_vars.rb +3 -3
- data/lib/tap/test/extensions.rb +11 -17
- data/lib/tap/test/file_test.rb +74 -132
- data/lib/tap/test/file_test_class.rb +4 -1
- data/lib/tap/test/regexp_escape.rb +2 -2
- data/lib/tap/test/script_test.rb +2 -2
- data/lib/tap/test/subset_test.rb +6 -6
- data/lib/tap/test/tap_test.rb +28 -154
- metadata +30 -51
- data/bin/rap +0 -118
- data/cgi/run.rb +0 -97
- data/lib/tap/declarations.rb +0 -229
- data/lib/tap/generator/generators/config/templates/doc.erb +0 -12
- data/lib/tap/generator/generators/config/templates/nodoc.erb +0 -8
- data/lib/tap/generator/generators/file_task/file_task_generator.rb +0 -27
- data/lib/tap/generator/generators/file_task/templates/file.txt +0 -11
- data/lib/tap/generator/generators/file_task/templates/result.yml +0 -6
- data/lib/tap/generator/generators/file_task/templates/task.erb +0 -33
- data/lib/tap/generator/generators/file_task/templates/test.erb +0 -29
- data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +0 -5
- data/lib/tap/patches/optparse/summarize.rb +0 -62
- data/lib/tap/support/assignments.rb +0 -173
- data/lib/tap/support/class_configuration.rb +0 -182
- data/lib/tap/support/combinator.rb +0 -125
- data/lib/tap/support/configurable.rb +0 -113
- data/lib/tap/support/configurable_class.rb +0 -271
- data/lib/tap/support/configuration.rb +0 -170
- data/lib/tap/support/gems/rake.rb +0 -111
- data/lib/tap/support/instance_configuration.rb +0 -173
- data/lib/tap/support/joins/fork.rb +0 -19
- data/lib/tap/support/joins/merge.rb +0 -22
- data/lib/tap/support/joins/sequence.rb +0 -21
- data/lib/tap/support/lazy_attributes.rb +0 -45
- data/lib/tap/support/lazydoc.rb +0 -386
- data/lib/tap/support/lazydoc/comment.rb +0 -503
- data/lib/tap/support/lazydoc/config.rb +0 -17
- data/lib/tap/support/lazydoc/definition.rb +0 -36
- data/lib/tap/support/lazydoc/document.rb +0 -152
- data/lib/tap/support/lazydoc/method.rb +0 -24
- data/lib/tap/support/tdoc.rb +0 -409
- data/lib/tap/support/tdoc/tdoc_html_generator.rb +0 -38
- data/lib/tap/support/tdoc/tdoc_html_template.rb +0 -42
- data/lib/tap/support/validation.rb +0 -479
- data/lib/tap/tasks/rake.rb +0 -57
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'ostruct'
|
2
|
-
|
2
|
+
autoload(:ERB, 'erb')
|
3
|
+
autoload(:YAML, 'yaml')
|
3
4
|
|
4
5
|
module Tap
|
5
6
|
module Support
|
@@ -161,6 +162,13 @@ module Tap
|
|
161
162
|
@_erbout = input
|
162
163
|
end
|
163
164
|
|
165
|
+
unless RUBY_VERSION < "1.9"
|
166
|
+
def force_encoding(encoding)
|
167
|
+
@_erbout.force_encoding(encoding)
|
168
|
+
@_erbout
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
164
172
|
# Redirects output of erb to the redirected_erbout string
|
165
173
|
# for the duration of the block. When redirect completes,
|
166
174
|
# the redirected_erbout is concatenated to the main
|
data/lib/tap/support/versions.rb
CHANGED
@@ -80,6 +80,45 @@ module Tap
|
|
80
80
|
a <=> b
|
81
81
|
end
|
82
82
|
|
83
|
+
# Version unique. Select the latest or earliest versions of each file
|
84
|
+
# in the array. For paths that have no version, vniq considers any
|
85
|
+
# version to beat no version. The order of paths is preserved by
|
86
|
+
# default, but the extra sort doing so may be turned off.
|
87
|
+
#
|
88
|
+
# paths = [
|
89
|
+
# "/path/to/two-0.0.1.txt",
|
90
|
+
# "/path/to/one-0.0.1.txt",
|
91
|
+
# "/path/to/one.txt",
|
92
|
+
# "/path/to/two-1.0.1.txt",
|
93
|
+
# "/path/to/three.txt"]
|
94
|
+
#
|
95
|
+
# vniq(paths)
|
96
|
+
# # => [
|
97
|
+
# # "/path/to/one-0.0.1.txt",
|
98
|
+
# # "/path/to/two-1.0.1.txt",
|
99
|
+
# # "/path/to/three.txt"]
|
100
|
+
#
|
101
|
+
def vniq(array, earliest=false, preserve_order=true)
|
102
|
+
unique = {}
|
103
|
+
array.sort.each do |path|
|
104
|
+
base, version = deversion(path)
|
105
|
+
(unique[base] ||= []) << version
|
106
|
+
end
|
107
|
+
|
108
|
+
results = []
|
109
|
+
unique.each_pair do |base, versions|
|
110
|
+
versions = versions.sort {|a, b| compare_versions(a,b) }
|
111
|
+
winner = earliest ? versions.shift : versions.pop
|
112
|
+
results << version(base, winner)
|
113
|
+
end
|
114
|
+
|
115
|
+
results = results.sort_by do |path|
|
116
|
+
array.index(path)
|
117
|
+
end if preserve_order
|
118
|
+
|
119
|
+
results
|
120
|
+
end
|
121
|
+
|
83
122
|
private
|
84
123
|
|
85
124
|
# Converts an input argument (typically a string or an array)
|
data/lib/tap/task.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
|
2
|
-
require 'tap/support/lazydoc/method'
|
3
|
-
require 'tap/support/lazydoc/definition'
|
4
|
-
require 'tap/support/intern'
|
5
|
-
autoload(:OptionParser, 'optparse')
|
1
|
+
autoload(:ConfigParser, 'config_parser')
|
6
2
|
|
7
3
|
module Tap
|
8
|
-
|
4
|
+
autoload(:FileTask, 'tap/file_task')
|
5
|
+
|
6
|
+
module Support
|
7
|
+
autoload(:Templater, 'tap/support/templater')
|
8
|
+
autoload(:Intern, 'tap/support/intern')
|
9
|
+
end
|
10
|
+
|
9
11
|
# === Task Definition
|
10
12
|
#
|
11
13
|
# Tasks specify executable code by overridding the process method in
|
@@ -29,9 +31,8 @@ module Tap
|
|
29
31
|
# MixedInputs.new.execute(:a, :b) # => [:a, :b, []]
|
30
32
|
# MixedInputs.new.execute(:a, :b, 1, 2, 3) # => [:a, :b, [1,2,3]]
|
31
33
|
#
|
32
|
-
# Tasks may be create with new, or with intern. Intern overrides
|
33
|
-
#
|
34
|
-
# and the inputs.
|
34
|
+
# Tasks may be create with new, or with intern. Intern overrides process
|
35
|
+
# using a block that receives the task instance and the inputs.
|
35
36
|
#
|
36
37
|
# no_inputs = Task.intern {|task| [] }
|
37
38
|
# one_input = Task.intern {|task, input| [input] }
|
@@ -67,8 +68,8 @@ module Tap
|
|
67
68
|
# t.respond_to?(:three) # => false
|
68
69
|
#
|
69
70
|
# Configurations can be validated/transformed using an optional block.
|
70
|
-
#
|
71
|
-
#
|
71
|
+
# Many common blocks are pre-packaged and may be accessed through the
|
72
|
+
# class method 'c':
|
72
73
|
#
|
73
74
|
# class ValidatingTask < Tap::Task
|
74
75
|
# # string config validated to be a string
|
@@ -85,40 +86,31 @@ module Tap
|
|
85
86
|
# t.integer = "1"
|
86
87
|
# t.integer == 1 # => true
|
87
88
|
#
|
88
|
-
|
89
|
-
#
|
90
|
-
# Tasks can be subclassed normally, with one reminder related to batching.
|
89
|
+
# See the {Configurable}[http://tap.rubyforge.org/configurable/]
|
90
|
+
# documentation for more information.
|
91
91
|
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
# undesirable; the batched task should have it's own copy of an
|
96
|
-
# instance variable.
|
92
|
+
# === Subclassing
|
93
|
+
# Tasks may be subclassed normally, but be sure to call super as necessary,
|
94
|
+
# in particular when overriding the following methods:
|
97
95
|
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
96
|
+
# class Subclass < Tap::Task
|
97
|
+
# class << self
|
98
|
+
# def inherited(child)
|
99
|
+
# super
|
100
|
+
# end
|
101
|
+
# end
|
101
102
|
#
|
102
|
-
# class SubclassTask < Tap::Task
|
103
|
-
# attr_accessor :array
|
104
103
|
# def initialize(*args)
|
105
|
-
# @array = []
|
106
104
|
# super
|
107
105
|
# end
|
108
|
-
#
|
106
|
+
#
|
109
107
|
# def initialize_copy(orig)
|
110
|
-
# @array = orig.array.dup
|
111
108
|
# super
|
112
109
|
# end
|
113
110
|
# end
|
114
111
|
#
|
115
|
-
# t1 = SubclassTask.new
|
116
|
-
# t2 = t1.initialize_batch_obj
|
117
|
-
# t1.array == t2.array # => true
|
118
|
-
# t1.array.object_id == t2.array.object_id # => false
|
119
|
-
#
|
120
112
|
class Task
|
121
|
-
include
|
113
|
+
include Configurable
|
122
114
|
include Support::Executable
|
123
115
|
|
124
116
|
class << self
|
@@ -140,15 +132,15 @@ module Tap
|
|
140
132
|
# Returns an instance of self; the instance is a kind of 'global'
|
141
133
|
# instance used in class-level dependencies. See depends_on.
|
142
134
|
def instance
|
143
|
-
@instance ||= new
|
135
|
+
@instance ||= new.extend(Support::Dependency)
|
144
136
|
end
|
145
137
|
|
146
138
|
def inherited(child) # :nodoc:
|
147
139
|
unless child.instance_variable_defined?(:@source_file)
|
148
|
-
caller
|
140
|
+
caller[0] =~ Lazydoc::CALLER_REGEXP
|
149
141
|
child.instance_variable_set(:@source_file, File.expand_path($1))
|
150
142
|
end
|
151
|
-
|
143
|
+
|
152
144
|
child.instance_variable_set(:@dependencies, dependencies.dup)
|
153
145
|
super
|
154
146
|
end
|
@@ -168,146 +160,166 @@ module Tap
|
|
168
160
|
end
|
169
161
|
|
170
162
|
# Parses the argv into an instance of self and an array of arguments
|
171
|
-
# (implicitly to be enqued to the instance).
|
172
|
-
|
173
|
-
|
174
|
-
parse!(argv.dup, &block)
|
163
|
+
# (implicitly to be enqued to the instance).
|
164
|
+
def parse(argv=ARGV, app=Tap::App.instance)
|
165
|
+
parse!(argv.dup, app)
|
175
166
|
end
|
176
167
|
|
177
|
-
# Same as parse, but removes switches destructively.
|
178
|
-
def parse!(argv=ARGV, app=Tap::App.instance)
|
179
|
-
opts =
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
unless configurations.empty?
|
184
|
-
opts.separator ""
|
185
|
-
opts.separator "configurations:"
|
186
|
-
end
|
187
|
-
|
188
|
-
configurations.each do |receiver, key, config|
|
189
|
-
opts.on(*config.to_optparse_argv) do |value|
|
190
|
-
argv_config[key] = value
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
# Add options on_tail, giving priority to configurations
|
168
|
+
# Same as parse, but removes switches destructively.
|
169
|
+
def parse!(argv=ARGV, app=Tap::App.instance)
|
170
|
+
opts = ConfigParser.new
|
171
|
+
opts.separator "configurations:"
|
172
|
+
opts.add(configurations)
|
173
|
+
|
195
174
|
opts.separator ""
|
196
175
|
opts.separator "options:"
|
197
|
-
|
198
|
-
|
176
|
+
|
177
|
+
# add option to print help
|
178
|
+
opts.on("--help", "Print this help") do
|
199
179
|
prg = case $0
|
200
180
|
when /rap$/ then 'rap'
|
201
181
|
else 'tap run --'
|
202
182
|
end
|
203
183
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
puts opts
|
209
|
-
exit
|
210
|
-
end
|
184
|
+
puts "#{help}usage: #{prg} #{to_s.underscore} #{args}"
|
185
|
+
puts
|
186
|
+
puts opts
|
187
|
+
exit
|
211
188
|
end
|
212
|
-
|
213
|
-
#
|
189
|
+
|
190
|
+
# add option to specify the task name
|
214
191
|
name = default_name
|
215
|
-
opts.
|
192
|
+
opts.on('--name NAME', 'Specifies the task name') do |value|
|
216
193
|
name = value
|
217
194
|
end
|
218
|
-
|
219
|
-
#
|
195
|
+
|
196
|
+
# add option to specify a config file
|
197
|
+
config_path = nil
|
198
|
+
opts.on('--config FILE', 'Specifies a config file') do |value|
|
199
|
+
config_path = value
|
200
|
+
end
|
201
|
+
|
202
|
+
# add option to load args to ARGV
|
220
203
|
use_args = []
|
221
|
-
opts.
|
222
|
-
|
223
|
-
case obj
|
224
|
-
when Hash
|
225
|
-
obj.values.each do |array|
|
226
|
-
# error if value isn't an array
|
227
|
-
use_args.concat(array)
|
228
|
-
end
|
229
|
-
when Array
|
230
|
-
use_args.concat(obj)
|
231
|
-
else
|
232
|
-
use_args << obj
|
233
|
-
end
|
204
|
+
opts.on('--use FILE', 'Loads inputs to ARGV') do |path|
|
205
|
+
use(path, use_args)
|
234
206
|
end
|
235
207
|
|
236
|
-
# parse
|
237
|
-
opts.parse!(argv)
|
208
|
+
# parse!
|
209
|
+
argv = opts.parse!(argv, {}, false)
|
238
210
|
|
239
|
-
#
|
240
|
-
|
241
|
-
|
242
|
-
path_configs = load_config(app.config_filepath(name))
|
243
|
-
if path_configs.kind_of?(Array)
|
244
|
-
path_configs.each_with_index do |path_config, i|
|
245
|
-
next if i == 0
|
246
|
-
batch_obj = obj.initialize_batch_obj(path_config, "#{name}_#{i}")
|
247
|
-
batch_obj.reconfigure(argv_config)
|
248
|
-
end
|
249
|
-
path_configs = path_configs[0]
|
211
|
+
# load configurations
|
212
|
+
if config_path == nil && name != nil
|
213
|
+
config_path = app.filepath('config', "#{name}.yml")
|
250
214
|
end
|
251
|
-
obj.reconfigure(path_configs).reconfigure(argv_config)
|
252
215
|
|
253
|
-
|
216
|
+
config = load_config(config_path)
|
217
|
+
|
218
|
+
# build and reconfigure the instance
|
219
|
+
instance = new({}, name, app).reconfigure(config).reconfigure(opts.nested_config)
|
220
|
+
|
221
|
+
[instance, (argv + use_args)]
|
254
222
|
end
|
255
223
|
|
256
224
|
# A convenience method to parse the argv and execute the instance
|
257
225
|
# with the remaining arguments. If 'help' is specified in the argv,
|
258
226
|
# execute prints the help and exits.
|
227
|
+
#
|
228
|
+
# Returns the non-audited result.
|
259
229
|
def execute(argv=ARGV)
|
260
|
-
instance, args = parse(ARGV)
|
261
|
-
puts help
|
262
|
-
exit
|
263
|
-
end
|
264
|
-
|
230
|
+
instance, args = parse(ARGV)
|
265
231
|
instance.execute(*args)
|
266
232
|
end
|
267
|
-
|
268
|
-
# Returns the class lazydoc, resolving if specified.
|
269
|
-
def lazydoc(resolve=true)
|
270
|
-
lazydoc = super(false)
|
271
|
-
lazydoc[self.to_s]['args'] ||= lazydoc.register_method(:process, Support::Lazydoc::Method)
|
272
|
-
super
|
273
|
-
end
|
274
233
|
|
275
234
|
DEFAULT_HELP_TEMPLATE = %Q{<% manifest = task_class.manifest %>
|
276
|
-
<%= task_class %><%= manifest.
|
235
|
+
<%= task_class %><%= manifest.empty? ? '' : ' -- ' %><%= manifest.to_s %>
|
277
236
|
|
278
|
-
<%
|
237
|
+
<% desc = manifest.kind_of?(Lazydoc::Comment) ? manifest.wrap(77, 2, nil) : [] %>
|
238
|
+
<% unless desc.empty? %>
|
279
239
|
<%= '-' * 80 %>
|
280
240
|
|
281
|
-
<%
|
241
|
+
<% desc.each do |line| %>
|
282
242
|
<%= line %>
|
283
243
|
<% end %>
|
284
244
|
<%= '-' * 80 %>
|
285
245
|
<% end %>
|
286
246
|
|
287
247
|
}
|
248
|
+
|
288
249
|
# Returns the class help.
|
289
250
|
def help
|
290
251
|
Tap::Support::Templater.new(DEFAULT_HELP_TEMPLATE, :task_class => self).build
|
291
252
|
end
|
292
253
|
|
254
|
+
# Recursively loads path into a nested configuration file.
|
255
|
+
def load_config(path)
|
256
|
+
# optimization to check for trivial paths
|
257
|
+
return {} if Root.trivial?(path)
|
258
|
+
|
259
|
+
Configurable::Utils.load_file(path, true) do |base, key, value|
|
260
|
+
base[key] ||= value if base.kind_of?(Hash)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
# Loads the contents of path onto argv.
|
265
|
+
def use(path, argv=ARGV)
|
266
|
+
obj = Root.trivial?(path) ? [] : (YAML.load_file(path) || [])
|
267
|
+
|
268
|
+
case obj
|
269
|
+
when Array then argv.concat(obj)
|
270
|
+
else argv << obj
|
271
|
+
end
|
272
|
+
|
273
|
+
argv
|
274
|
+
end
|
275
|
+
|
293
276
|
protected
|
294
277
|
|
295
|
-
# Sets a class-level dependency
|
296
|
-
# class A, instances of B are initialized to depend on A.instance
|
297
|
-
# specified
|
278
|
+
# Sets a class-level dependency; when task class B depends_on another
|
279
|
+
# task class A, instances of B are initialized to depend on A.instance.
|
280
|
+
# If a non-nil name is specified, depends_on will create a reader of
|
281
|
+
# the resolved dependency value.
|
282
|
+
#
|
283
|
+
# class A < Tap::Task
|
284
|
+
# def process
|
285
|
+
# "result"
|
286
|
+
# end
|
287
|
+
# end
|
288
|
+
#
|
289
|
+
# class B < Tap::Task
|
290
|
+
# depends_on :a, A
|
291
|
+
# end
|
292
|
+
#
|
293
|
+
# b = B.new
|
294
|
+
# b.dependencies # => [A.instance]
|
295
|
+
# b.a # => "result"
|
296
|
+
#
|
297
|
+
# A.instance.resolved? # => true
|
298
|
+
#
|
299
|
+
# Normally class-level dependencies are not added to existing instances
|
300
|
+
# but, as a special case, depends_on updates instance to depend on
|
301
|
+
# dependency_class.instance.
|
302
|
+
#
|
303
|
+
# Returns self.
|
298
304
|
def depends_on(name, dependency_class)
|
299
305
|
unless dependencies.include?(dependency_class)
|
300
306
|
dependencies << dependency_class
|
301
307
|
end
|
302
308
|
|
303
|
-
#
|
304
|
-
|
305
|
-
instance
|
306
|
-
|
307
|
-
|
309
|
+
# update instance with the dependency if necessary
|
310
|
+
if instance_variable_defined?(:@instance)
|
311
|
+
instance.depends_on(dependency_class.instance)
|
312
|
+
end
|
313
|
+
|
314
|
+
if name
|
315
|
+
# returns the resolved result of the dependency
|
316
|
+
define_method(name) do
|
317
|
+
dependency_class.instance.resolve.value
|
318
|
+
end
|
319
|
+
|
320
|
+
public(name)
|
308
321
|
end
|
309
322
|
|
310
|
-
public(name)
|
311
323
|
self
|
312
324
|
end
|
313
325
|
|
@@ -391,50 +403,29 @@ module Tap
|
|
391
403
|
end
|
392
404
|
|
393
405
|
if block_given?
|
406
|
+
# prevent lazydoc registration of the process method
|
407
|
+
subclass.registered_methods.delete(:process)
|
394
408
|
subclass.send(:define_method, :process, &block)
|
395
409
|
end
|
396
410
|
|
397
|
-
#
|
398
|
-
|
399
|
-
|
400
|
-
writer = (options[:writer] ||= "#{name}_config=".to_sym)
|
401
|
-
|
402
|
-
attr_reader name
|
403
|
-
|
404
|
-
define_method(reader) do
|
405
|
-
# return the config for the instance
|
406
|
-
instance_variable_get(instance_var).config
|
407
|
-
end
|
408
|
-
|
409
|
-
define_method(writer) do |value|
|
410
|
-
# initialize or reconfigure the instance of subclass
|
411
|
-
if instance_variable_defined?(instance_var)
|
412
|
-
instance_variable_get(instance_var).reconfigure(value)
|
413
|
-
else
|
414
|
-
instance_variable_set(instance_var, subclass.new(value))
|
415
|
-
end
|
416
|
-
end
|
417
|
-
public(name, reader, writer)
|
411
|
+
# register documentation
|
412
|
+
# TODO: register subclass in documentation
|
413
|
+
options[:desc] ||= Lazydoc.register_caller(Lazydoc::Trailer, 1)
|
418
414
|
|
419
415
|
# add the configuration
|
420
|
-
|
421
|
-
caller[0] =~ Support::Lazydoc::CALLER_REGEXP
|
422
|
-
desc = Support::Lazydoc.register($1, $3.to_i - 1, Support::Lazydoc::Definition)
|
423
|
-
desc.subclass = subclass
|
424
|
-
options[:desc] = desc
|
425
|
-
end
|
426
|
-
|
427
|
-
configurations.add(name, subclass.configurations.instance_config, options)
|
416
|
+
nest(name, subclass, options) {|overrides| subclass.new(overrides) }
|
428
417
|
end
|
429
418
|
end
|
430
419
|
|
431
420
|
instance_variable_set(:@source_file, __FILE__)
|
432
421
|
instance_variable_set(:@default_name, 'tap/task')
|
433
422
|
instance_variable_set(:@dependencies, [])
|
423
|
+
|
434
424
|
lazy_attr :manifest
|
435
|
-
lazy_attr :args
|
425
|
+
lazy_attr :args, :process
|
426
|
+
lazy_register :process, Lazydoc::Arguments
|
436
427
|
|
437
|
-
# The name of self
|
428
|
+
# The name of self
|
438
429
|
#--
|
439
430
|
# Currently names may be any object. Audit makes use of name
|
440
431
|
# via to_s, as does app when figuring configuration filepaths.
|
@@ -442,25 +433,16 @@ module Tap
|
|
442
433
|
|
443
434
|
# Initializes a new Task.
|
444
435
|
def initialize(config={}, name=nil, app=App.instance)
|
445
|
-
super()
|
446
|
-
|
447
436
|
@name = name || self.class.default_name
|
448
437
|
@app = app
|
449
|
-
@
|
438
|
+
@method_name = :execute_with_callbacks
|
450
439
|
@on_complete_block = nil
|
451
440
|
@dependencies = []
|
452
|
-
@batch = [self]
|
453
441
|
|
454
|
-
|
455
|
-
|
456
|
-
# update is prudent to ensure all configs have an input
|
457
|
-
# (and hence, all configs will be initialized)
|
458
|
-
@config = config.update(self.class.configurations)
|
459
|
-
config.bind(self)
|
460
|
-
else
|
461
|
-
initialize_config(config)
|
462
|
-
end
|
442
|
+
# initialize configs
|
443
|
+
initialize_config(config)
|
463
444
|
|
445
|
+
# setup class dependencies
|
464
446
|
self.class.dependencies.each do |dependency_class|
|
465
447
|
depends_on(dependency_class.instance)
|
466
448
|
end
|
@@ -468,15 +450,6 @@ module Tap
|
|
468
450
|
workflow
|
469
451
|
end
|
470
452
|
|
471
|
-
# Creates a new batched object and adds the object to batch. The batched
|
472
|
-
# object will be a duplicate of the current object but with a new name
|
473
|
-
# and/or configurations.
|
474
|
-
def initialize_batch_obj(overrides={}, name=nil)
|
475
|
-
obj = super().reconfigure(overrides)
|
476
|
-
obj.name = name if name
|
477
|
-
obj
|
478
|
-
end
|
479
|
-
|
480
453
|
# The method for processing inputs into outputs. Override this method in
|
481
454
|
# subclasses to provide class-specific process logic. The number of
|
482
455
|
# arguments specified by process corresponds to the number of arguments
|