zanders 2.2.7 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zanders/catalog.rb +2 -21
- data/lib/zanders/inventory.rb +1 -12
- data/lib/zanders/version.rb +1 -1
- data/lib/zanders.rb +0 -1
- metadata +3 -4
- data/lib/zanders/chunker.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1e40bf9409d6d02ef10b37ea4775601ceb7c2cd
|
4
|
+
data.tar.gz: f71f3e3d12781a6f2857a10527e9a2e318fc51e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d9e843dca9c57e9b6d750154f5d42d169c8518cefdc1a982f705948833dccb660cb4e92f64d09a15c9f67fe0ab1de22a70b4e91b05e54da0b16045cb99d4f5d
|
7
|
+
data.tar.gz: a81640e4b9b752fa676ede380d5b963ded5cee5393cf6b1ced0cb1c6f5b7b3f9fb5adb826387ef042e3606015af63d0c404ee78157bc83d33fb1360c5bfd5674
|
data/lib/zanders/catalog.rb
CHANGED
@@ -6,10 +6,6 @@ module Zanders
|
|
6
6
|
def initialize(options = {})
|
7
7
|
requires!(options, :username, :password)
|
8
8
|
@options = options
|
9
|
-
|
10
|
-
if options[:full_product].present?
|
11
|
-
self.load_descriptions
|
12
|
-
end
|
13
9
|
end
|
14
10
|
|
15
11
|
def self.all(chunk_size = 15, options = {}, &block)
|
@@ -18,22 +14,11 @@ module Zanders
|
|
18
14
|
end
|
19
15
|
|
20
16
|
def all(chunk_size, &block)
|
21
|
-
chunker = Zanders::Chunker.new(chunk_size)
|
22
17
|
tempfile = get_file(CATALOG_FILENAME)
|
23
18
|
xml_doc = Nokogiri::XML(tempfile.open)
|
24
19
|
|
25
20
|
xml_doc.xpath("//ZandersDataOut").each do |item|
|
26
|
-
|
27
|
-
yield(chunker.chunk)
|
28
|
-
|
29
|
-
chunker.reset!
|
30
|
-
else
|
31
|
-
chunker.add(map_hash(item, @options[:full_product].present?))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
if chunker.chunk.count > 0
|
36
|
-
yield(chunker.chunk)
|
21
|
+
map_hash(item)
|
37
22
|
end
|
38
23
|
|
39
24
|
tempfile.unlink
|
@@ -41,13 +26,9 @@ module Zanders
|
|
41
26
|
|
42
27
|
protected
|
43
28
|
|
44
|
-
def map_hash(node
|
29
|
+
def map_hash(node)
|
45
30
|
features = self.map_features(node)
|
46
31
|
|
47
|
-
if full_product
|
48
|
-
long_description = self.get_description(content_for(node, 'ITEMNO'))
|
49
|
-
end
|
50
|
-
|
51
32
|
# product_type = case content_for(node, 'ITEMPRODUCTTYPE')
|
52
33
|
# when 'PD', 'PR'
|
53
34
|
# :ammunition
|
data/lib/zanders/inventory.rb
CHANGED
@@ -30,22 +30,11 @@ module Zanders
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def all(chunk_size, &block)
|
33
|
-
chunker = Zanders::Chunker.new(chunk_size)
|
34
33
|
tempfile = get_file(INVENTORY_FILENAME)
|
35
34
|
xml_doc = Nokogiri::XML(tempfile.open)
|
36
35
|
|
37
36
|
xml_doc.xpath('//ZandersDataOut').each do |item|
|
38
|
-
|
39
|
-
yield(chunker.chunk)
|
40
|
-
|
41
|
-
chunker.reset!
|
42
|
-
else
|
43
|
-
chunker.add(map_hash(item))
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
if chunker.chunk.count > 0
|
48
|
-
yield(chunker.chunk)
|
37
|
+
map_hash(item)
|
49
38
|
end
|
50
39
|
|
51
40
|
tempfile.unlink
|
data/lib/zanders/version.rb
CHANGED
data/lib/zanders.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zanders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Knight
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -131,7 +131,6 @@ files:
|
|
131
131
|
- lib/zanders/address.rb
|
132
132
|
- lib/zanders/base.rb
|
133
133
|
- lib/zanders/catalog.rb
|
134
|
-
- lib/zanders/chunker.rb
|
135
134
|
- lib/zanders/inventory.rb
|
136
135
|
- lib/zanders/item.rb
|
137
136
|
- lib/zanders/order.rb
|
@@ -159,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
158
|
version: '0'
|
160
159
|
requirements: []
|
161
160
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
161
|
+
rubygems_version: 2.5.1
|
163
162
|
signing_key:
|
164
163
|
specification_version: 4
|
165
164
|
summary: Ruby library for Zanders
|
data/lib/zanders/chunker.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module Zanders
|
2
|
-
class Chunker
|
3
|
-
|
4
|
-
attr_accessor :chunk, :total_count, :current_count, :size
|
5
|
-
|
6
|
-
def initialize(size, total_count = nil)
|
7
|
-
@size = size
|
8
|
-
@chunk = Array.new
|
9
|
-
@current_count = 0
|
10
|
-
@total_count = total_count
|
11
|
-
end
|
12
|
-
|
13
|
-
def add(row)
|
14
|
-
self.reset! if is_full?
|
15
|
-
|
16
|
-
@chunk.push(row)
|
17
|
-
|
18
|
-
@current_count += 1
|
19
|
-
end
|
20
|
-
|
21
|
-
def reset!
|
22
|
-
@chunk.clear
|
23
|
-
end
|
24
|
-
|
25
|
-
def is_full?
|
26
|
-
@chunk.count == @size
|
27
|
-
end
|
28
|
-
|
29
|
-
def is_complete?
|
30
|
-
@total_count == @current_count
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|