class StackedConfig::Layers::GemLayer

Attributes

gem_name[R]

Public Class Methods

gem_config_root(gem_name) click to toggle source
# File lib/stacked_config/layers/gem_layer.rb, line 8
def self.gem_config_root(gem_name)
  return nil unless gem_name
  Gem.loaded_specs.each_pair do |name, spec|
    return spec.full_gem_path if name == gem_name
  end
  nil
end

Public Instance Methods

gem_config_root() click to toggle source
# File lib/stacked_config/layers/gem_layer.rb, line 16
def gem_config_root
  self.class.gem_config_root gem_name
end
gem_name=(gem_name) click to toggle source
# File lib/stacked_config/layers/gem_layer.rb, line 21
def gem_name=(gem_name)
  @gem_name = gem_name.to_s
  rescan
  reload
end
perform_substitutions(path_part) click to toggle source
# File lib/stacked_config/layers/gem_layer.rb, line 38
def perform_substitutions path_part
  return nil unless gem_config_root
  res = path_part.dup
  res.gsub! '##GEM_CONFIG_ROOT##', gem_config_root
  res.gsub! '##GEM_NAME##', gem_name if self.respond_to? :gem_name
  res
end
possible_sources() click to toggle source
# File lib/stacked_config/layers/gem_layer.rb, line 27
def possible_sources
  [
      %w(##GEM_CONFIG_ROOT## etc ##GEM_NAME##.##EXTENSION##),
      %w(##GEM_CONFIG_ROOT## etc ##GEM_NAME## config.##EXTENSION##),
      %w(##GEM_CONFIG_ROOT## etc ##GEM_NAME## ##GEM_NAME##.##EXTENSION##),
      %w(##GEM_CONFIG_ROOT## config ##GEM_NAME##.##EXTENSION##),
      %w(##GEM_CONFIG_ROOT## config ##GEM_NAME## config.##EXTENSION##),
      %w(##GEM_CONFIG_ROOT## config ##GEM_NAME## ##GEM_NAME##.##EXTENSION##)
  ]
end