Class: Aardi::Config

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

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



5
6
7
# File 'lib/aardi/config.rb', line 5

def initialize
  @data = {}
end

Instance Method Details

#[](key) ⇒ Object



9
# File 'lib/aardi/config.rb', line 9

def [](key) = @data[key]

#load(path) ⇒ Object



11
12
13
14
# File 'lib/aardi/config.rb', line 11

def load(path)
  config_yaml = File.read path
  prepare config_yaml
end

#prepare(config_yaml) ⇒ Object

:reek:TooManyStatements



17
18
19
20
21
22
23
24
# File 'lib/aardi/config.rb', line 17

def prepare(config_yaml)
  config_hash = YAML.safe_load config_yaml
  config_hash.transform_keys!(&:to_sym)
  config_hash[:markup_options]&.transform_keys!(&:to_sym)
  @data.merge!(config_hash)
  @data.freeze
  self
end