module LogLineParser::Bots

Constants

DEFAULT_BOTS
DEFAULT_CONFIG
DEFAULT_RE

Public Class Methods

compile_bots_re(bots_config=DEFAULT_CONFIG) click to toggle source
# File lib/log_line_parser/bots.rb, line 30
def self.compile_bots_re(bots_config=DEFAULT_CONFIG)
  escaped_re = compile_escaped_re(bots_config)
  re = compile_re(bots_config)
  return Regexp.union(escaped_re, re) if escaped_re && re
  escaped_re || re
end

Private Class Methods

compile_escaped_re(bots_config) click to toggle source
# File lib/log_line_parser/bots.rb, line 37
def self.compile_escaped_re(bots_config)
  bot_names = bots_config[ConfigLabels::BOTS] || []
  if bots_config[ConfigLabels::INHERIT_DEFAULT_BOTS]
    bot_names = (DEFAULT_BOTS + bot_names).uniq
  end
  return if bot_names.empty?
  escaped_bots_str = bot_names.map {|name| Regexp.escape(name) }.join("|")
  Regexp.compile(escaped_bots_str, Regexp::IGNORECASE, "n")
end
compile_re(bots_config) click to toggle source
# File lib/log_line_parser/bots.rb, line 47
def self.compile_re(bots_config)
  bots_pats = bots_config[ConfigLabels::BOTS_RE]
  Regexp.compile(bots_pats.join("|"), nil, "n") if bots_pats
end