Module: Pangea::Config
- Defined in:
- lib/pangea/config.rb
Constant Summary collapse
- CONFIG_PATHS =
File paths in increasing order of priority.
[ '/etc/pangea/config.yml', File.('~/.config/pangea/config.yml'), 'pangea.yml' ].freeze
Class Method Summary collapse
-
.config ⇒ Object
Public: Returns a memoized configuration Hash.
-
.load_config ⇒ Object
Loads and deep-merges available YAML configuration files.
Class Method Details
.config ⇒ Object
Public: Returns a memoized configuration Hash. The configuration is lazily loaded and deep-merged so that:
-
Keys in pangea.yml override keys in ~/.config/pangea/config.yml
-
Keys in ~/.config/pangea/config.yml override keys in /etc/pangea/config.yml
11 12 13 |
# File 'lib/pangea/config.rb', line 11 def config @config ||= load_config end |
.load_config ⇒ Object
Loads and deep-merges available YAML configuration files.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pangea/config.rb', line 23 def load_config merged = {} CONFIG_PATHS.each do |file_path| if File.exist?(file_path) data = YAML.load_file(file_path) merged = Pangea::Utils.deep_merge(merged, data) if data.is_a?(Hash) end end merged end |