Sha256: ed4db4b212c3d1eb12134da85a8e3cff843b24d3888958b1f095bd1b749ec2a7
Contents?: true
Size: 1.1 KB
Versions: 4
Compression:
Stored size: 1.1 KB
Contents
require 'yaml' require 'hashie/mash' class Alerty class Config class << self attr_reader :opts def configure(opts) @opts = opts end def config_path @config_path ||= opts[:config_path] || ENV['ALERTY_CONFIG_PATH'] || '/etc/alerty/alerty.yml' end def config @config ||= Hashie::Mash.new(YAML.load_file(config_path)) end def log_path opts[:log_path] || config.log_path || 'STDOUT' end def log_level opts[:log_level] || config.log_level || 'warn' end def timeout opts[:timeout] || config.timeout end def lock_path opts[:lock_path] || config.lock_path end def plugins @plugins ||= config.fetch('plugins').map do |plugin| require "alerty/plugin/#{plugin.type}" class_name = "Alerty::Plugin::#{StringUtil.camelize(plugin.type)}" Object.const_get(class_name).new(plugin) end end # for debug def reset @config_path = nil @config = nil @plugins = nil end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
alerty-0.0.8 | lib/alerty/config.rb |
alerty-0.0.7 | lib/alerty/config.rb |
alerty-0.0.6 | lib/alerty/config.rb |
alerty-0.0.5 | lib/alerty/config.rb |