Class: Dexter::CsvLogParser

Inherits:
LogParser show all
Defined in:
lib/dexter/csv_log_parser.rb

Constant Summary collapse

FIRST_LINE_REGEX =
/\A.+/

Constants inherited from LogParser

LogParser::REGEX

Constants included from Logging

Logging::COLOR_CODES

Instance Method Summary collapse

Methods inherited from LogParser

#initialize

Methods included from Logging

#colorize, #log, #output

Constructor Details

This class inherits a constructor from Dexter::LogParser

Instance Method Details

#performObject



5
6
7
8
9
10
11
# File 'lib/dexter/csv_log_parser.rb', line 5

def perform
  CSV.new(@logfile.to_io).each do |row|
    process_csv_row(row[13], row[14])
  end
rescue CSV::MalformedCSVError => e
  raise Dexter::Abort, "ERROR: #{e.message}"
end

#process_csv_row(message, detail) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/dexter/csv_log_parser.rb', line 13

def process_csv_row(message, detail)
  if (m = REGEX.match(message))
    # replace first line with match
    # needed for multiline queries
    active_line = message.sub(FIRST_LINE_REGEX, m[3])

    add_parameters(active_line, detail) if detail
    process_entry(active_line, m[1].to_f)
  end
end