class Marsdawn::Config
Public Class Methods
new(file='./config/marsdawn.yml')
click to toggle source
# File lib/marsdawn/config.rb, line 5 def initialize file='./config/marsdawn.yml' file = File.absolute_path(file) raise "Cannot find a config file for marsdawn." unless File.exists?(file) @config = YAML.load_file(file) end
Public Instance Methods
each() { |key, to_hash(key)| ... }
click to toggle source
# File lib/marsdawn/config.rb, line 25 def each @config.keys.each do |key| yield key, to_hash(key) end end
get(key, entry, default=nil)
click to toggle source
# File lib/marsdawn/config.rb, line 11 def get key, entry, default=nil conf = to_hash(key) conf[entry] = default if !default.nil? && !conf.key?(entry) raise "No entry '#{entry}' in the setting file of marsdawn." unless conf.key?(entry) ret = conf[entry] ret = Marsdawn::Util.hash_symbolize_keys(ret) if ret.kind_of?(Hash) ret end
to_hash(key)
click to toggle source
# File lib/marsdawn/config.rb, line 20 def to_hash key raise "Cannot find the configuration for '#{key}' in marsdawn.yml." unless @config.key?(key) Marsdawn::Util.hash_symbolize_keys(@config[key]) end