Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / strip.rb
index 3fac47d..067af00 100644 (file)
@@ -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