Sha256: 54111d490508c57c10ebcf6d96e9cb237e5d2226d45d252b64d52870b03798bd
Contents?: true
Size: 923 Bytes
Versions: 2
Compression:
Stored size: 923 Bytes
Contents
class LocalConf < Hash include Hash::Slop def initialize(file) r1 = load file.sub(/\.yml$/, ".defaults.yml") r2 = load file return if r1 || r2 raise Errno::ENOENT, "Missing configuration file #{App.root}/config/#{file.sub(/\.yml$/, "")}{.defaults}.yml}" end private def load(file) data = YAML::load_file("#{App.root}/config/#{file}") data.each { |k,v| update k.to_sym => v } if h = data["defaults"] h.each { |k,v| update k.to_sym => v } end if h = data[App.env] h.each { |k,v| update k.to_sym => v } end true rescue Errno::ENOENT false end def method_missing(sym, *args, &block) return super unless args.empty? && !block_given? && sym.to_s =~ /(.*)\?/ !fetch($1.to_sym).blank? rescue IndexError false end def self.method_missing(sym, *args, &block) App.local_conf.send sym, *args, &block end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vex-0.6.2 | lib/vex/base/local_conf.rb |
vex-0.4.2 | lib/vex/base/local_conf.rb |