summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/mixin/from_file.rb17
-rw-r--r--lib/chef/recipe.rb21
2 files changed, 21 insertions, 17 deletions
diff --git a/lib/chef/mixin/from_file.rb b/lib/chef/mixin/from_file.rb
index 94e3144f9f..b8300340c7 100644
--- a/lib/chef/mixin/from_file.rb
+++ b/lib/chef/mixin/from_file.rb
@@ -37,23 +37,6 @@ class Chef
end
end
- # This will return an array of hashes or something that then needs to get inflated.
- def from_yaml_file(filename)
- self.source_file = filename
- if File.file?(filename) && File.readable?(filename)
- res = ::YAML.safe_load(IO.read(filename))
- if res.is_a?(Hash)
- from_hash(res)
- elsif res.is_a?(Array)
- from_array(res)
- else
- raise "boom"
- end
- else
- raise IOError, "Cannot open or read #{filename}!"
- end
- end
-
# Loads a given ruby file, and runs class_eval against it in the context of the current
# object.
#
diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb
index 95b69532f8..ddb45de8e3 100644
--- a/lib/chef/recipe.rb
+++ b/lib/chef/recipe.rb
@@ -85,7 +85,28 @@ class Chef
end
end
+ def from_yaml_file(filename)
+ self.source_file = filename
+ if File.file?(filename) && File.readable?(filename)
+ from_yaml(IO.read(filename))
+ else
+ raise IOError, "Cannot open or read #{filename}!"
+ end
+ end
+
+ def from_yaml(string)
+ res = ::YAML.safe_load(string)
+ if res.is_a?(Hash)
+ from_hash(res)
+ elsif res.is_a?(Array)
+ from_array(res)
+ else
+ raise "boom"
+ end
+ end
+
def from_array(array)
+ Chef::Log.warn "array yaml files are super duper experimental behavior"
array.each { |e| from_hash(e) }
end