Modify task DSL API to take env on initialization

This commit is contained in:
Thibault Jouan
2014-01-08 21:55:33 +00:00
parent 356d778746
commit 1d6ae126ed
4 changed files with 20 additions and 16 deletions

View File

@@ -3,8 +3,8 @@ module Producer
class Task
class << self
def evaluate(name, env, *args, &block)
dsl = DSL.new(&block)
dsl.evaluate(env, *args)
dsl = DSL.new(env, &block)
dsl.evaluate(*args)
Task.new(name, dsl.actions, dsl.condition)
end
end

View File

@@ -15,16 +15,16 @@ module Producer
define_action :file_write, Actions::FileWriter
attr_accessor :actions
attr_accessor :env, :actions
def initialize(&block)
def initialize(env, &block)
@env = env
@block = block
@actions = []
@condition = true
end
def evaluate(env, *args)
@env = env
def evaluate(*args)
instance_exec *args, &@block
end