Method: Chef::Application::Apply#read_recipe_file

Defined in:
lib/chef/application/apply.rb

#read_recipe_file(file_name) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/chef/application/apply.rb', line 185

def read_recipe_file(file_name)
  if file_name.nil?
    Chef::Application.fatal!("No recipe file was provided", Chef::Exceptions::RecipeNotFound.new)
  else
    recipe_path = File.expand_path(file_name)
    unless File.exist?(recipe_path)
      Chef::Application.fatal!("No file exists at #{recipe_path}", Chef::Exceptions::RecipeNotFound.new)
    end
    recipe_fh = open(recipe_path)
    recipe_text = recipe_fh.read
    [recipe_text, recipe_fh]
  end
end