Sha256: 09e7c08e93365100f1daa0db08c5a81cf7849aa4799044661f26f5a6fd561d1b
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
require 'csv' require 'open-uri' module I2X ## # = CSVDetector # # Detect changes in CSV files (using column numbers). # class CSVDetector < Detector public ## # == Detect the changes # def detect object I2X::Config.log.debug(self.class.name) {"Monitoring #{object[:uri]}"} CSV.new(open(object[:uri]), :headers => :first_row).each do |row| begin unless object[:cache].nil? then @response = Cashier.verify row[object[:cache].to_i], object, row, object[:seed] else @response = Cashier.verify row[0], object, row, object[:seed] end rescue Exception => e I2X::Config.log.error(self.class.name) {"Loading error: #{e}"} end begin # Process i2xcache response @cache = JSON.parse(@response, {:symbolize_names => true}) unless @cache[:templates].nil? then @cache[:templates].each do |t| @templates.push t end end # The actual processing # if @cache[:cache][:status] == 100 then I2X::Config.log.info(self.class.name) {"Not on cache, generating payload"} payload = Hash.new 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 rescue Exception => e I2X::Config.log.error(self.class.name) {"Processing error: #{e}"} end @cache[:templates] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
i2x-0.1.1 | lib/i2x/csvdetector.rb |
i2x-0.1 | lib/i2x/csvdetector.rb |
i2x-0.0.7 | lib/i2x/csvdetector.rb |