Sha256: 0e5e38e3a27f4771482305268babc0c152a63f4799bd5e3f3a5093d0d2e3d574
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
module Zanders class Inventory < Base INVENTORY_FILENAME = "liveinv.csv" def initialize(options = {}) requires!(options, :username, :password) @options = options end def self.all(chunk_size = 15, options = {}, &block) requires!(options, :username, :password) new(options).all(chunk_size, &block) end def all(chunk_size, &block) connect(@options) do |ftp| begin csv_tempfile = Tempfile.new ftp.chdir(Zanders.config.ftp_directory) ftp.getbinaryfile(QUANTITY_FILENAME, csv_tempfile.path) SmarterCSV.process(csv_tempfile, { :chunk_size => chunk_size, :convert_values_to_numeric => false, :key_mapping => { :available => :quantity, :itemnumber => :item_identifier, :price1 => :price } }) do |chunk| chunk.each do |item| item.except!(:qty1, :qty2, :qty3, :price2, :price3) end yield(chunk) end csv_tempfile.unlink ensure ftp.close end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
zanders-2.0.3 | lib/zanders/inventory.rb |
zanders-2.0.2 | lib/zanders/inventory.rb |
zanders-2.0.1 | lib/zanders/inventory.rb |
zanders-2.0 | lib/zanders/inventory.rb |