lib/bill_hicks/inventory.rb in bill_hicks-1.1.8 vs lib/bill_hicks/inventory.rb in bill_hicks-1.1.9.pre

- old
+ new

@@ -34,10 +34,11 @@ lines = ftp.gettextfile(INVENTORY_FILENAME, nil) CSV.parse(lines, headers: :first_row) do |row| inventory << { + brand: BillHicks::BrandConverter.convert(row.fetch('Product')), product: row.fetch('Product'), upc: row.fetch('UPC'), quantity: (Integer(row.fetch('Qty Avail')) rescue 0) } end @@ -54,10 +55,14 @@ temp_csv_file = Tempfile.new ftp.chdir(BillHicks.config.top_level_dir) ftp.getbinaryfile(INVENTORY_FILENAME, temp_csv_file.path) - SmarterCSV.process(temp_csv_file, { :chunk_size => size, :force_utf8 => true, :convert_values_to_numeric => false }) do |chunk| + SmarterCSV.process(temp_csv_file, { :chunk_size => size, :force_utf8 => true, :convert_values_to_numeric => false, }) do |chunk| + chunk.each do |item| + item[:brand] = BillHicks::BrandConverter.convert(item[:product]) + end + yield(chunk) end temp_csv_file.unlink end