From 7c6fa004a6f22bffa46ecf20e143fcc30c46a0ce Mon Sep 17 00:00:00 2001 From: Ryota Arai Date: Sun, 22 Feb 2015 16:56:49 +0900 Subject: [PATCH] [Bugfix] Do not include included recipes. --- lib/itamae/recipe.rb | 16 ++++++++-------- lib/itamae/runner.rb | 4 +++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/itamae/recipe.rb b/lib/itamae/recipe.rb index 602032b0..79b956b2 100644 --- a/lib/itamae/recipe.rb +++ b/lib/itamae/recipe.rb @@ -29,9 +29,11 @@ def initialize(runner, path) @runner = runner @path = path @delayed_notifications = [] + @children = RecipeChildren.new + end - context = EvalContext.new(self) - @children = context.children + def load + EvalContext.new(self) end def run(options = {}) @@ -49,11 +51,8 @@ def run(options = {}) end class EvalContext - attr_reader :children - def initialize(recipe) @recipe = recipe - @children = RecipeChildren.new instance_eval(File.read(@recipe.path), @recipe.path, 1) end @@ -76,7 +75,7 @@ def method_missing(*args, &block) end resource = klass.new(@recipe, name, &block) - @children << resource + @recipe.children << resource end def define(name, params = {}, &block) @@ -104,12 +103,13 @@ def include_recipe(target) end if runner.children.find_recipe_by_path(path) - Logger.debug "Recipe, #{target}, is skipped because it is already included" + Logger.debug "Recipe, #{path}, is skipped because it is already included" return end recipe = Recipe.new(runner, path) - @children << recipe + @recipe.children << recipe + recipe.load end def node diff --git a/lib/itamae/runner.rb b/lib/itamae/runner.rb index aa8cf3b7..1bf9abbc 100644 --- a/lib/itamae/runner.rb +++ b/lib/itamae/runner.rb @@ -101,7 +101,9 @@ def initialize(node) def load_recipes(paths) paths.each do |path| - children << Recipe.new(self, File.expand_path(path)) + recipe = Recipe.new(self, File.expand_path(path)) + children << recipe + recipe.load end end