Small re-factor.
This commit is contained in:
parent
36ec2c36ea
commit
49d208a13e
1 changed files with 18 additions and 17 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
#
|
||||||
# load_vars.rb
|
# load_vars.rb
|
||||||
#
|
#
|
||||||
# This script will allow for loading variables from an external YAML
|
# This script will allow for loading variables from an external YAML
|
||||||
|
@ -50,12 +51,12 @@ module Puppet::Parser::Functions
|
||||||
begin
|
begin
|
||||||
data = YAML.load_file(file)
|
data = YAML.load_file(file)
|
||||||
rescue => error
|
rescue => error
|
||||||
raise(Puppet::ParseError,
|
raise(Puppet::ParseError, "Unable to load data " +
|
||||||
"Unable to load data from the file `%s': %s" % file, error.to_s)
|
"from the file `%s': %s" % file, error.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
raise(Puppet::ParseError,
|
raise(Puppet::ParseError, "Data in the file `%s' " +
|
||||||
"Data in the file `%s' is not a hash" % file) unless data.is_a?(Hash)
|
"is not a hash" % file) unless data.is_a?(Hash)
|
||||||
|
|
||||||
data = ((data[key] and data[key].is_a?(Hash)) ? data[key] : {}) if key
|
data = ((data[key] and data[key].is_a?(Hash)) ? data[key] : {}) if key
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue