2013-05-02 15:10:59 +02:00
|
|
|
module Puppet::Parser::Functions
|
|
|
|
newfunction(:dirname, :type => :rvalue, :doc => <<-EOS
|
|
|
|
Returns the dirname of a path.
|
|
|
|
EOS
|
|
|
|
) do |arguments|
|
|
|
|
|
2014-11-18 19:34:55 +01:00
|
|
|
if arguments.size < 1 then
|
|
|
|
raise(Puppet::ParseError, "dirname(): No arguments given")
|
|
|
|
end
|
|
|
|
if arguments.size > 1 then
|
|
|
|
raise(Puppet::ParseError, "dirname(): Too many arguments given (#{arguments.size})")
|
|
|
|
end
|
|
|
|
unless arguments[0].is_a?(String)
|
|
|
|
raise(Puppet::ParseError, 'dirname(): Requires string as argument')
|
|
|
|
end
|
2013-05-02 15:10:59 +02:00
|
|
|
|
2014-11-18 19:34:55 +01:00
|
|
|
return File.dirname(arguments[0])
|
2013-05-02 15:10:59 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# vim: set ts=2 sw=2 et :
|