diff --git a/lib/r10k/source/hash.rb b/lib/r10k/source/hash.rb index f96057222..1f3ed7d16 100644 --- a/lib/r10k/source/hash.rb +++ b/lib/r10k/source/hash.rb @@ -126,8 +126,8 @@ class R10K::Source::Hash < R10K::Source::Base # @return [Boolean] False if the hash is obviously invalid. A true return # means _maybe_ it's valid. def self.valid_environments_hash?(hash) - # TODO: more robust schema valiation - hash.is_a?(Hash) + # TODO: more robust schema valiation + hash.is_a?(Hash) end # @param name [String] The identifier for this source. @@ -143,6 +143,10 @@ def initialize(name, basedir, options = {}) super(name, basedir, options) end + # Set the environment hash for the source. The environment hash is what the + # source uses to generate enviroments. + # @param hash [Hash] The hash to sanitize and use as the source's environments. + # Should be formatted for use with R10K::Environment#from_hash. def set_environments_hash(hash) @environments_hash = hash.reduce({}) do |memo,(name,opts)| R10K::Util::SymbolizeKeys.symbolize_keys!(opts) @@ -155,8 +159,11 @@ def set_environments_hash(hash) end end + # Return the sanitized environments hash for this source. The environments + # hash should contain objects formatted for use with R10K::Environment#from_hash. + # If the hash does not exist it will be built based on @options. def environments_hash - @environments_hash ||= set_environments_hash(@options.delete(:environments) || {}) + @environments_hash ||= set_environments_hash(@options.fetch(:environments, {})) end def environments