summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/functions')
-rw-r--r--lib/puppet/parser/functions/dirname.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/puppet/parser/functions/dirname.rb b/lib/puppet/parser/functions/dirname.rb
index ea8cc1e..40b300d 100644
--- a/lib/puppet/parser/functions/dirname.rb
+++ b/lib/puppet/parser/functions/dirname.rb
@@ -4,11 +4,17 @@ module Puppet::Parser::Functions
EOS
) do |arguments|
- raise(Puppet::ParseError, "dirname(): Wrong number of arguments " +
- "given (#{arguments.size} for 1)") if arguments.size < 1
+ if arguments.size < 1 then
+ raise(Puppet::ParseError, "dirname(): No arguments given")
+ end
+ if arguments.size > 1 then
+ raise(Puppet::ParseError, "dirname(): Too many arguments given (#{arguments.size})")
+ end
+ unless arguments[0].is_a?(String)
+ raise(Puppet::ParseError, 'dirname(): Requires string as argument')
+ end
- path = arguments[0]
- return File.dirname(path)
+ return File.dirname(arguments[0])
end
end