Class: Pipio::TextLogParser
- Inherits:
-
Object
- Object
- Pipio::TextLogParser
- 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
-
#initialize(source_file_path, user_aliases) ⇒ TextLogParser
constructor
A new instance of TextLogParser.
- #parse ⇒ Object
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
#parse ⇒ Object
17 18 19 |
# File 'lib/pipio/parsers/text_log_parser.rb', line 17 def parse @parser.parse end |