Changed wording of the note in the comment.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
This commit is contained in:
Krzysztof Wilczynski 2011-04-30 02:54:47 +01:00
parent db7a27cf5b
commit 4da6d8222e
7 changed files with 69 additions and 4 deletions

2
abs.rb
View file

@ -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

View 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

View 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.chomp : i }
else
result = value.chomp

View 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.chop : i }
else
result = value.chop

32
downcase.rb Normal file
View file

@ -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 :

View file

@ -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

32
upcase.rb Normal file
View file

@ -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 :