summaryrefslogtreecommitdiff
path: root/puppet/modules/stdlib/lib/puppet/parser/functions/dirname.rb
diff options
context:
space:
mode:
Diffstat (limited to 'puppet/modules/stdlib/lib/puppet/parser/functions/dirname.rb')
-rw-r--r--puppet/modules/stdlib/lib/puppet/parser/functions/dirname.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/puppet/modules/stdlib/lib/puppet/parser/functions/dirname.rb b/puppet/modules/stdlib/lib/puppet/parser/functions/dirname.rb
new file mode 100644
index 00000000..ea8cc1e0
--- /dev/null
+++ b/puppet/modules/stdlib/lib/puppet/parser/functions/dirname.rb
@@ -0,0 +1,15 @@
+module Puppet::Parser::Functions
+ newfunction(:dirname, :type => :rvalue, :doc => <<-EOS
+ Returns the dirname of a path.
+ EOS
+ ) do |arguments|
+
+ raise(Puppet::ParseError, "dirname(): Wrong number of arguments " +
+ "given (#{arguments.size} for 1)") if arguments.size < 1
+
+ path = arguments[0]
+ return File.dirname(path)
+ end
+end
+
+# vim: set ts=2 sw=2 et :