Sha256: 1eb03f62e9516b96783c4b9b29cf3ab8ebbe3907a3f39c9cb3917c12515927a4

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

require 'r10k/deployment'
require 'r10k/config/loader'

class R10K::Config

  attr_accessor :configfile

  def loaded?
    !(@config.nil?)
  end

  # Serve up the loaded config if it's already been loaded, otherwise try to
  # load a config in the current wd.
  def dump
    load_config unless @config
    @config
  end

  def setting(key)
    self.dump[key]
  end
  alias_method :[], :setting

  # Load and store a config file, and set relevant options
  #
  # @param [String] configfile The path to the YAML config file
  def load_config
    unless @configfile
      loader = R10K::Config::Loader.new
      @configfile = loader.search
    end
    File.open(@configfile) { |fh| @config = YAML.load(fh.read) }
    apply_config_settings
    @config
  end

  private

  # 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::Deployment::EnvironmentCollection.new(@config)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
r10k-0.0.9 lib/r10k/config.rb
r10k-0.0.8 lib/r10k/config.rb
r10k-0.0.7 lib/r10k/config.rb
r10k-0.0.6 lib/r10k/config.rb
r10k-0.0.5 lib/r10k/config.rb
r10k-0.0.4 lib/r10k/config.rb
r10k-0.0.3 lib/r10k/config.rb
r10k-0.0.2 lib/r10k/config.rb