Class: Mysticonfig::Loader
- Inherits:
-
Object
- Object
- Mysticonfig::Loader
- Defined in:
- lib/mysticonfig.rb
Overview
Configuration loader.
Instance Method Summary collapse
-
#initialize(appname) ⇒ Loader
constructor
A new instance of Loader.
-
#load ⇒ Object
Find and load config file.
-
#load_json ⇒ Object
Find and load JSON config file.
-
#load_yaml ⇒ Object
Find and load YAML config file.
Constructor Details
#initialize(appname) ⇒ Loader
Returns a new instance of Loader.
9 10 11 |
# File 'lib/mysticonfig.rb', line 9 def initialize(appname) @filenames = Utils.generate_config_filenames appname end |
Instance Method Details
#load ⇒ Object
Find and load config file.
15 16 17 18 19 |
# File 'lib/mysticonfig.rb', line 15 def load config_file = find_file @filenames Utils.load_auto config_file end |
#load_json ⇒ Object
Find and load JSON config file.
23 24 25 26 27 |
# File 'lib/mysticonfig.rb', line 23 def load_json json_config_file = Utils.lookup_file @filenames[:json] Utils.load_json json_config_file end |
#load_yaml ⇒ Object
Find and load YAML config file.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mysticonfig.rb', line 31 def load_yaml yaml_config_files = @filenames[:yaml] yaml_config_file = nil yaml_config_files.each do |file| yaml_config_file = Utils.lookup_file file return Utils.load_yaml(yaml_config_file) unless yaml_config_file.nil? end {} # Return empty hash when can't load config file end |