4 module Puppet::Parser::Functions
5 newfunction(:dirname, :type => :rvalue, :doc => <<-DOC
7 Returns the dirname of a path.
9 @return [String] the given path's dirname
14 raise(Puppet::ParseError, 'dirname(): No arguments given')
17 raise(Puppet::ParseError, "dirname(): Too many arguments given (#{arguments.size})")
19 unless arguments[0].is_a?(String)
20 raise(Puppet::ParseError, 'dirname(): Requires string as argument')
22 # undef is converted to an empty string ''
23 if arguments[0].empty?
24 raise(Puppet::ParseError, 'dirname(): Requires a non-empty string as argument')
27 return File.dirname(arguments[0])
31 # vim: set ts=2 sw=2 et :