Module: Climatic::ConfigLayers::ProgramDescriptionHelper

Included in:
LayersManager
Defined in:
lib/climatic/config_layers/program_description_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#app_descriptionObject

Returns the value of attribute app_description.



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

def app_description
  @app_description
end

#app_nameObject

Returns the value of attribute app_name.



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

def app_name
  @app_name
end

#app_versionObject

Returns the value of attribute app_version.



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

def app_version
  @app_version
end

#config_file_base_nameObject

Returns the value of attribute config_file_base_name.



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

def config_file_base_name
  @config_file_base_name
end

Instance Method Details

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



8
9
10
# File 'lib/climatic/config_layers/program_description_helper.rb', line 8

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

#command_line_helpObject



79
80
81
# File 'lib/climatic/config_layers/program_description_helper.rb', line 79

def command_line_help
  command_line_layer.help
end

#describes_application(options = {}) ⇒ Object



83
84
85
86
87
88
# File 'lib/climatic/config_layers/program_description_helper.rb', line 83

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



69
70
71
72
73
74
75
76
# File 'lib/climatic/config_layers/program_description_helper.rb', line 69

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



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

def detailed_layers_info
  info, sep = [], '-' * 80
  info << sep
  layers.values.sort {|a, b| a.priority <=> b.priority}.each do |layer|
    info << "#{layer.name} (priority: #{layer.priority})"
    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



37
38
39
40
41
42
43
44
45
# File 'lib/climatic/config_layers/program_description_helper.rb', line 37

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

end