X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fsize.rb;h=2002a3df5872c2f3ad8fcdb889dddbb412c24412;hb=131e09855e065be940e104d9ab0f18940cc76257;hp=b503aa09e1f958443cdc6a02faa77df6c928c822;hpb=407d322498f4fde815abf381007fbecfe5c10b2b;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/size.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/size.rb index b503aa09e..2002a3df5 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/size.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/size.rb @@ -1,14 +1,16 @@ # # size.rb # - module Puppet::Parser::Functions - newfunction(:size, :type => :rvalue, :doc => <<-EOS -Returns the number of elements in a string, an array or a hash - EOS - ) do |arguments| + newfunction(:size, :type => :rvalue, :doc => <<-DOC + Returns the number of elements in a string, an array or a hash + + Note that since Puppet 5.4.0, the length() function in Puppet is preferred over this. For versions + of Puppet < 5.4.0 use the stdlib length() function. + DOC + ) do |arguments| - raise(Puppet::ParseError, "size(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "size(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? item = arguments[0] @@ -28,7 +30,6 @@ Returns the number of elements in a string, an array or a hash Float(item) raise(Puppet::ParseError, 'size(): Requires either string, array or hash to work with') - rescue ArgumentError result = item.size end