class Itamae::Recipe::EvalContext
Public Class Methods
new(recipe, vars)
click to toggle source
# File lib/itamae/recipe.rb, line 87 def initialize(recipe, vars) @recipe = recipe vars.each do |k, v| define_singleton_method(k) { v } end end
Public Instance Methods
define(name, params = {}, &block)
click to toggle source
# File lib/itamae/recipe.rb, line 116 def define(name, params = {}, &block) Resource.define_resource(name, Definition.create_class(name, params, @recipe, &block)) end
include_recipe(target)
click to toggle source
# File lib/itamae/recipe.rb, line 120 def include_recipe(target) 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) @recipe.children << recipe recipe.load end
method_missing(*args, &block)
click to toggle source
Calls superclass method
# File lib/itamae/recipe.rb, line 102 def method_missing(*args, &block) super unless args.size == 2 method, name = args begin klass = Resource.get_resource_class(method) rescue NameError super end resource = klass.new(@recipe, name, &block) @recipe.children << resource end
node()
click to toggle source
# File lib/itamae/recipe.rb, line 141 def node runner.node end
respond_to_missing?(method, include_private = false)
click to toggle source
# File lib/itamae/recipe.rb, line 95 def respond_to_missing?(method, include_private = false) Resource.get_resource_class(method) true rescue NameError false end
run_command(*args)
click to toggle source
# File lib/itamae/recipe.rb, line 149 def run_command(*args) runner.backend.run_command(*args) end
runner()
click to toggle source
# File lib/itamae/recipe.rb, line 145 def runner @recipe.runner end