Class: StackedConfig::Layers::UserLayer

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

Constant Summary

Constants included from SourceHelper

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

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

Class Method Details

.user_config_rootObject



7
8
9
# File 'lib/stacked_config/layers/user_layer.rb', line 7

def self.user_config_root
  Dir.home
end

Instance Method Details

#perform_substitutions(path_part) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/stacked_config/layers/user_layer.rb', line 27

def perform_substitutions path_part
  res = path_part.dup
  res.gsub! '##USER_CONFIG_ROOT##', user_config_root

  exec_name = manager.nil? ? StackedConfig::Orchestrator.default_config_file_base_name : manager.config_file_base_name
  res.gsub! '##PROGRAM_NAME##', exec_name

  res
end

#possible_sourcesObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/stacked_config/layers/user_layer.rb', line 16

def possible_sources
  [
      ['##USER_CONFIG_ROOT##', '.##PROGRAM_NAME##.##EXTENSION##' ],
      ['##USER_CONFIG_ROOT##', '.config', '##PROGRAM_NAME##.##EXTENSION##' ],
      ['##USER_CONFIG_ROOT##', '.config', '##PROGRAM_NAME##', 'config.##EXTENSION##' ],
      ['##USER_CONFIG_ROOT##', '.config', '##PROGRAM_NAME##', '##PROGRAM_NAME##.##EXTENSION##' ],
      ['##USER_CONFIG_ROOT##', '.##PROGRAM_NAME##', 'config.##EXTENSION##' ],
      ['##USER_CONFIG_ROOT##', '.##PROGRAM_NAME##', '##PROGRAM_NAME##.##EXTENSION##' ]
  ]
end

#user_config_rootObject



11
12
13
# File 'lib/stacked_config/layers/user_layer.rb', line 11

def user_config_root
  self.class.user_config_root
end