Sha256: 3e1e30753fb14dbad8fd9ab046bc123f9391c5a581895d531fd3dc77739345af
Contents?: true
Size: 1.13 KB
Versions: 5
Compression:
Stored size: 1.13 KB
Contents
require 'singleton' require 'ostruct' require 'yaml' require 'logger' require 'pstore' module FeedTorrents def self.configuration Configuration.instance end def self.logger configuration.logger end class Configuration include Singleton def yaml_from_file(file) set_config YAML.load_file(File.expand_path(file)) nil end def set_config(hash) @source = OpenStruct.new(hash) end def logger @logger ||= create_logger end def method_missing(method, *args, &block) @source.send(method, *args, &block) end def filter_testing=(value) @filter_testing = !!value end def filter_testing? @filter_testing end private def source @source ||= OpenStruct.new end def create_logger if self.log && self.log[:out] == 'STDOUT' || filter_testing? obj = Logger.new(STDOUT) else obj = Logger.new(File.expand_path(self.log[:out]), self.log[:rotate], self.log[:size]) obj.level = Logger.const_get(self.log[:level]) obj.datetime_format = self.log[:format] end obj end end end
Version data entries
5 entries across 5 versions & 1 rubygems