class Itamae::Recipe::EvalContext

Public Instance Methods

include_recipe(target, &block)
include_recipe_with_seasoning(target, &block) click to toggle source
# 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
Also aliased as: include_recipe
include_recipe_without_seasoning(target, &block)
Alias for: include_recipe
include_seasoning() click to toggle source
# File lib/itamae/recipe/seasoning.rb, line 23
def include_seasoning
  if @recipe.seasoning
    context = EvalContext.new(@recipe.parent_recipe, {})
    context.instance_eval(&@recipe.seasoning)
  end
end