Ignore:
Timestamp:
Jul 31, 2017, 6:42:27 PM (9 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
0.5, app-cordova, debian/bullseye, debian/jessie, master
Children:
fc9d514
Parents:
eb1ccd6
Message:

Updated apt and stdlib module to newer versions (stdlib version used by current ntp module)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/puppetcode/environments/gnuboat/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb

    reb1ccd6 rbe0859f  
    11module Puppet::Parser::Functions
     2  newfunction(:loadyaml, :type => :rvalue, :arity => -2, :doc => <<-'ENDHEREDOC') do |args|
     3Load a YAML file containing an array, string, or hash, and return the data
     4in the corresponding native data type.
     5The second parameter is the default value. It will be returned if the file
     6was not found or could not be parsed.
    27
    3   newfunction(:loadyaml, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
    4     Load a YAML file containing an array, string, or hash, and return the data
    5     in the corresponding native data type.
     8For example:
    69
    7     For example:
     10    $myhash = loadyaml('/etc/puppet/data/myhash.yaml')
     11    $myhash = loadyaml('no-file.yaml', {'default' => 'value'})
     12  ENDHEREDOC
    813
    9         $myhash = loadyaml('/etc/puppet/data/myhash.yaml')
    10     ENDHEREDOC
     14    raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless args.length >= 1
     15    require 'yaml'
    1116
    12     unless args.length == 1
    13       raise Puppet::ParseError, ("loadyaml(): wrong number of arguments (#{args.length}; must be 1)")
    14     end
    15 
    16     if File.exists?(args[0]) then
    17       YAML.load_file(args[0])
     17    if File.exists?(args[0])
     18      begin
     19        YAML::load_file(args[0]) || args[1]
     20      rescue Exception => e
     21        if args[1]
     22          args[1]
     23        else
     24          raise e
     25        end
     26      end
    1827    else
    19       warning("Can't load " + args[0] + ". File does not exist!")
    20       nil
     28      warning("Can't load '#{args[0]}' File does not exist!")
     29      args[1]
    2130    end
    2231
Note: See TracChangeset for help on using the changeset viewer.