Class: Metrician::Configuration
- Inherits:
-
Object
- Object
- Metrician::Configuration
- Defined in:
- lib/metrician/configuration.rb
Constant Summary collapse
- FileMissing =
Class.new(StandardError)
Class Method Summary collapse
- .app_locations ⇒ Object
- .config_locations ⇒ Object
- .env_location ⇒ Object
- .gem_location ⇒ Object
- .load ⇒ Object
- .reset_dependents ⇒ Object
Class Method Details
.app_locations ⇒ Object
30 31 32 33 34 35 |
# File 'lib/metrician/configuration.rb', line 30 def self.app_locations [ File.join(Dir.pwd, "config", "metrician.yaml"), File.join(Dir.pwd, "config", "metrician.yml"), ] end |
.config_locations ⇒ Object
17 18 19 |
# File 'lib/metrician/configuration.rb', line 17 def self.config_locations [env_location, *app_locations, gem_location].compact end |
.env_location ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/metrician/configuration.rb', line 21 def self.env_location path = ENV["METRICIAN_CONFIG"] if path && !File.exist?(path) # this should never raise unless a bad ENV setting has been set raise(FileMissing.new(path)) end path end |
.gem_location ⇒ Object
37 38 39 |
# File 'lib/metrician/configuration.rb', line 37 def self.gem_location File.("../../../metrician.defaults.yaml", __FILE__) end |
.load ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/metrician/configuration.rb', line 7 def self.load reset_dependents config = {} config_locations.reverse.each do |location| config.deep_merge!(YAML.load_file(location)) if File.exist?(location) end config end |