mge_wholesale 1.0.4 → 3.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94efa68d0a6acf4fa2471953fe46666ed375de8081ef156ae5176e7bdb4d13f8
4
- data.tar.gz: a3912f9bef3ad4c6abf79faf8084df79a5f58aeb4c837ea63bdb5f9fb3051fec
3
+ metadata.gz: 7463a0e2032a6bd9056bc5b1979793ad752d5c1c9327068e74bede719fa9bcf6
4
+ data.tar.gz: 7b5409d4d70b850bb24370cdb16626e487a8674933ffc882f9f2d690be553dd1
5
5
  SHA512:
6
- metadata.gz: fba07faa86b192bf3bfa88e63b172d693cd65c4dccbeeae858f7ec1f59a29db4d81bf1c669a7e19590b4e76ee9be163b3806c1c1f4aee27ba7bacefd0accef5a
7
- data.tar.gz: a5afcdf5b2e0eb92778ef2e21c8a58e9d2b38573ff0421a26444011915c7b123232823916b25960050df878ebbf768ae63cce8312b4308ba79c82797057a6411
6
+ metadata.gz: d275c5d84cb7ec8d9ddd2767581e4fc05fc58aa3370447f93a09aca5ca1d2d74408ddd6cab116a63ca97d470caf01981cb721adae9b1bf5bba06e9fe6266e1dc
7
+ data.tar.gz: a181d5b70f864a943d8dd87e6d91aed4906d1da425a4e25053f4e36bd509f6a03db2616dc4cc5bddd08c3ec4718f3f8943ed65e7c99ae3773daa058cf90ecde9
@@ -1,7 +1,8 @@
1
1
  module MgeWholesale
2
2
  class Inventory < Base
3
3
 
4
- INVENTORY_FILENAME = 'exportXML_cq_barcodeFFL.xml'
4
+ INVENTORY_FILENAME = 'exportXML_cq_barcodeFFL.csv'.freeze
5
+ FULL_INVENTORY_FILENAME = 'exportXML_cq_barcodeFFL_all.csv'.freeze
5
6
 
6
7
  def initialize(options = {})
7
8
  requires!(options, :username, :password)
@@ -13,51 +14,40 @@ module MgeWholesale
13
14
  new(options).all(&block)
14
15
  end
15
16
 
16
- def self.get_quantity_file(options = {})
17
- requires!(options, :username, :password)
18
- new(options).get_quantity_file
19
- end
20
-
21
17
  def self.quantity(options = {}, &block)
22
18
  requires!(options, :username, :password)
23
- new(options).all(&block)
19
+ new(options).quantity(&block)
24
20
  end
25
21
 
26
22
  def all(&block)
27
23
  tempfile = get_file(INVENTORY_FILENAME)
28
24
 
29
- Nokogiri::XML(tempfile).xpath('//item').each do |item|
30
- yield map_hash(item)
25
+ CSV.foreach(tempfile, { headers: :first_row }).each do |row|
26
+ item = {
27
+ item_identifier: row['id'],
28
+ quantity: row['qty'].to_i,
29
+ price: row['cost'],
30
+ }
31
+
32
+ yield(item)
31
33
  end
32
34
 
33
- tempfile.close
34
35
  tempfile.unlink
35
36
  end
36
37
 
37
- def get_quantity_file
38
- inventory_tempfile = get_file(INVENTORY_FILENAME)
39
- tempfile = Tempfile.new
38
+ def quantity(&block)
39
+ tempfile = get_file(FULL_INVENTORY_FILENAME)
40
40
 
41
- Nokogiri::XML(inventory_tempfile).xpath('//item').each do |item|
42
- tempfile.puts("#{content_for(item, 'id')},#{content_for(item, 'qty')}")
43
- end
41
+ CSV.foreach(tempfile, { headers: :first_row }).each do |row|
42
+ item = {
43
+ item_identifier: row['id'],
44
+ quantity: row['qty'].to_i,
45
+ }
44
46
 
45
- inventory_tempfile.close
46
- inventory_tempfile.unlink
47
- tempfile.close
48
- tempfile.path
49
- end
50
-
51
- alias quantity all
52
-
53
- private
47
+ yield(item)
48
+ end
54
49
 
55
- def map_hash(node)
56
- {
57
- item_identifier: content_for(node, 'id'),
58
- quantity: content_for(node, 'qty').to_i,
59
- price: content_for(node, 'cost')
60
- }
50
+ tempfile.unlink
61
51
  end
62
52
 
63
53
  end
@@ -1,3 +1,3 @@
1
1
  module MgeWholesale
2
- VERSION = '1.0.4'.freeze
2
+ VERSION = '3.0.0.pre'.freeze
3
3
  end
data/lib/mge_wholesale.rb CHANGED
@@ -4,7 +4,6 @@ require 'csv'
4
4
  require 'net/ftp'
5
5
  require 'tempfile'
6
6
 
7
- # these can be commented out when the gem is bundled into a Rails app
8
7
  require 'nokogiri'
9
8
  require 'active_support/all'
10
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mge_wholesale
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 3.0.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Ebling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-20 00:00:00.000000000 Z
11
+ date: 2018-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -123,9 +123,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - ">="
126
+ - - ">"
127
127
  - !ruby/object:Gem::Version
128
- version: '0'
128
+ version: 1.3.1
129
129
  requirements: []
130
130
  rubyforge_project:
131
131
  rubygems_version: 2.7.7