X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fparseyaml.rb;h=5d081e6a62c801f85b0a559928b484b76c08f3fa;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hp=ba9d98aa9c14d1370056d18ebd542b8871f06940;hpb=6963202b4b62c2816655ac9532521b018fdf83bd;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb index ba9d98aa9..5d081e6a6 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb @@ -1,32 +1,32 @@ # # parseyaml.rb # - module Puppet::Parser::Functions - newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS -This function accepts YAML as a string and converts it into the correct -Puppet structure. + newfunction(:parseyaml, :type => :rvalue, :doc => <<-DOC + @summary + This function accepts YAML as a string and converts it into the correct + Puppet structure. + + @return + converted YAML into Puppet structure -The optional second argument can be used to pass a default value that will -be returned if the parsing of YAML string have failed. - EOS - ) do |arguments| + > *Note:* + The optional second argument can be used to pass a default value that will + be returned if the parsing of YAML string have failed. + DOC + ) do |arguments| raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless arguments.length >= 1 require 'yaml' begin - YAML::load(arguments[0]) || arguments[1] + YAML.load(arguments[0]) || arguments[1] # rubocop:disable Security/YAMLLoad : using YAML.safe_load causes the code to break # in ruby 1.9.3 Psych::SyntaxError is a RuntimeException # this still needs to catch that and work also on rubies that # do not have Psych available. - rescue StandardError, Psych::SyntaxError => e - if arguments[1] - arguments[1] - else - raise e - end + rescue StandardError, Psych::SyntaxError => e # rubocop:disable Lint/ShadowedException : See above + raise e unless arguments[1] + arguments[1] end - end end