Class: Ossert::Config
- Inherits:
-
Object
- Object
- Ossert::Config
- Defined in:
- lib/ossert/config.rb
Constant Summary collapse
- CONFIG_ROOT =
File.join(File.dirname(__FILE__), '..', '..', 'config')
- CONST_NAME =
'Settings'
Class Method Summary collapse
-
.load(*configs) ⇒ Object
TODO: use ERB, needed for Time syntetics.
Class Method Details
.load(*configs) ⇒ Object
TODO: use ERB, needed for Time syntetics
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ossert/config.rb', line 10 def self.load(*configs) config_data = configs.each_with_object({}) do |config, result| if (path = File.join(CONFIG_ROOT, "#{config}.yml")) && File.exist?(path.to_s) result.merge! YAML.load(IO.read(path.to_s)) end end Kernel.send(:remove_const, CONST_NAME) if Kernel.const_defined?(CONST_NAME) Kernel.const_set(CONST_NAME, config_data) rescue Psych::SyntaxError => e raise "YAML syntax error occurred while parsing #{path}. " \ "Error: #{e.message}" end |