]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - 3rdparty/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / loadyaml.rb
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb
new file mode 100644 (file)
index 0000000..10c4005
--- /dev/null
@@ -0,0 +1,20 @@
+module Puppet::Parser::Functions
+
+  newfunction(:loadyaml, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
+    Load a YAML file containing an array, string, or hash, and return the data
+    in the corresponding native data type.
+
+    For example:
+
+        $myhash = loadyaml('/etc/puppet/data/myhash.yaml')
+    ENDHEREDOC
+
+    unless args.length == 1
+      raise Puppet::ParseError, ("loadyaml(): wrong number of arguments (#{args.length}; must be 1)")
+    end
+
+    YAML.load_file(args[0])
+
+  end
+
+end