class Fluent::Plugin::TKGIMetadataParser
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/parser_tkgi_metadata.rb, line 34 def configure(conf) super if @delimiter.length != 1 raise ConfigError, "delimiter must be a single character. #{@delimiter} is not." end end
parse(text) { |nil, record| ... }
click to toggle source
# File lib/fluent/plugin/parser_tkgi_metadata.rb, line 42 def parse(text) # Delete first and last square bracket text.delete_prefix!("[") text.delete_suffix!("]") # Replace any whitespaces with `_` if exists inside the double quotes text.gsub!(/\s+(?=(?:(?:[^"]*"){2})*[^"]*"[^"]*$)/,'_') # Delete any double quotes text.gsub!(/"/,'') source, key_values = text.split(' ', 2) source, id = source.split('@', 2) record = {} key_values.split(' ').each do |kv| k, v = kv.split('=', 2) if @es_mode k.gsub!(/[\.\-\\\/]/, '_') end record[k] = v end record.merge!(source: source, source_id: id) yield nil, record end