require 'rake' require 'rake/tasklib' require 'rbconfig' require 'fileutils' #require 'mega/filelist' require 'reap/projectinfo' module Reap ; VERSION = 3.01 ; end module ReapTask extend self end # Base class for reap tasks. # # Here's an oh so simple example: # # class MyTask < Reap::Task # # register 'mytask' # # default_desc 'this is a custom reap task' # # attr_accessor :message # # def init # @message ||= master['default'] || 'None Found!' # end # # def run # puts @message # end # end # # The corresponding settings in the ProjectInfo file will then be: # # default: Default text, if any. # # myname: # TASK: mytask # message: Message text, if any. # module Reap #def self.register( name, klass ) # @registry ||= {} # @registry[name.to_s.downcase] = klass #end #def self.registry ; @registry ; end class Task < ::Rake::TaskLib RUBY = Config::CONFIG['ruby_install_name'] def self.register( name ) klass = self.class ReapTask.class_eval { define_method( "#{name}_task" ) { |*args| klass.new(*args) } } end def master ::ProjectInfo.info end #attr_reader :name, :description, :subtask def initialize( task_name=nil, subtask=nil, &yld ) #:yield: o = nil o = yld.call(self) if yld if String === o begin section( o ).each { |k,v| send("#{k}=", v ) } end end init task_name ||= default_name task_desc = @desc || default_desc if subtask desc task_desc task task_name => subtask do run end else desc task_desc task task_name do run end end end def default_desc ; '(no desciption given)' ; end #def default_name ; self.class.basename.downcase ; end def init raise "not implemented" end def section( ymlstr ) iy = YAML::load(ProjectInfo.info_stream + "\ntask:\n" + ymlstr.tabto(2)) iy['task'] || {} end end #class Task end #module Reap ## # Convenience methods for built-in rake tasks ## module RakeTask extend self def gem_package_task(*args,&blk) ::Rake::GemPackageTask.new(*args,&blk) end def package_task(*args,&blk) ::Rake::PackageTask.new(*args,&blk) end def test_task(*args,&blk) ::Rake::TestTask.new(*args,&blk) end def rdoc_task(*args,&blk) ::Rake::RDocTask.new(*args,&blk) end end