Implement Task::DSL#evaluate:

So that the env is available from the task DSL.
This commit is contained in:
Thibault Jouan
2013-07-30 23:24:28 +00:00
parent a45a340b64
commit ace6a4ad2b
6 changed files with 28 additions and 12 deletions

View File

@@ -16,7 +16,7 @@ module Producer
def evaluate(env)
dsl = DSL.new(@code).evaluate(env)
dsl.tasks.map(&:evaluate)
dsl.tasks.map { |e| e.evaluate env }
end
end
end

View File

@@ -8,8 +8,8 @@ module Producer
@block = block
end
def evaluate
DSL.new &@block
def evaluate(env)
DSL.new(&@block).evaluate(env)
end
end
end

View File

@@ -5,7 +5,11 @@ module Producer
ConditionNotMetError = Class.new(StandardError)
def initialize(&block)
instance_eval &block
@block = block
end
def evaluate(env)
instance_eval &@block
rescue ConditionNotMetError
end