Module: Fudge::TaskDSL

Included in:
Description
Defined in:
lib/fudge/task_dsl.rb

Overview

Domain specific language for expressing Tasks in the Fudgefile

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object

Delegate to the current object scope



25
26
27
28
29
# File 'lib/fudge/task_dsl.rb', line 25

def method_missing(meth, *args, &block)
  task meth, *args, &block
rescue Fudge::Exceptions::TaskNotFound
  super
end

Class Method Details

.included(base) ⇒ Object

Sets up attr_writers the including class will need



5
6
7
# File 'lib/fudge/task_dsl.rb', line 5

def self.included(base)
  attr_writer :scope
end

Instance Method Details

#scopeObject

Add self to the scope



10
11
12
# File 'lib/fudge/task_dsl.rb', line 10

def scope
  @scope ||= [self]
end

#task(name, *args) ⇒ Object

Adds a task to the current scope



15
16
17
18
19
20
21
22
# File 'lib/fudge/task_dsl.rb', line 15

def task(name, *args)
  klass = Fudge::Tasks.discover(name)

  task = klass.new(*args)
  current_scope.tasks << task

  with_scope(task) { yield if block_given? }
end