Module: Reap

Defined in:
lib/reap/task.rb,
lib/reap/reap.rb,
lib/reap/task/doap.rb,
lib/reap/projectinfo.rb,
lib/reap/rakeadapter.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.message ||= 'None Found!'
  end

  def run
    puts mytask.message  #=> 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, Package, Perm, Publish, RDoc, Release, Scaffold, Task, Template, Test

Constant Summary collapse

Version =
"4.5.0"

Class Method Summary collapse

Class Method Details

.projectfile?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/reap/projectinfo.rb', line 20

def self.projectfile?
  ProjectInfo.instance.info_file
end

.RakeAdapter(reapclass) ⇒ Object

Rake adapter translates a Reap task into a Rake task.



9
10
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/rakeadapter.rb', line 9

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

.registerObject

( alternative_project_file=nil )



14
15
16
17
18
# File 'lib/reap/projectinfo.rb', line 14

def self.register #( alternative_project_file=nil )
  pi = ProjectInfo.load( nil, true )
  pi.require_custom_tasks if pi
  pi
end

.registryObject

Hash of all possible tasks { task name => task class }



55
56
57
# File 'lib/reap/task.rb', line 55

def self.registry
  Task.task_list
end

.tasksObject

Hash of tasks available to this project



61
62
63
64
65
66
67
68
69
# File 'lib/reap/task.rb', line 61

def self.tasks
  unless @tasks
    @tasks = {}
    registry.each do |name, klass|
      @tasks[name] = klass if klass.available?
    end
  end
  @tasks
end