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.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, Noop, Package, Perm, Publish, RDoc, Release, Task, Test

Constant Summary collapse

Version =
"4.3.5"

Class Method Summary collapse

Class Method Details

.projectfile?Boolean

Returns:

  • (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?
        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 )



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

.registryObject

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

.tasksObject

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