summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions
diff options
context:
space:
mode:
authorRaphaël Pinson <raphael.pinson@camptocamp.com>2013-05-02 15:10:59 +0200
committerRaphaël Pinson <raphael.pinson@camptocamp.com>2013-05-02 15:17:35 +0200
commit2ba9e4721b6d96f0b9e66bbb2f8b09c9c413efe2 (patch)
treeb5b1528e5b7f1c17c20d2aca2c569a641e44b689 /lib/puppet/parser/functions
parent0aa7e942f4bdcd51d7af827618288c662e0cb8e4 (diff)
Add a dirname function
Diffstat (limited to 'lib/puppet/parser/functions')
-rw-r--r--lib/puppet/parser/functions/dirname.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/dirname.rb b/lib/puppet/parser/functions/dirname.rb
new file mode 100644
index 0000000..ea8cc1e
--- /dev/null
+++ b/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 :