Module: AmberbitConfig
- Defined in:
- lib/amberbit-config.rb,
lib/amberbit-config/config.rb,
lib/amberbit-config/engine.rb,
lib/amberbit-config/errors.rb,
lib/amberbit-config/version.rb,
lib/amberbit-config/hash_struct.rb
Defined Under Namespace
Classes: Config, ConfigNotSetError, Engine, HashArgumentError, HashStruct
Constant Summary collapse
- VERSION =
'1.1.0'
Class Method Summary collapse
-
.initialize(default_file, config_file) ⇒ Object
Initialize AppConfig variable with default file path and custom file path if it wasn’t set yet.
-
.initialize_within(root_path) ⇒ Object
Run initialze with default file names within root_path.
-
.path_from(root_path, file) ⇒ Object
Gets path from root_path and file name, i.e.
Class Method Details
.initialize(default_file, config_file) ⇒ Object
Initialize AppConfig variable with default file path and custom file path if it wasn’t set yet.
9 10 11 12 13 14 15 |
# File 'lib/amberbit-config.rb', line 9 def self.initialize(default_file, config_file) return unless File.exist?(default_file) return if defined?(AppConfig) config = Config.new default_file, config_file Object.const_set 'AppConfig', HashStruct.create(config.data) end |
.initialize_within(root_path) ⇒ Object
Run initialze with default file names within root_path
18 19 20 |
# File 'lib/amberbit-config.rb', line 18 def self.initialize_within(root_path) initialize path_from(root_path, 'app_config_default.yml'), path_from(root_path, 'app_config.yml') end |
.path_from(root_path, file) ⇒ Object
Gets path from root_path and file name, i.e. path_from File.dirname(__FILE__), 'app_config.yml'
24 25 26 |
# File 'lib/amberbit-config.rb', line 24 def self.path_from(root_path, file) File. File.join(File.dirname(root_path), 'config', file) end |