Module: Beeta::Config
- Defined in:
- lib/beeta/config.rb
Constant Summary collapse
- ConfigFile =
%W( #{ENV['BEETA_CONF']} ./beeta.json #{ENV['HOME']}/.beeta.json /etc/beeta.json ).select { |fn| File.exist? fn }.first
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
-
.loaded ⇒ Object
Returns the value of attribute loaded.
Class Method Summary collapse
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
12 13 14 |
# File 'lib/beeta/config.rb', line 12 def config @config end |
.loaded ⇒ Object
Returns the value of attribute loaded.
12 13 14 |
# File 'lib/beeta/config.rb', line 12 def loaded @loaded end |
Class Method Details
.load(fn = nil, force = false) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/beeta/config.rb', line 14 def self.load(fn = nil, force = false) fn ||= ConfigFile return false if(fn.nil? || (!force && loaded)) self.config = JSON.parse File.read(fn) # TODO: When the config solidifies reasonably, get rid of the # overly metaprogrammed bits here, and replace with regular # methods. It's just a little easier for now to be able to add # values to the config file and have the methods appear out of # nowhere. config.each { |k,v| class << self; self; end.module_eval { define_method(k) { v } } } self.loaded = true end |