Class: Completely::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/completely/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Config

Returns a new instance of Config.



19
20
21
# File 'lib/completely/config.rb', line 19

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/completely/config.rb', line 3

def config
  @config
end

Class Method Details

.load(config_path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/completely/config.rb', line 6

def load(config_path)
  begin
    config = YAML.load_file config_path, aliases: true
  rescue ArgumentError
    # :nocov:
    config = YAML.load_file config_path
    # :nocov:
  end

  new config
end

Instance Method Details

#flat_configObject



23
24
25
26
27
28
29
30
31
# File 'lib/completely/config.rb', line 23

def flat_config
  result = {}

  config.each do |root_key, root_list|
    result.merge! process_key(root_key, root_list)
  end

  result
end