Sha256: 887295430d7ec870f9d7c644f35634bf6a66430ab733314abaa058346122eeb4

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

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

    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

    def parse
      @parser.parse
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pipio-0.0.2 lib/pipio/parsers/text_log_parser.rb
pipio-0.0.1 lib/pipio/parsers/text_log_parser.rb