]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Changed wording of the note in the comment.
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Sat, 30 Apr 2011 01:54:47 +0000 (02:54 +0100)
committerKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Sat, 30 Apr 2011 01:54:47 +0000 (02:54 +0100)
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
abs.rb
capitalize.rb
chomp.rb
chop.rb
downcase.rb [new file with mode: 0644]
lstrip.rb
upcase.rb [new file with mode: 0644]

diff --git a/abs.rb b/abs.rb
index c3e90d401cc13c7e2d70898a45d0efa2ed3a36ee..0a554e4f2302b7c30a77b1d57a4d0a078e5f9f66 100644 (file)
--- a/abs.rb
+++ b/abs.rb
@@ -12,7 +12,7 @@ module Puppet::Parser::Functions
 
     value = arguments[0]
 
-    # Numbers in Puppet are often string-encoded ...
+    # Numbers in Puppet are often string-encoded which is troublesome ...
     if value.is_a?(String)
       if value.match(/^-?(?:\d+)(?:\.\d+){1}$/)
         value = value.to_f
index ac6cc50d28c6e8edf54c60386925629c4fe08571..f902cb34806badb9a5ed4027174a159e5af53517 100644 (file)
@@ -19,7 +19,7 @@ module Puppet::Parser::Functions
     end
 
     if value.is_a?(Array)
-      # Numbers in Puppet are often string-encoded ...
+      # Numbers in Puppet are often string-encoded which is troublesome ...
       result = value.collect { |i| i.is_a?(String) ? i.capitalize : i }
     else
       result = value.capitalize
index aba9e8decc63a964b039540af7986504bb2f195e..e1d788a6ee6af29d8e12531b9155b3d4ac30e8a8 100644 (file)
--- a/chomp.rb
+++ b/chomp.rb
@@ -19,7 +19,7 @@ module Puppet::Parser::Functions
     end
 
     if value.is_a?(Array)
-      # Numbers in Puppet are often string-encoded ...
+      # Numbers in Puppet are often string-encoded which is troublesome ...
       result = value.collect { |i| i.is_a?(String) ? i.chomp : i }
     else
       result = value.chomp
diff --git a/chop.rb b/chop.rb
index 32ce040008fea1ec23815212511edbe6837d2918..0f9af868e78c6434a3c8e9b844720fb60acf4039 100644 (file)
--- a/chop.rb
+++ b/chop.rb
@@ -19,7 +19,7 @@ module Puppet::Parser::Functions
     end
 
     if value.is_a?(Array)
-      # Numbers in Puppet are often string-encoded ...
+      # Numbers in Puppet are often string-encoded which is troublesome ...
       result = value.collect { |i| i.is_a?(String) ? i.chop : i }
     else
       result = value.chop
diff --git a/downcase.rb b/downcase.rb
new file mode 100644 (file)
index 0000000..71f8480
--- /dev/null
@@ -0,0 +1,32 @@
+#
+#  downcase.rb
+#
+
+module Puppet::Parser::Functions
+  newfunction(:downcase, :type => :rvalue, :doc => <<-EOS
+    EOS
+  ) do |arguments|
+
+    raise(Puppet::ParseError, "downcase(): Wrong number of arguments " +
+      "given (#{arguments.size} for 1)") if arguments.size < 1
+
+    value = arguments[0]
+    klass = value.class
+
+    unless [Array, String].include?(klass)
+      raise(Puppet::ParseError, 'downcase(): Requires either ' +
+        'array or string to work with')
+    end
+
+    if value.is_a?(Array)
+      # Numbers in Puppet are often string-encoded which is troublesome ...
+      result = value.collect { |i| i.is_a?(String) ? i.downcase : i }
+    else
+      result = value.downcase
+    end
+
+    return result
+  end
+end
+
+# vim: set ts=2 sw=2 et :
index 241b68355251427aef334e9162f83944f5061006..a7b26565e5d1ec1a9b1cbc004e7f5b6f6cb7427a 100644 (file)
--- a/lstrip.rb
+++ b/lstrip.rb
@@ -19,6 +19,7 @@ module Puppet::Parser::Functions
     end
 
     if value.is_a?(Array)
+      # Numbers in Puppet are often string-encoded which is troublesome ...
       result = value.collect { |i| i.is_a?(String) ? i.lstrip : i }
     else
       result = value.lstrip
diff --git a/upcase.rb b/upcase.rb
new file mode 100644 (file)
index 0000000..8a9769d
--- /dev/null
+++ b/upcase.rb
@@ -0,0 +1,32 @@
+#
+# upcase.rb
+#
+
+module Puppet::Parser::Functions
+  newfunction(:upcase, :type => :rvalue, :doc => <<-EOS
+    EOS
+  ) do |arguments|
+
+    raise(Puppet::ParseError, "upcase(): Wrong number of arguments " +
+      "given (#{arguments.size} for 1)") if arguments.size < 1
+
+    value = arguments[0]
+    klass = value.class
+
+    unless [Array, String].include?(klass)
+      raise(Puppet::ParseError, 'upcase(): Requires either ' +
+        'array or string to work with')
+    end
+
+    if value.is_a?(Array)
+      # Numbers in Puppet are often string-encoded which is troublesome ...
+      result = value.collect { |i| i.is_a?(String) ? i.upcase : i }
+    else
+      result = value.upcase
+    end
+
+    return result
+  end
+end
+
+# vim: set ts=2 sw=2 et :