X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fstrip.rb;h=067af001d68f145ac7e5e4d07b9b401667bfdb79;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hp=3fac47d531d5eb3e4c989769afb9d0120c13a148;hpb=ad88f67c13ae0f1a08936dad643f1e3509ab5f40;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/strip.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/strip.rb index 3fac47d53..067af001d 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/strip.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/strip.rb @@ -1,35 +1,38 @@ # # strip.rb # - module Puppet::Parser::Functions - newfunction(:strip, :type => :rvalue, :doc => <<-EOS -This function removes leading and trailing whitespace from a string or from -every string inside an array. + newfunction(:strip, :type => :rvalue, :doc => <<-DOC + @summary + This function removes leading and trailing whitespace from a string or from + every string inside an array. + + @return + String or Array converted -*Examples:* + @example **Usage** - strip(" aaa ") + strip(" aaa ") + Would result in: "aaa" -Would result in: "aaa" - EOS - ) do |arguments| + > *Note:*: from Puppet 6.0.0, the compatible function with the same name in Puppet core + will be used instead of this function. + DOC + ) do |arguments| - raise(Puppet::ParseError, "strip(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "strip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'strip(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'strip(): Requires either array or string to work with') end - if value.is_a?(Array) - result = value.collect { |i| i.is_a?(String) ? i.strip : i } - else - result = value.strip - end + result = if value.is_a?(Array) + value.map { |i| i.is_a?(String) ? i.strip : i } + else + value.strip + end return result end