Class: StackedConfig::Orchestrator

Inherits:
SuperStack::Manager
  • Object
show all
Includes:
ProgramDescriptionHelper
Defined in:
lib/stacked_config/orchestrator.rb

Instance Attribute Summary collapse

Attributes included from ProgramDescriptionHelper

#app_description, #app_name, #app_version, #config_file_base_name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ProgramDescriptionHelper

#add_command_line_section, #command_line_help, #describes_application, #detailed_config_files_info, #detailed_layers_info, #rescan_layers

Constructor Details

#initializeOrchestrator

Returns a new instance of Orchestrator.


9
10
11
12
13
14
15
# File 'lib/stacked_config/orchestrator.rb', line 9

def initialize
  super
  self.merge_policy = SuperStack::MergePolicies::FullMergePolicy
  setup_layers
  default_name = self.class.default_config_file_base_name
  describes_application config_file_base_name: default_name, app_name: default_name
end

Instance Attribute Details

#command_line_layerObject (readonly)

Returns the value of attribute command_line_layer


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

def command_line_layer
  @command_line_layer
end

#env_layerObject (readonly)

Returns the value of attribute env_layer


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

def env_layer
  @env_layer
end

#executable_gem_layerObject (readonly)

Returns the value of attribute executable_gem_layer


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

def executable_gem_layer
  @executable_gem_layer
end

#global_layerObject (readonly)

Returns the value of attribute global_layer


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

def global_layer
  @global_layer
end

#project_layerObject (readonly)

Returns the value of attribute project_layer


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

def project_layer
  @project_layer
end

#provided_config_file_layerObject (readonly)

Returns the value of attribute provided_config_file_layer


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

def provided_config_file_layer
  @provided_config_file_layer
end

#system_layerObject (readonly)

Returns the value of attribute system_layer


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

def system_layer
  @system_layer
end

#user_layerObject (readonly)

Returns the value of attribute user_layer


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

def user_layer
  @user_layer
end

Class Method Details

.default_config_file_base_nameObject


18
19
20
# File 'lib/stacked_config/orchestrator.rb', line 18

def self.default_config_file_base_name
  File.basename($PROGRAM_NAME).gsub /\.[^\.]+$/, ''
end

Instance Method Details

#include_env_layer(filter = nil, priority = 70) ⇒ Object


29
30
31
32
33
34
# File 'lib/stacked_config/orchestrator.rb', line 29

def include_env_layer(filter = nil, priority = 70)
  @env_layer = StackedConfig::Layers::EnvLayer.new filter
  env_layer.name = 'Environment variables level'
  env_layer.priority = priority
  self << env_layer
end

#include_gem_layer_for(gem_name, priority = 30) ⇒ Object


36
37
38
39
40
41
42
43
# File 'lib/stacked_config/orchestrator.rb', line 36

def include_gem_layer_for(gem_name, priority = 30)
  gem_layer  = StackedConfig::Layers::GemLayer.new
  gem_layer.gem_name = gem_name
  raise "No config found in gem #{gem_name}" if gem_layer.file_name.nil?
  gem_layer.name = "#{gem_name} Gem configuration level"
  gem_layer.priority = priority
  self << gem_layer
end

#include_project_layer(file_or_directory, project_file_basename = nil, priority = 65) ⇒ Object


22
23
24
25
26
27
# File 'lib/stacked_config/orchestrator.rb', line 22

def include_project_layer(file_or_directory, project_file_basename=nil, priority = 65)
  @project_layer = StackedConfig::Layers::ProjectLayer.new file_or_directory, project_file_basename
  project_layer.name = 'Project level'
  project_layer.priority = priority
  self << project_layer
end