lib/mattock/task.rb in mattock-0.3.0 vs lib/mattock/task.rb in mattock-0.3.1

- old
+ new

@@ -1,8 +1,11 @@ require 'mattock/cascading-definition' +require 'singleton' #Rake fails to require this properly require 'rake/task' require 'rake/file_task' +require 'rake/file_creation_task' +require 'rake/multi_task' module Mattock # A configurable subclass of Rake::Task, such that you can use a # configuration block to change how a common task behaves, while still # overriding Rake API methods like Task#needed? and Task#timestamp @@ -36,10 +39,11 @@ end super(*configs) end def resolve_configuration + super if @extracted_task_args.empty? self.task_args = [task_name] else self.task_args = @extracted_task_args end @@ -81,19 +85,26 @@ def inspect "#{self.class.name}: #{self.task_args.inspect}" end + attr_accessor :rake_task def define - task = task_class.define_task(*task_args) do + self.rake_task = task_class.define_task(*task_args) do finalize_configuration - task.action + copy_settings_to(rake_task) + rake_task.action end - task.source_task = self - copy_settings_to(task) + copy_settings_to(rake_task) + rake_task.source_task = self end end + #I'm having misgivings about this design choice. Rightly, this is probably a + #"Task Definer" that knows what class to ::define_task and then mixin a + #module to handle the original purpose of being able to override e.g. + ##needed? There's a lot of client code that relies on this pattern now, + #though. class Task < Rake::Task include TaskMixin end class FileTask < Rake::FileTask