Module: Honeycomb::Environment
- Defined in:
- lib/honeycomb/environment.rb
Constant Summary collapse
- CONFIG =
{}
- CFGFILE =
Pathname.new(__FILE__).dirname.dirname.dirname..join('etc').join('config.yml')
Class Method Summary collapse
-
.load_config(hash) ⇒ Object
TODO: Comment.
-
.read_config(file = CFGFILE) ⇒ Object
TODO: Comment.
Class Method Details
.load_config(hash) ⇒ Object
TODO: Comment
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/honeycomb/environment.rb', line 30 def self.load_config(hash) hash.each do |k,v| if v.is_a?(String) v = v.gsub(/\$([A-Z][A-Z0-9_]*)\$/) do |v| var = $1 if const_defined?(var) const_get(var).to_s else raise("Invalid variable referenced in configuration: #{v}") end end end CONFIG[k.to_s] = v end end |
.read_config(file = CFGFILE) ⇒ Object
TODO: Comment
47 48 49 50 51 52 53 54 55 |
# File 'lib/honeycomb/environment.rb', line 47 def self.read_config(file=CFGFILE) if h = YAML.load_file(file) if h.is_a?(Hash) load_config(h) else raise("invalid honeycomb config file format") end end end |