Sha256: afa8a4dd011a9a76d6fd0d92d1026d5cf2b4028a15e2e2e928e111c31c80622d

Contents?: true

Size: 630 Bytes

Versions: 7

Compression:

Stored size: 630 Bytes

Contents

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

    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

    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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pgdexter-0.5.5 lib/dexter/csv_log_parser.rb
pgdexter-0.5.4 lib/dexter/csv_log_parser.rb
pgdexter-0.5.3 lib/dexter/csv_log_parser.rb
pgdexter-0.5.2 lib/dexter/csv_log_parser.rb
pgdexter-0.5.1 lib/dexter/csv_log_parser.rb
pgdexter-0.5.0 lib/dexter/csv_log_parser.rb
pgdexter-0.4.3 lib/dexter/csv_log_parser.rb