Sha256: 1143342288b620198c03e77ba4f40528971cd2dc0c957f5d0ec4ccdb110ec7a1
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
require 'yaml' require "active_support/all" module Writer class Configuration attr_accessor :template_path, :date_format, :attributes, :log_level, :logger, :namer, :creator def initialize(attrs = {}) attrs = attrs.merge(config) attrs.each do |attr, value| self.send("#{attr}=", value) end @attributes = attrs end def namer=(other) @namer = Object.const_get(other) end def logger=(other) @logger = Object.const_get(other) end def creator=(other) @creator = Object.const_get(other) end private def config conf = default_config path = 'config/writer.yml' if File.exist?(path) config_file = File.open(path) user_config = YAML.load(config_file) conf = conf.merge(user_config) end conf end def default_config { namer: 'Writer::FileNamer', creator: 'Writer::FileCreator', logger: 'Writer::Logger', date_format: '%Y-%m%b-%d', log_level: 2, # see Logger for levels template_path: '' } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
writer-0.4.1.1 | lib/writer/configuration.rb |
writer-0.4.1 | lib/writer/configuration.rb |
writer-0.4.0.1 | lib/writer/configuration.rb |