X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fsort.rb;h=a6e0509dcf84e867736ba36b1b2c628be4d27548;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hp=cefbe5463b48de6d63b76c42a88e3b31b4cc14f9;hpb=ad88f67c13ae0f1a08936dad643f1e3509ab5f40;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/sort.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/sort.rb index cefbe5463..a6e0509dc 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/sort.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/sort.rb @@ -1,26 +1,30 @@ # -# sort.rb +# sort.rb +# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. # - module Puppet::Parser::Functions - newfunction(:sort, :type => :rvalue, :doc => <<-EOS -Sorts strings and arrays lexically. - EOS - ) do |arguments| + newfunction(:sort, :type => :rvalue, :doc => <<-DOC + @summary + Sorts strings and arrays lexically. + + @return + sorted string or array - if (arguments.size != 1) then - raise(Puppet::ParseError, "sort(): Wrong number of arguments "+ - "given #{arguments.size} for 1") + Note that from Puppet 6.0.0 the same function in Puppet will be used instead of this. + DOC + ) do |arguments| + + if arguments.size != 1 + raise(Puppet::ParseError, "sort(): Wrong number of arguments given #{arguments.size} for 1") end value = arguments[0] - if value.is_a?(Array) then + if value.is_a?(Array) value.sort - elsif value.is_a?(String) then - value.split("").sort.join("") + elsif value.is_a?(String) + value.split('').sort.join('') end - end end