class Fluent::Config::YamlParser::Loader
Constants
- FLUENT_JSON_TAG
- FLUENT_STR_TAG
- INCLUDE_TAG
- SHOVEL
Public Class Methods
new(context = Kernel.binding)
click to toggle source
# File lib/fluent/config/yaml_parser/loader.rb, line 33 def initialize(context = Kernel.binding) @context = context @current_path = nil end
Public Instance Methods
eval_include(path, parent)
click to toggle source
# File lib/fluent/config/yaml_parser/loader.rb, line 63 def eval_include(path, parent) if path.relative? pattern = parent.join(path) else pattern = path end result = [] Dir.glob(pattern).sort.each do |path| result.concat(load(Pathname.new(path))) end result rescue SystemCallError => e parse_error = ConfigParseError.new("include error #{path} - #{e}") parse_error.set_backtrace(e.backtrace) raise parse_error end
load(path)
click to toggle source
@param [String] path @return [Hash]
# File lib/fluent/config/yaml_parser/loader.rb, line 40 def load(path) class_loader = Psych::ClassLoader.new scanner = Psych::ScalarScanner.new(class_loader) visitor = Visitor.new(scanner, class_loader) visitor._register_domain(INCLUDE_TAG) do |_, val| eval_include(Pathname.new(val), path.parent) end visitor._register_domain(FLUENT_JSON_TAG) do |_, val| Fluent::Config::YamlParser::FluentValue::JsonValue.new(val) end visitor._register_domain(FLUENT_STR_TAG) do |_, val| Fluent::Config::YamlParser::FluentValue::StringValue.new(val, @context) end path.open do |f| visitor.accept(Psych.parse(f)) end end