class Fluent::Plugin::RegexpParser
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
Fluent::Plugin::Parser#configure
# File lib/fluent/plugin/parser_regexp.rb, line 33 def configure(conf) super # For compat layer if @ignorecase || @multiline options = 0 options |= Regexp::IGNORECASE if @ignorecase options |= Regexp::MULTILINE if @multiline @expression = Regexp.compile(@expression.source, options) end @regexp = @expression # For backward compatibility if @expression.named_captures.empty? raise Fluent::ConfigError, "No named captures in 'expression' parameter. The regexp must have at least one named capture" end end
parse(text) { |nil, nil| ... }
click to toggle source
# File lib/fluent/plugin/parser_regexp.rb, line 49 def parse(text) m = @expression.match(text) unless m yield nil, nil return end r = {} m.names.each do |name| if value = m[name] r[name] = value end end time, record = convert_values(parse_time(r), r) yield time, record end