lib/chef/recipe.rb in chef-0.7.16 vs lib/chef/recipe.rb in chef-0.8.2
- old
+ new
@@ -19,21 +19,22 @@
require 'chef/resource'
Dir[File.join(File.dirname(__FILE__), 'resource/**/*.rb')].sort.each { |lib| require lib }
require 'chef/mixin/from_file'
require 'chef/mixin/language'
+require 'chef/mixin/language_include_recipe'
require 'chef/mixin/recipe_definition_dsl_core'
require 'chef/resource_collection'
require 'chef/cookbook_loader'
require 'chef/rest'
-require 'chef/search/result'
class Chef
class Recipe
include Chef::Mixin::FromFile
include Chef::Mixin::Language
+ include Chef::Mixin::LanguageIncludeRecipe
include Chef::Mixin::RecipeDefinitionDSLCore
attr_accessor :cookbook_name, :recipe_name, :recipe, :node, :collection,
:definitions, :params, :cookbook_loader
@@ -45,51 +46,11 @@
@definitions = definitions || Hash.new
@cookbook_loader = cookbook_loader || Chef::CookbookLoader.new
@params = Hash.new
end
- def include_recipe(*args)
- args.flatten.each do |recipe|
- if @node.run_state[:seen_recipes].has_key?(recipe)
- Chef::Log.debug("I am not loading #{recipe}, because I have already seen it.")
- next
- end
-
- Chef::Log.debug("Loading Recipe #{recipe} via include_recipe")
- @node.run_state[:seen_recipes][recipe] = true
-
- rmatch = recipe.match(/(.+?)::(.+)/)
- if rmatch
- cookbook = @cookbook_loader[rmatch[1]]
- cookbook.load_recipe(rmatch[2], @node, @collection, @definitions, @cookbook_loader)
- else
- cookbook = @cookbook_loader[recipe]
- cookbook.load_recipe("default", @node, @collection, @definitions, @cookbook_loader)
- end
- end
- end
-
- def require_recipe(*args)
- include_recipe(*args)
- end
-
def resources(*args)
@collection.resources(*args)
- end
-
- def search(type, query, attributes=[], &block)
- Chef::Log.debug("Searching #{type} index with #{query}")
- r = Chef::REST.new(Chef::Config[:search_url])
-
- results = r.get_rest("search/#{type}?q=#{query}&a=#{attributes.join(',')}")
- Chef::Log.debug("Searching #{type} index with #{query} returned #{results.length} entries")
- if block
- results.each do |sr|
- block.call(sr)
- end
- else
- results
- end
end
# Sets a tag, or list of tags, for this node. Syntactic sugar for
# @node[:tags].
#