Method: Chef::Recipe#from_yaml_file

Defined in:
lib/chef/recipe.rb

#from_yaml_file(filename) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/chef/recipe.rb', line 81

def from_yaml_file(filename)
  self.source_file = filename
  if File.file?(filename) && File.readable?(filename)
    yaml_contents = IO.read(filename)
    if ::YAML.load_stream(yaml_contents).length > 1
      raise ArgumentError, "YAML recipe '#{filename}' contains multiple documents, only one is supported"
    end

    from_yaml(yaml_contents)
  else
    raise IOError, "Cannot open or read file '#{filename}'!"
  end
end