summaryrefslogtreecommitdiff
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorAdrien Thebo <git@somethingsinistral.net>2013-05-02 15:17:32 -0700
committerAdrien Thebo <git@somethingsinistral.net>2013-05-02 15:17:32 -0700
commit0c68ff6d66960424567f15711cb20b674fc60054 (patch)
treeb5b1528e5b7f1c17c20d2aca2c569a641e44b689 /lib/puppet/parser
parent0aa7e942f4bdcd51d7af827618288c662e0cb8e4 (diff)
parent2ba9e4721b6d96f0b9e66bbb2f8b09c9c413efe2 (diff)
Merge pull request #150 from raphink/dev/dirname_function
Add a dirname function
Diffstat (limited to 'lib/puppet/parser')
-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 :