diff --git a/lib/puppet/parser/functions/lstrip.rb b/lib/puppet/parser/functions/lstrip.rb index 16e0006..62c73f1 100644 --- a/lib/puppet/parser/functions/lstrip.rb +++ b/lib/puppet/parser/functions/lstrip.rb @@ -1,37 +1,37 @@ # frozen_string_literal: true # # lstrip.rb # module Puppet::Parser::Functions newfunction(:lstrip, type: :rvalue, doc: <<-DOC @summary **Deprecated:** Strips leading spaces to the left of a string. @return [String] The stripped string > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a - built-in [`max`](https://puppet.com/docs/puppet/latest/function.html#max) function. + built-in [`lstrip`](https://puppet.com/docs/puppet/latest/function.html#lstrip) function. DOC ) do |arguments| raise(Puppet::ParseError, "lstrip(): 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, 'lstrip(): Requires either array or string to work with') end result = if value.is_a?(Array) # Numbers in Puppet are often string-encoded which is troublesome ... value.map { |i| i.is_a?(String) ? i.lstrip : i } else value.lstrip end return result end end # vim: set ts=2 sw=2 et : diff --git a/lib/puppet/parser/functions/max.rb b/lib/puppet/parser/functions/max.rb index 173dc0e..b0eac16 100644 --- a/lib/puppet/parser/functions/max.rb +++ b/lib/puppet/parser/functions/max.rb @@ -1,32 +1,32 @@ # frozen_string_literal: true # # max.rb # module Puppet::Parser::Functions newfunction(:max, type: :rvalue, doc: <<-DOC @summary **Deprecated:** Returns the highest value of all arguments. Requires at least one argument. @return The highest value among those passed in > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a - built-in [`lstrip`](https://puppet.com/docs/puppet/latest/function.html#lstrip) function. + built-in [`max`](https://puppet.com/docs/puppet/latest/function.html#max) function. DOC ) do |args| raise(Puppet::ParseError, 'max(): Wrong number of arguments need at least one') if args.empty? # Sometimes we get numbers as numerics and sometimes as strings. # We try to compare them as numbers when possible return args.max do |a, b| if a.to_s =~ %r{\A-?\d+(.\d+)?\z} && b.to_s =~ %r{\A-?\d+(.\d+)?\z} a.to_f <=> b.to_f else a.to_s <=> b.to_s end end end end