Sha256: fe10b96975e90fb1f2893c7cce007b593250f4ff9584a591ea39cf4144eecfc4

Contents?: true

Size: 747 Bytes

Versions: 8

Compression:

Stored size: 747 Bytes

Contents

require 'r10k'

class R10K::Config
end

class R10K::Config::Loader

  def initialize
    @loadpath = []

    populate_loadpath
  end

  # @return [String] The path to the first valid configfile
  def search
    first = @loadpath.find {|filename| File.file? filename}
  end

  private

  def populate_loadpath

    # Scan all parent directories for r10k
    dir_components = Dir.getwd.split(File::SEPARATOR)

    dir_components.each_with_index do |dirname, index|
      full_path = [''] # Shim case for root directory
      full_path << dir_components[0...index]
      full_path << dirname << 'r10k.yaml'

      @loadpath << File.join(full_path)
    end

    # Always check /etc/r10k.yaml
    @loadpath << '/etc/r10k.yaml'

    @loadpath
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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