Class: Completely::Config
- Inherits:
-
Object
- Object
- Completely::Config
- Defined in:
- lib/completely/config.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #flat_config ⇒ Object
-
#initialize(config) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(config) ⇒ Config
Returns a new instance of Config.
16 17 18 19 |
# File 'lib/completely/config.rb', line 16 def initialize(config) @options = config.delete('completely_options')&.transform_keys(&:to_sym) || {} @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/completely/config.rb', line 3 def config @config end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/completely/config.rb', line 3 def @options end |
Class Method Details
.load(path) ⇒ Object
12 |
# File 'lib/completely/config.rb', line 12 def load(path) = parse(File.read(path)) |
.parse(str) ⇒ Object
6 7 8 9 10 |
# File 'lib/completely/config.rb', line 6 def parse(str) new YAML.load(str, aliases: true) rescue Psych::Exception => e raise ParseError, "Invalid YAML: #{e.}" end |
.read(io) ⇒ Object
13 |
# File 'lib/completely/config.rb', line 13 def read(io) = parse(io.read) |
Instance Method Details
#flat_config ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/completely/config.rb', line 21 def flat_config result = {} config.each do |root_key, root_list| result.merge! process_key(root_key, root_list) end result end |