From 2ba9e4721b6d96f0b9e66bbb2f8b09c9c413efe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Thu, 2 May 2013 15:10:59 +0200 Subject: Add a dirname function --- lib/puppet/parser/functions/dirname.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/puppet/parser/functions/dirname.rb (limited to 'lib/puppet/parser/functions') 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 : -- cgit v1.2.3