Sha256: 0afecf00f32f49a5fb57950966cb59500d6b814f225d6537c59e46622b1653c7
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
#require 'helper' require 'csv' require 'open-uri' #require 'seedreader' #require 'csvseedreader' #require 'sqlseedreader' #require 'xmlseedreader' #require 'jsonseedreader' module I2X ## # = CSVDetector # # Detect changes in CSV files (using column numbers). # class CSVDetector < Detector public ## # == Detect the changes # def detect object begin CSV.new(open(object[:uri]), :headers => :first_row).each do |row| unless object[:cache].nil? then @cache = Cashier.verify row[object[:cache].to_i], object, row, object[:seed] else @cache = Cashier.verify row[0], object, row, object[:seed] end # The actual processing # if @cache[:status] == 100 then # add row data to payload from selectors (key => key, value => column name) payload = Hash.new JSON.parse(object[:selectors]).each do |selector| selector.each do |k,v| payload[k] = row[v.to_i] end end # add payload object to payloads list @payloads.push payload end end rescue Exception => e I2X::Slog.exception e end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
i2x-0.0.4 | lib/i2x/csvdetector.rb |