Class: SlowActions::Parser
- Inherits:
-
Object
- Object
- SlowActions::Parser
- Defined in:
- lib/slow_actions_parser.rb
Overview
Text parser for #SlowActions
Instance Method Summary collapse
-
#initialize(file_path, start_date, end_date) ⇒ Parser
constructor
Create a new #Parser file_path: path to log file to parse start_date: Date object.
-
#parse ⇒ Object
Initiate the parsing.
Constructor Details
#initialize(file_path, start_date, end_date) ⇒ Parser
Create a new #Parser
file_path: path to log file to parse
start_date: Date object. Entries before this date are skipped
end_date: Date object. Entries after this date are skipped
Dates are inclusive
12 13 14 15 16 17 18 |
# File 'lib/slow_actions_parser.rb', line 12 def initialize(file_path, start_date, end_date) @file_path = file_path raise "File not found: #{file_path}" unless File.exists? file_path @file = File.new(file_path, 'r') @start_date = start_date @end_date = end_date end |
Instance Method Details
#parse ⇒ Object
Initiate the parsing
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/slow_actions_parser.rb', line 21 def parse @log_entries = [] begin while true line = @file.readline if line =~ /^Processing/ @log_entries << parse_log_entry(line) end end rescue EOFError => ex @file.close end return @log_entries end |