require 'facet/hash/keys_to_s' module Reap # Rake adapter translates a Reap task into a Rake task. def self.RakeAdapter( reapclass ) require 'rake/tasklib' Class.new( ::Rake::TaskLib ) do define_method( :reapclass ) { reapclass } attr_accessor :name, :options # Create task. def initialize(name=reapclass.task_name) # :yield: @name = name @options = nil if block_given? options = OpenObject.new yield( options ) @options = options.to_h.keys_to_s #reapclass.master[reapclass.task_name].update( @options ) end define end # Create the tasks defined by this task lib. def define desc reapclass.task_desc task name do rc = reapclass.new if @options rc.execute( @options.to_h ) else rc.execute end end self end end end end # module Reap