Class: Fluent::Compat::TextParser::RegexpParser

Inherits:
Plugin::RegexpParser show all
Includes:
TypeConverterCompatParameters
Defined in:
lib/fluent/compat/parser.rb

Constant Summary

Constants inherited from Plugin::Parser

Plugin::Parser::AVAILABLE_PARSER_VALUE_TYPES, Plugin::Parser::PARSER_TYPES, Plugin::Parser::TRUTHY_VALUES

Constants included from Fluent::Configurable

Fluent::Configurable::CONFIG_TYPE_REGISTRY

Instance Attribute Summary

Attributes inherited from Plugin::Parser

#type_converters

Attributes inherited from Plugin::Base

#under_plugin_development

Instance Method Summary collapse

Methods included from TypeConverterCompatParameters

#convert_type_converter_parameters!

Methods inherited from Plugin::RegexpParser

#parse

Methods inherited from Plugin::Parser

#build_type_converters, #call, #convert_values, #implement?, #parse, #parse_io, #parse_partial_data, #parse_time, #parse_with_timeout, #parser_type, #start, #stop, #string_like_null

Methods included from TimeMixin::Parser

included, #time_parser_create

Methods included from Plugin::OwnedByMixin

#log, #owner, #owner=

Methods inherited from Plugin::Base

#acquire_worker_lock, #after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #called_in_test?, #close, #closed?, #configured?, #context_router, #context_router=, #fluentd_worker_id, #get_lock_path, #has_router?, #inspect, #multi_workers_ready?, #plugin_root_dir, #reloadable_plugin?, #shutdown, #shutdown?, #start, #started?, #stop, #stopped?, #string_safe_encoding, #terminate, #terminated?

Methods included from SystemConfig::Mixin

#system_config, #system_config_override

Methods included from Fluent::Configurable

#config, #configure_proxy_generate, #configured_section_create, included, lookup_type, register_type

Constructor Details

#initialize(regexp, conf = {}) ⇒ RegexpParser

TODO: warn when deprecated



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/fluent/compat/parser.rb', line 151

def initialize(regexp, conf = {})
  super()

  @stored_regexp = regexp
  @manually_configured = false
  unless conf.empty?
    conf_init = if conf.is_a?(Fluent::Config::Element)
                  conf
                else
                  Fluent::Config::Element.new('parse', '', conf, [])
                end
    self.configure(conf_init)
    @manually_configured = true
  end
end

Instance Method Details

#configure(conf) ⇒ Object



167
168
169
170
171
172
173
174
175
176
# File 'lib/fluent/compat/parser.rb', line 167

def configure(conf)
  return if @manually_configured # not to run twice

  conf['expression'] ||= @stored_regexp.source
  conf['ignorecase'] ||= @stored_regexp.options & Regexp::IGNORECASE != 0
  conf['multiline'] ||= @stored_regexp.options & Regexp::MULTILINE != 0
  convert_type_converter_parameters!(conf)

  super
end

#patternsObject



178
179
180
# File 'lib/fluent/compat/parser.rb', line 178

def patterns
  {'format' => @regexp, 'time_format' => @time_format}
end