zanders 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/zanders/catalog.rb +32 -1
- data/lib/zanders/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b576303e22f47e9b64ce97b147ecba724b6cc7c4
|
4
|
+
data.tar.gz: 461cc3c15db5b26f232e750a93e31e3470d34abf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8928b2cf077fde093a8ca4b7d2fff784293a8e4c88c8ad0ed0254b3fc879b478494f7f44a725440a30dac8c63fd086e567526f6a42fd39efce72f00e1eeed148
|
7
|
+
data.tar.gz: 41b36a8a3dee437475d504165594ff46f1125b2b1382c8b4687d018a7de3f2946152e34eec120eab5d75462d6462fa895af9b1b87cc96881b3e1db0af0766d1b
|
data/lib/zanders/catalog.rb
CHANGED
@@ -6,6 +6,10 @@ 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
|
9
13
|
end
|
10
14
|
|
11
15
|
def self.all(chunk_size = 15, options = {}, &block)
|
@@ -13,7 +17,7 @@ module Zanders
|
|
13
17
|
new(options).all(chunk_size, &block)
|
14
18
|
end
|
15
19
|
|
16
|
-
|
20
|
+
def all(chunk_size, &block)
|
17
21
|
chunker = Zanders::Chunker.new(chunk_size)
|
18
22
|
|
19
23
|
connect(@options) do |ftp|
|
@@ -51,6 +55,10 @@ module Zanders
|
|
51
55
|
def map_hash(node, full_product = false)
|
52
56
|
features = self.map_features(node)
|
53
57
|
|
58
|
+
if full_product
|
59
|
+
long_description = self.get_description(content_for(node, 'ITEMNO'))
|
60
|
+
end
|
61
|
+
|
54
62
|
{
|
55
63
|
name: content_for(node, 'ITEMDESCRIPTION'),
|
56
64
|
upc: content_for(node, 'ITEMUPC'),
|
@@ -58,6 +66,7 @@ module Zanders
|
|
58
66
|
quantity: content_for(node, 'ITEMQTYAVAIL'),
|
59
67
|
price: content_for(node, 'ITEMPRICE'),
|
60
68
|
short_description: content_for(node, 'ITEMDESCRIPTION'),
|
69
|
+
long_description: long_description,
|
61
70
|
category: content_for(node, 'ITEMCATEGORYNAME'),
|
62
71
|
product_type: content_for(node, 'ITEMPRODUCTTYPE'),
|
63
72
|
mfg_number: content_for(node, 'ITEMMPN'),
|
@@ -69,6 +78,17 @@ module Zanders
|
|
69
78
|
}
|
70
79
|
end
|
71
80
|
|
81
|
+
def get_description(item_number)
|
82
|
+
description = @descriptions.find { |x| x[0] == item_number }
|
83
|
+
|
84
|
+
if description
|
85
|
+
description = description.last
|
86
|
+
description.slice!("FEATURES")
|
87
|
+
end
|
88
|
+
|
89
|
+
description
|
90
|
+
end
|
91
|
+
|
72
92
|
def map_features(node)
|
73
93
|
features = Hash.new
|
74
94
|
|
@@ -82,5 +102,16 @@ module Zanders
|
|
82
102
|
features.symbolize_keys!
|
83
103
|
end
|
84
104
|
|
105
|
+
def load_descriptions
|
106
|
+
connect(@options) do |ftp|
|
107
|
+
csv_tempfile = Tempfile.new
|
108
|
+
|
109
|
+
ftp.chdir(Zanders.config.ftp_directory)
|
110
|
+
ftp.getbinaryfile('detaildesctext.csv', csv_tempfile.path)
|
111
|
+
|
112
|
+
@descriptions = CSV.read(csv_tempfile, { :col_sep => '~', :quote_char => "\x00" })
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
85
116
|
end
|
86
117
|
end
|
data/lib/zanders/version.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.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Knight
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|