Module: Fluent::Config::YamlParser

Defined in:
lib/fluent/config/yaml_parser.rb,
lib/fluent/config/yaml_parser/loader.rb,
lib/fluent/config/yaml_parser/parser.rb,
lib/fluent/config/yaml_parser/fluent_value.rb,
lib/fluent/config/yaml_parser/section_builder.rb

Defined Under Namespace

Modules: FluentValue Classes: Loader, Parser, RootBuilder, SectionBodyBuilder, SectionBuilder

Class Method Summary collapse

Class Method Details

.parse(path) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fluent/config/yaml_parser.rb', line 24

def self.parse(path)
  context = Kernel.binding

  unless context.respond_to?(:use_nil)
    context.define_singleton_method(:use_nil) do
      raise Fluent::SetNil
    end
  end

  unless context.respond_to?(:use_default)
    context.define_singleton_method(:use_default) do
      raise Fluent::SetDefault
    end
  end

  unless context.respond_to?(:hostname)
    context.define_singleton_method(:hostname) do
      Socket.gethostname
    end
  end

  unless context.respond_to?(:worker_id)
    context.define_singleton_method(:worker_id) do
      ENV['SERVERENGINE_WORKER_ID'] || ''
    end
  end

  s = Fluent::Config::YamlParser::Loader.new(context).load(Pathname.new(path))
  Fluent::Config::YamlParser::Parser.new(s).build.to_element
end