Add Env class

This commit is contained in:
Thibault Jouan
2013-07-29 21:07:58 +00:00
parent 30e1930719
commit d199ba56fd
7 changed files with 50 additions and 11 deletions

View File

@@ -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
View 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

View File

@@ -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