Add Env class
This commit is contained in:
@@ -13,7 +13,9 @@ module Producer
|
||||
def run!
|
||||
print_usage_and_exit(64) unless @arguments.length == 2
|
||||
|
||||
Recipe.from_file(@arguments[1]).evaluate
|
||||
recipe = Recipe.from_file(@arguments[1])
|
||||
env = Env.new(recipe)
|
||||
recipe.evaluate env
|
||||
end
|
||||
|
||||
|
||||
|
11
lib/producer/core/env.rb
Normal file
11
lib/producer/core/env.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
module Producer
|
||||
module Core
|
||||
class Env
|
||||
attr_reader :current_recipe
|
||||
|
||||
def initialize(recipe)
|
||||
@current_recipe = recipe
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -12,8 +12,8 @@ module Producer
|
||||
@filepath = filepath
|
||||
end
|
||||
|
||||
def evaluate
|
||||
dsl = DSL.new(@code).evaluate
|
||||
def evaluate(env)
|
||||
dsl = DSL.new(@code).evaluate(env)
|
||||
dsl.tasks.each.map(&:evaluate)
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ module Producer
|
||||
@tasks = []
|
||||
end
|
||||
|
||||
def evaluate
|
||||
def evaluate(env)
|
||||
if @code
|
||||
instance_eval @code
|
||||
else
|
||||
|
Reference in New Issue
Block a user