24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/mattock/task.rb', line 24
def define_task(*args)
configs = args.take_while{|arg| Calibrate::Configurable === arg}
= args[configs.length..-1]
if .any?{|arg| Calibrate::Configurable === arg}
raise "Mattock::Task classes should be created with parent configs, then Rake task args"
end
if .empty?
= [default_value_for(:task_name)]
end
task = ::Rake.application.define_task(self, *) do |task, args|
task.finalize_configuration
task.action(args)
end
unless self === task
raise "Task already defined for #{task.name} - attempted to redefine with #{self.name}"
end
task.setup_deferred
task.setup_cascade(*configs) do |t|
t.task_name = task.name
t.task_args =
yield(t) if block_given?
end
return task
end
|