]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/lib/puppet/parser/functions/dirname.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / dirname.rb
1 module Puppet::Parser::Functions
2   newfunction(:dirname, :type => :rvalue, :doc => <<-EOS
3     Returns the dirname of a path.
4     EOS
5   ) do |arguments|
6
7     if arguments.size < 1 then
8       raise(Puppet::ParseError, "dirname(): No arguments given")
9     end
10     if arguments.size > 1 then
11       raise(Puppet::ParseError, "dirname(): Too many arguments given (#{arguments.size})")
12     end
13     unless arguments[0].is_a?(String)
14       raise(Puppet::ParseError, 'dirname(): Requires string as argument')
15     end
16
17     return File.dirname(arguments[0])
18   end
19 end
20
21 # vim: set ts=2 sw=2 et :