Class: Fluent::Test::Driver::BaseOwned

Inherits:
Base
  • Object
show all
Defined in:
lib/fluent/test/driver/base_owned.rb

Direct Known Subclasses

Formatter, Parser, Storage

Constant Summary

Constants inherited from Base

Fluent::Test::Driver::Base::DEFAULT_TIMEOUT

Instance Attribute Summary collapse

Attributes inherited from Base

#instance, #logs

Instance Method Summary collapse

Methods inherited from Base

#break_if, #broken?, #end_if, #instance_hook_after_started, #instance_hook_before_stopped, #instance_shutdown, #instance_start, #run, #run_actual, #stop?

Constructor Details

#initialize(klass, opts: {}, &block) ⇒ BaseOwned

Returns a new instance of BaseOwned.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fluent/test/driver/base_owned.rb', line 36

def initialize(klass, opts: {}, &block)
  super

  owner = OwnerDummy.new
  if opts
    owner.system_config_override(opts)
  end
  owner.log = TestLogger.new

  if @instance.respond_to?(:owner=)
    @instance.owner = owner
    if opts
      @instance.system_config_override(opts)
    end
  end

  @logs = owner.log.out.logs
  @section_name = ''
end

Instance Attribute Details

#section_nameObject

Returns the value of attribute section_name.



34
35
36
# File 'lib/fluent/test/driver/base_owned.rb', line 34

def section_name
  @section_name
end

Instance Method Details

#configure(conf) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fluent/test/driver/base_owned.rb', line 56

def configure(conf)
  if conf.is_a?(Fluent::Config::Element)
    @config = conf
  elsif conf.is_a?(Hash)
    @config = Fluent::Config::Element.new(@section_name, "", Hash[conf.map{|k,v| [k.to_s, v]}], [])
  else
    @config = Fluent::Config.parse(conf, @section_name, "", syntax: :v1)
  end
  @instance.configure(@config)
  self
end

#configure_v0(conf) ⇒ Object

this is special method for v0 and should be deleted



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fluent/test/driver/base_owned.rb', line 69

def configure_v0(conf)
  if conf.is_a?(Fluent::Config::Element)
    @config = conf
  elsif conf.is_a?(Hash)
    @config = Fluent::Config::Element.new(@section_name, "", Hash[conf.map{|k,v| [k.to_s, v]}], [])
  else
    @config = Fluent::Config.parse(conf, @section_name, "", syntax: :v0)
  end
  @instance.configure(@config)
  self
end