Class: Pipio::TextLogParser

Inherits:
Object
  • Object
show all
Defined in:
lib/pipio/parsers/text_log_parser.rb

Constant Summary collapse

TIMESTAMP_REGEX =
'\((?<timestamp>\d{1,2}:\d{1,2}:\d{1,2})\)'

Instance Method Summary collapse

Constructor Details

#initialize(source_file_path, user_aliases) ⇒ TextLogParser

Returns a new instance of TextLogParser.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/pipio/parsers/text_log_parser.rb', line 5

def initialize(source_file_path, user_aliases)
  # @line_regex matches a line in a text log file other than the first.
  line_regex = /#{TIMESTAMP_REGEX} (?<sn_or_alias>.*?) ?(?<auto_reply><AUTO-REPLY>)?: (?<body>.*)/o
  # @line_regex_status matches a status or event line.
  line_regex_status = /#{TIMESTAMP_REGEX} (?<body>[^:]+)/o

  cleaner = Cleaners::TextCleaner

  @parser = BasicParser.new(source_file_path, user_aliases, line_regex,
    line_regex_status, cleaner)
end

Instance Method Details

#parseObject



17
18
19
# File 'lib/pipio/parsers/text_log_parser.rb', line 17

def parse
  @parser.parse
end