Sha256: f9caa9e09ca6e0f1f9b216d33daf87ae14e62709ff0aaeb484aa61e98ff6ed0a
Contents?: true
Size: 1.05 KB
Versions: 5
Compression:
Stored size: 1.05 KB
Contents
require 'csv' module ARII # = CSVSeedReader # # Load content from CSV seed. # class CSVSeedReader < SeedReader ## # == Read # # => Load the seed data into the @objects array for processing. # def read begin CSV.new(open(@seed[:payload][:uri]), :headers => :first_row).each do |row| begin object = @help.deep_copy @agent[:payload] object.each_pair do |key, value| variables = @help.identify_variables(object[key]) variables.each do |v| object[key].gsub!("%{#{v}}", row[@seed[:payload][:selectors][v].to_i]) end end unless @seed[:payload][:cache].nil? then object[:seed] = row[@seed[:payload][:cache].to_i] else object[:seed] = row[0] end object[:identifier] = @agent.identifier @objects.push object rescue Exception => e end end rescue Exception => e end @objects end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
arii-1.8 | lib/arii/csvseedreader.rb |
arii-1.7 | lib/arii/csvseedreader.rb |
arii-1.6 | lib/arii/csvseedreader.rb |
arii-1.5 | lib/arii/csvseedreader.rb |
arii-1.2.2 | lib/arii/csvseedreader.rb |