Sha256: 8381f1ae5c6c5d58b3db71c666feb9694b01c18451a499ca52c130edad512541
Contents?: true
Size: 941 Bytes
Versions: 3
Compression:
Stored size: 941 Bytes
Contents
require 'yaml' module Configuration # we don't want to instantiate this class - it's a singleton, # so just keep it as a self-extended module extend self @settings = {} attr_reader :settings def load!(filename, options = {}) begin @settings = symbolize_keys(YAML::load_file(filename)) rescue Errno::ENOENT puts "[FATAL] configuration file '#{filename}' not found. Exiting."; exit 1 rescue Psych::SyntaxError puts "[FATAL] configuration file '#{filename}' contains invalid syntax. Exiting."; exit 1 end end def symbolize_keys(hash) hash.inject({}){|result, (key, value)| new_key = case key when String then key.to_sym else key end new_value = case value when Hash then symbolize_keys(value) else value end result[new_key] = new_value result } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
webhookd-0.0.9 | lib/webhookd/configuration.rb |
webhookd-0.0.8 | lib/webhookd/configuration.rb |
webhookd-0.0.7 | lib/webhookd/configuration.rb |