lib/r10k/deployment.rb in r10k-0.0.1rc1 vs lib/r10k/deployment.rb in r10k-0.0.1

- old
+ new

@@ -1,8 +1,8 @@ require 'r10k' require 'r10k/synchro/git' -require 'r10k/environment_collection' +require 'r10k/deployment/environment_collection' require 'yaml' class R10K::Deployment # Model a full installation of module directories and modules. @@ -19,14 +19,18 @@ # Load up all module roots # # @return [Array<R10K::Root>] def environments - collection = R10K::EnvironmentCollection.new(config) collection.to_a end + def collection + load_config unless @config + @collection + end + # Serve up the loaded config if it's already been loaded, otherwise try to # load a config in the current wd. def config load_config unless @config @config @@ -45,16 +49,15 @@ # @param [String] configfile The path to the YAML config file def load_config File.open(@configfile) { |fh| @config = YAML.load(fh.read) } apply_config_settings @config - rescue => e - raise "Couldn't load #{configfile}: #{e}" end # Apply config settings to the relevant classes after a config has been loaded. def apply_config_settings if @config[:cachedir] R10K::Synchro::Git.cache_root = @config[:cachedir] end + @collection = R10K::EnvironmentCollection.new(@config) end end