Sha256: 602fb7114ac7a88d84d5767ba4b2f08b5c676c96e028f6b8d861af725cc19d83

Contents?: true

Size: 569 Bytes

Versions: 6

Compression:

Stored size: 569 Bytes

Contents

require "csv"

module Dexter
  class CsvLogParser < LogParser
    FIRST_LINE_REGEX = /\A.+/

    def perform
      CSV.new(@logfile.to_io).each do |row|
        if (m = REGEX.match(row[13]))
          # replace first line with match
          # needed for multiline queries
          active_line = row[13].sub(FIRST_LINE_REGEX, m[3])

          add_parameters(active_line, row[14]) if row[14]
          process_entry(active_line, m[1].to_f)
        end
      end
    rescue CSV::MalformedCSVError => e
      raise Dexter::Abort, "ERROR: #{e.message}"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pgdexter-0.4.2 lib/dexter/csv_log_parser.rb
pgdexter-0.4.1 lib/dexter/csv_log_parser.rb
pgdexter-0.4.0 lib/dexter/csv_log_parser.rb
pgdexter-0.3.10 lib/dexter/csv_log_parser.rb
pgdexter-0.3.9 lib/dexter/csv_log_parser.rb
pgdexter-0.3.8 lib/dexter/csv_log_parser.rb