summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2011-04-30 02:54:47 +0100
committerKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2011-04-30 02:54:47 +0100
commit4da6d8222eeca060ad91c9a49f965ec1150a37c2 (patch)
treecd1d49007085dfaebe9d52b9bd5c7be03723b8da
parentdb7a27cf5b0cb5667b17e2cbc686bff4be3966b7 (diff)
downloadpuppet-stdlib-4da6d8222eeca060ad91c9a49f965ec1150a37c2.tar.gz
puppet-stdlib-4da6d8222eeca060ad91c9a49f965ec1150a37c2.tar.bz2
Changed wording of the note in the comment.
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
-rw-r--r--abs.rb2
-rw-r--r--capitalize.rb2
-rw-r--r--chomp.rb2
-rw-r--r--chop.rb2
-rw-r--r--downcase.rb32
-rw-r--r--lstrip.rb1
-rw-r--r--upcase.rb32
7 files changed, 69 insertions, 4 deletions
diff --git a/abs.rb b/abs.rb
index c3e90d4..0a554e4 100644
--- 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
diff --git a/capitalize.rb b/capitalize.rb
index ac6cc50..f902cb3 100644
--- a/capitalize.rb
+++ b/capitalize.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.capitalize : i }
else
result = value.capitalize
diff --git a/chomp.rb b/chomp.rb
index aba9e8d..e1d788a 100644
--- 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 32ce040..0f9af86 100644
--- 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
index 0000000..71f8480
--- /dev/null
+++ b/downcase.rb
@@ -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 :
diff --git a/lstrip.rb b/lstrip.rb
index 241b683..a7b2656 100644
--- 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
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 :