Class: Steenzout::ConfigurationManager
- Inherits:
-
Object
- Object
- Steenzout::ConfigurationManager
- Defined in:
- lib/cfg/manager.rb
Overview
Class to hold gem configurations.
Class Method Summary collapse
-
.configuration_for_gem(name) ⇒ Object
Returns the configuration for the given gem.
-
.load(filename) ⇒ Object
Loads the configuration from the given file.
Class Method Details
.configuration_for_gem(name) ⇒ Object
Returns the configuration for the given gem.
46 47 48 |
# File 'lib/cfg/manager.rb', line 46 def self.configuration_for_gem name @configurations[:"#{name}"] end |
.load(filename) ⇒ Object
Loads the configuration from the given file. As convention, the configuration file should have as top symbol the gem name.
Example:
:steenzout-cfg:
:log: 'log/development.log'
Warning: loading a configuration file which hold configurations for a previous loaded gem,
will cause the previous configuration to be lost.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cfg/manager.rb', line 22 def self.load filename raise ArgumentError, "File #{filename} does not exist!" if !File.exist? filename if @configurations.nil? # load configuration @configurations = YAML.load_file(filename) else # merge existing configurations YAML.load_file(filename).each {|key, value| @configurations[key] = value } end # TODO: for each gem name, store from which file the configuration was loaded... end |