Module: StackedConfig::ProgramDescriptionHelper

Included in:
Orchestrator
Defined in:
lib/stacked_config/program_description_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#app_descriptionObject

Returns the value of attribute app_description


4
5
6
# File 'lib/stacked_config/program_description_helper.rb', line 4

def app_description
  @app_description
end

#app_nameObject

Returns the value of attribute app_name


4
5
6
# File 'lib/stacked_config/program_description_helper.rb', line 4

def app_name
  @app_name
end

#app_versionObject

Returns the value of attribute app_version


4
5
6
# File 'lib/stacked_config/program_description_helper.rb', line 4

def app_version
  @app_version
end

#config_file_base_nameObject

Returns the value of attribute config_file_base_name


4
5
6
# File 'lib/stacked_config/program_description_helper.rb', line 4

def config_file_base_name
  @config_file_base_name
end

Instance Method Details

#add_command_line_section(title = 'Script specific', &block) ⇒ Object


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

def add_command_line_section(title='Script specific', &block)
  command_line_layer.add_command_line_section title, &block
end

#command_line_helpObject


77
78
79
# File 'lib/stacked_config/program_description_helper.rb', line 77

def command_line_help
  command_line_layer.help
end

#describes_application(options = {}) ⇒ Object


81
82
83
84
85
86
# File 'lib/stacked_config/program_description_helper.rb', line 81

def describes_application(options = {})
  self.app_name = options.fetch(:app_name, nil)
  self.app_version = options.fetch(:app_version, nil)
  self.app_description = options.fetch(:app_description, nil)
  self.config_file_base_name = options.fetch(:config_file_base_name, nil)
end

#detailed_config_files_infoObject


67
68
69
70
71
72
73
74
# File 'lib/stacked_config/program_description_helper.rb', line 67

def detailed_config_files_info
  merger = SuperStack::Manager.new
  merger.merge_policy = SuperStack::MergePolicies::FullMergePolicy
  layers.values.each do |layer|
    merger << layer.possible_config_files if layer.respond_to? :possible_config_files
  end
  merger[]
end

#detailed_layers_infoObject


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/stacked_config/program_description_helper.rb', line 46

def detailed_layers_info
  info, sep = [], '-' * 80
  info << sep
  layers.values.sort {|a, b| a.priority <=> b.priority}.each do |layer|
    info << layer.name
    if layer.file_name.nil?
      info << 'There is no file attached to this level.'
    else
      info << "Using '#{layer.file_name}' as config file for this layer."
    end
    if layer.empty?
      info << 'There is no data in this layer'
    else
      info << 'This layer contains the following data:'
      info << layer.to_yaml
    end
    info << sep
  end
  info.join "\n"
end

#rescan_layersObject


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

def rescan_layers
  layers.values.each do |layer|
    if layer.respond_to? :rescan
      layer.clear
      layer.rescan
    end
  end

end