Modify task DSL API to take env on initialization
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user