30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/itamae/recipe/seasoning.rb', line 30
def include_recipe_with_seasoning(target, &block)
expanded_path = ::File.expand_path(target, File.dirname(@recipe.path))
expanded_path = ::File.join(expanded_path, 'default.rb') if ::Dir.exist?(expanded_path)
expanded_path.concat('.rb') unless expanded_path.end_with?('.rb')
candidate_paths = [expanded_path, Recipe.find_recipe_in_gem(target)].compact
path = candidate_paths.find {|path| File.exist?(path) }
unless path
raise NotFoundError, "Recipe not found. (#{target})"
end
if runner.children.find_recipe_by_path(path)
Itamae.logger.debug "Recipe, #{path}, is skipped because it is already included"
return
end
recipe = Recipe.new(runner, path)
if @recipe.original_recipe
@recipe.original_recipe.children << recipe
else
@recipe.children << recipe
end
if block_given?
recipe.load({}, @recipe, Proc.new(&block))
else
recipe.load({})
end
end
|