]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Small re-factor.
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Fri, 11 Mar 2011 18:30:49 +0000 (18:30 +0000)
committerKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Fri, 11 Mar 2011 18:30:49 +0000 (18:30 +0000)
load_vars.rb

index cc2495b065660384cdfe618a0dc22d2c7219175c..87effad9ed57c21fc6a027d79b6612da33b7eea3 100644 (file)
@@ -1,3 +1,4 @@
+#
 # load_vars.rb
 #
 # This script will allow for loading variables from an external YAML
@@ -7,19 +8,19 @@
 #
 # Given following content of the data.yaml file:
 #
-#  ---
-#  host1.example.com:
-#    foo: bar
-#    baz: quux
-#    question: 42
-#  host2.example.com:
-#    abc: def
-#    this: that
-#    darth: vader
+#   ---
+#   host1.example.com:
+#     foo: bar
+#     baz: quux
+#     question: 42
+#   host2.example.com:
+#     abc: def
+#     this: that
+#     darth: vader
 #
 # Then calling load_vars in Puppet manifest file as follows:
 #
-#  load_vars("/etc/puppet/data.yaml", $fqdn)
+#   load_vars("/etc/puppet/data.yaml", $fqdn)
 #
 # Will result in addition of variables $foo, $baz and $question
 # for matching host name as per the variable $fqdn ...
 #
 # Given following content of the file data-host1.example.com.yaml:
 #
-#  ---
-#  foo: bar
+#   ---
+#   foo: bar
 #
 # Then when we call load_vars like this:
 #
-#  load_vars("/etc/puppet/data-$fqdn.yaml")
+#   load_vars("/etc/puppet/data-$fqdn.yaml")
 #
 # This will result in a variable $foo being added and ready for use.
 #
@@ -50,12 +51,12 @@ module Puppet::Parser::Functions
       begin
         data = YAML.load_file(file)
       rescue => error
-        raise(Puppet::ParseError,
-          "Unable to load data from the file `%s': %s" % file, error.to_s)
+        raise(Puppet::ParseError, "Unable to load data " +
+          "from the file `%s': %s" % file, error.to_s)
       end
 
-      raise(Puppet::ParseError,
-        "Data in the file `%s' is not a hash" % file) unless data.is_a?(Hash)
+      raise(Puppet::ParseError, "Data in the file `%s' " +
+        "is not a hash" % file) unless data.is_a?(Hash)
 
       data = ((data[key] and data[key].is_a?(Hash)) ? data[key] : {}) if key
     end