diff options
author | Ken Barber <ken@bob.sh> | 2011-06-29 21:21:55 +0100 |
---|---|---|
committer | Ken Barber <ken@bob.sh> | 2011-06-29 21:21:55 +0100 |
commit | 790818116e953118ba9eab5e5bef6d63f7bbc1fa (patch) | |
tree | 3f56e221af94f481159a6848338c9f31d3b31e72 /lib/puppet/parser/functions/load_json.rb | |
parent | e071b05ab631f4b73fed7178c52d0416f7629cb8 (diff) |
Added tests for each function, fixing functions as we hit bugs.
Diffstat (limited to 'lib/puppet/parser/functions/load_json.rb')
-rw-r--r-- | lib/puppet/parser/functions/load_json.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/load_json.rb b/lib/puppet/parser/functions/load_json.rb index 9ec8c78..7c3f187 100644 --- a/lib/puppet/parser/functions/load_json.rb +++ b/lib/puppet/parser/functions/load_json.rb @@ -6,6 +6,18 @@ module Puppet::Parser::Functions newfunction(:load_json, :type => :rvalue, :doc => <<-EOS EOS ) do |arguments| + + if (arguments.size != 1) then + raise(Puppet::ParseError, "load_json(): Wrong number of arguments "+ + "given #{arguments.size} for 1") + end + + json = arguments[0] + + require 'json' + + JSON.load(json) + end end |