Class: StackedConfig::Layers::GemLayer

Inherits:
GenericLayer
  • Object
show all
Defined in:
lib/stacked_config/layers/gem_layer.rb

Constant Summary

Constants included from SourceHelper

SourceHelper::DEFAULT_OS_FLAVOUR, SourceHelper::EXTENSIONS, SourceHelper::OS_FLAVOURS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from GenericLayer

#initialize, #possible_config_files, #rescan

Methods included from SourceHelper

included, os_flavour, #os_flavour, supported_oses, #supported_oses

Constructor Details

This class inherits a constructor from StackedConfig::Layers::GenericLayer

Instance Attribute Details

#gem_nameObject

Returns the value of attribute gem_name


6
7
8
# File 'lib/stacked_config/layers/gem_layer.rb', line 6

def gem_name
  @gem_name
end

Class Method Details

.gem_config_root(gem_name) ⇒ Object


8
9
10
11
12
13
14
# 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

Instance Method Details

#gem_config_rootObject


16
17
18
# File 'lib/stacked_config/layers/gem_layer.rb', line 16

def gem_config_root
  self.class.gem_config_root gem_name
end

#perform_substitutions(path_part) ⇒ Object


38
39
40
41
42
43
44
# 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_sourcesObject


27
28
29
30
31
32
33
34
35
36
# 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