Module: Reap
- Defined in:
- lib/reap/task.rb,
lib/reap/reap.rb,
lib/reap/task/doap.rb,
lib/reap/rake/adapter.rb
Overview
Base class for reap tasks.
Here’s a simple example:
class MyTask < Reap::Task
task_desc 'this is a custom reap task'
task_attr :mytask
def init
mytask. ||= 'None Found!'
end
def run
puts mytask. #=> Hello!
puts master.default #=> Yo!
puts mytask.default #=> Yo! (inherited from master)
end
end
With the corresponding settings in the ProjectInfo file as:
default: Yo!
mytask:
message: Hello!
Defined Under Namespace
Classes: Announce, Doap, ExTest, Info, Install, Manifest, Noop, Package, Perm, Publish, RDoc, Release, Task, Test
Constant Summary collapse
- Version =
"4.3.5"
Class Method Summary collapse
- .projectfile? ⇒ Boolean
- .RakeAdapter(reapclass) ⇒ Object
-
.register ⇒ Object
( alternative_project_file=nil ).
-
.registry ⇒ Object
Hash of all possible tasks { task name => task class }.
-
.tasks ⇒ Object
Hash of tasks available to this project.
Class Method Details
.projectfile? ⇒ Boolean
50 51 52 |
# File 'lib/reap/reap.rb', line 50 def self.projectfile? $PROJECT_INFO.exists? end |
.RakeAdapter(reapclass) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 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 |
# File 'lib/reap/rake/adapter.rb', line 11 def self.RakeAdapter( reapclass ) 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? = OpenObject.new yield( ) @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 |
.register ⇒ Object
( alternative_project_file=nil )
45 46 47 48 |
# File 'lib/reap/reap.rb', line 45 def self.register #( alternative_project_file=nil ) $PROJECT_INFO = ProjectInfo.load( nil, true ) $PROJECT_INFO.exists? end |
.registry ⇒ Object
Hash of all possible tasks { task name => task class }
29 30 31 |
# File 'lib/reap/reap.rb', line 29 def self.registry Task.task_list end |
.tasks ⇒ Object
Hash of tasks available to this project
35 36 37 38 39 40 41 42 43 |
# File 'lib/reap/reap.rb', line 35 def self.tasks unless @tasks @tasks = {} registry.each do |name, klass| @tasks[name] = klass if klass.verify? end end @tasks end |