From 1064abcb6e7769cb9d51c20d330620ed1c06d6b9 Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Thu, 3 Mar 2011 09:10:36 +0000 Subject: Re-factor. Removed not needed shebang for Ruby. --- load_vars.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'load_vars.rb') diff --git a/load_vars.rb b/load_vars.rb index 0365cf9..c7ebf6c 100644 --- a/load_vars.rb +++ b/load_vars.rb @@ -1,4 +1,3 @@ -#!/usr/bin/env ruby # # load_vars.rb # -- cgit v1.2.3 From 688fd8c1aa17e9b834b0e376ad5f6d16ec8ab370 Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Thu, 3 Mar 2011 09:17:06 +0000 Subject: Fix. Given vim mode line should end with : in order to work. --- load_vars.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'load_vars.rb') diff --git a/load_vars.rb b/load_vars.rb index c7ebf6c..bebe4d8 100644 --- a/load_vars.rb +++ b/load_vars.rb @@ -65,4 +65,4 @@ module Puppet::Parser::Functions end end -# vim: set ts=2 sw=2 et +# vim: set ts=2 sw=2 et : -- cgit v1.2.3 From c5293e630c8c764c66721cbae5fa828b4f213f8b Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Thu, 3 Mar 2011 09:18:12 +0000 Subject: Fix. Should yield empty data structure when given key cannot be found in the hash upon parsing YAML file. --- load_vars.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'load_vars.rb') diff --git a/load_vars.rb b/load_vars.rb index bebe4d8..b39df27 100644 --- a/load_vars.rb +++ b/load_vars.rb @@ -58,7 +58,7 @@ module Puppet::Parser::Functions raise(Puppet::ParseError, "Data in the file `%s' is not a hash" % file) unless data.is_a?(Hash) - data = data[key] if key and data[key].is_a?(Hash) + data = (key and data[key].is_a?(Hash) ? data[key] : {}) end data.each { |param, value| setvar(param, strinterp(value)) } -- cgit v1.2.3 From 19fd344a0fdb22ef6b3c6e80bc8fd4983e56d7cb Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Thu, 3 Mar 2011 13:14:56 +0100 Subject: Fix. The data structure should only be populated and/or set to be empty if and only if key is present. --- load_vars.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'load_vars.rb') diff --git a/load_vars.rb b/load_vars.rb index b39df27..4d0d14e 100644 --- a/load_vars.rb +++ b/load_vars.rb @@ -58,7 +58,7 @@ module Puppet::Parser::Functions raise(Puppet::ParseError, "Data in the file `%s' is not a hash" % file) unless data.is_a?(Hash) - data = (key and data[key].is_a?(Hash) ? data[key] : {}) + data = ((data[key] and data[key].is_a?(Hash)) ? data[key] : {}) if key end data.each { |param, value| setvar(param, strinterp(value)) } -- cgit v1.2.3