Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Do not include included recipes. #85

Merged
merged 1 commit into from
Feb 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/itamae/recipe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {})
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/itamae/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down