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
22
# File 'lib/completely/config.rb', line 19

def initialize(config)
  @options = config.delete('completely_options')&.transform_keys(&:to_sym) || {}
  @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

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
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



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

def flat_config
  result = {}

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

  result
end