Sha256: be7258b217768518448abaaa48255501bfe91c4fe531eef00e0e0476595eb965
Contents?: true
Size: 882 Bytes
Versions: 3
Compression:
Stored size: 882 Bytes
Contents
module Puppet::Parser::Functions # convert nil values to :undefined recursively newfunction(:convert, :type => :rvalue) do |args| hash = args[0] data = {} hash.each do |key, value| if value.is_a?(Hash) data[key] = function_convert([value]) else data[key] = value unless value.nil? end end data end newfunction(:loadanyyaml, :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 = loadanyyaml('/etc/puppet/data/myhash.yaml') ENDHEREDOC args.delete_if { |filename| not File.exist? filename } if args.length == 0 raise Puppet::ParseError, ("loadanyyaml(): No files to load") end function_convert([YAML.load_file(args[0])]) end end
Version data entries
3 entries across 3 versions & 1 rubygems