module Fudge::TaskDSL

Domain specific language for expressing Tasks in the Fudgefile

Public Class Methods

included(base) click to toggle source

Sets up attr_writers the including class will need

# File lib/fudge/task_dsl.rb, line 5
def self.included(base)
  attr_writer :scope
end

Public Instance Methods

method_missing(meth, *args, &block) click to toggle source

Delegate to the current object scope

Calls superclass method
# File lib/fudge/task_dsl.rb, line 25
def method_missing(meth, *args, &block)
  task meth, *args, &block
rescue Fudge::Exceptions::TaskNotFound
  super
end
scope() click to toggle source

Add self to the scope

# File lib/fudge/task_dsl.rb, line 10
def scope
  @scope ||= [self]
end
task(name, *args) { || ... } click to toggle source

Adds a task to the current scope

# 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

Private Instance Methods

current_scope() click to toggle source
# File lib/fudge/task_dsl.rb, line 32
def current_scope
  scope.last
end
with_scope(task) { || ... } click to toggle source
# File lib/fudge/task_dsl.rb, line 36
def with_scope(task)
  scope << task
  yield
  scope.pop
end