class Fluent::Test::FormatterTestDriver

Attributes

config[R]
instance[R]

Public Class Methods

new(klass_or_str, proc=nil, &block) click to toggle source
# File lib/fluent/test/formatter_test.rb, line 23
def initialize(klass_or_str, proc=nil, &block)
  if klass_or_str.is_a?(Class)
    if block
      # Create new class for test w/ overwritten methods
      #   klass.dup is worse because its ancestors does NOT include original class name
      klass_or_str = Class.new(klass_or_str)
      klass_or_str.module_eval(&block)
    end
    @instance = klass_or_str.new
  elsif klass_or_str.is_a?(String)
    @instance = TextFormatter::TEMPLATE_REGISTRY.lookup(klass_or_str).call
  else
    @instance = klass_or_str
  end
  @config = Config.new
end

Public Instance Methods

configure(conf) click to toggle source
# File lib/fluent/test/formatter_test.rb, line 42
def configure(conf)
  case conf
  when Fluent::Config::Element
    @config = conf
  when String
    @config = Config.parse(conf, 'fluent.conf')
  when Hash
    @config = Config::Element.new('ROOT', '', conf, [])
  else
    raise "Unknown type... #{conf}"
  end
  @instance.configure(@config)
  self
end
format(tag, time, record) click to toggle source
# File lib/fluent/test/formatter_test.rb, line 57
def format(tag, time, record)
  @instance.format(tag, time, record)
end