From 0eea8ac101fdd6dbbe67c2406c3e742ae81a1c4c Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Sat, 12 Mar 2011 23:05:56 +0000 Subject: [PATCH] Check for the number of arguments given. --- load_vars.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/load_vars.rb b/load_vars.rb index 87effad..02e99a0 100644 --- a/load_vars.rb +++ b/load_vars.rb @@ -40,11 +40,19 @@ # module Puppet::Parser::Functions - newfunction(:load_vars, :type => :statement) do |args| + newfunction(:load_vars, :type => :statement) do |arguments| + + number_of_arguments = arguments.size + + if number_of_arguments < 2 + raise(Puppet::ParseError, "Wrong number of arguments " + + "given (#{number_of_arguments} for 2)") + end + data = {} - file = args[0] - key = args[1] if args[1] + file = arguments[0] + key = arguments[1] if arguments[1] if File.exists?(file)