A Recipe object is the context in which Chef recipes are evaluated.
# File lib/chef/recipe.rb, line 66 def initialize(cookbook_name, recipe_name, run_context) @cookbook_name = cookbook_name @recipe_name = recipe_name @run_context = run_context # TODO: 5/19/2010 cw/tim: determine whether this can be removed @params = Hash.new @node = deprecated_ivar(run_context.node, :node, :warn) end
Parses a potentially fully-qualified recipe name into its cookbook name and recipe short name.
For example:
"aws::elastic_ip" returns [:aws, "elastic_ip"] "aws" returns [:aws, "default"]
# File lib/chef/recipe.rb, line 57 def self.parse_recipe_name(recipe_name) rmatch = recipe_name.match(/(.+?)::(.+)/) if rmatch [ rmatch[1].to_sym, rmatch[2] ] else [ recipe_name.to_sym, "default" ] end end
Used in DSL mixins
# File lib/chef/recipe.rb, line 76 def node run_context.node end
Used by the DSL to look up resources when executing in the context of a recipe.
# File lib/chef/recipe.rb, line 82 def resources(*args) run_context.resource_collection.find(*args) end
This was moved to Chef::Node#tag, redirecting here for compatability
# File lib/chef/recipe.rb, line 87 def tag(*tags) run_context.node.tag(*tags) end
Returns true if the node is tagged with all of the supplied tags.
tags<Array> |
A list of tags |
true<TrueClass> |
If all the parameters are present |
false<FalseClass> |
If any of the parameters are missing |
# File lib/chef/recipe.rb, line 99 def tagged?(*tags) tags.each do |tag| return false unless run_context.node[:tags].include?(tag) end true end
Removes the list of tags from the node.
tags<Array> |
A list of tags |
tags<Array> |
The current list of run_context.node |
# File lib/chef/recipe.rb, line 113 def untag(*tags) tags.each do |tag| run_context.node.normal[:tags].delete(tag) end end
Generated with the Darkfish Rdoc Generator 2.