2011-04-29 19:09:39 +02:00
|
|
|
#
|
|
|
|
# lstrip.rb
|
|
|
|
#
|
|
|
|
|
|
|
|
module Puppet::Parser::Functions
|
|
|
|
newfunction(:lstrip, :type => :rvalue, :doc => <<-EOS
|
2011-07-30 00:09:30 +02:00
|
|
|
Strips leading spaces to the left of a string.
|
2011-04-29 19:09:39 +02:00
|
|
|
EOS
|
|
|
|
) do |arguments|
|
|
|
|
|
|
|
|
raise(Puppet::ParseError, "lstrip(): Wrong number of arguments " +
|
|
|
|
"given (#{arguments.size} for 1)") if arguments.size < 1
|
|
|
|
|
|
|
|
value = arguments[0]
|
|
|
|
|
2014-04-22 09:36:28 +02:00
|
|
|
unless value.is_a?(Array) || value.is_a?(String)
|
2011-04-30 00:30:32 +02:00
|
|
|
raise(Puppet::ParseError, 'lstrip(): Requires either ' +
|
2011-04-29 19:09:39 +02:00
|
|
|
'array or string to work with')
|
|
|
|
end
|
|
|
|
|
|
|
|
if value.is_a?(Array)
|
2011-04-30 03:54:47 +02:00
|
|
|
# Numbers in Puppet are often string-encoded which is troublesome ...
|
2011-04-29 19:09:39 +02:00
|
|
|
result = value.collect { |i| i.is_a?(String) ? i.lstrip : i }
|
|
|
|
else
|
|
|
|
result = value.lstrip
|
|
|
|
end
|
|
|
|
|
|
|
|
return result
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# vim: set ts=2 sw=2 et :
|