module Fluent::Config::YamlParser

Constants

SectionBuilder

Public Class Methods

parse(path) click to toggle source
# 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