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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e563c1243ef772c1fb83838331d6786650045c16
4
- data.tar.gz: 1fe3c1cf78a40af8fa23e2ae2e5261bd7998836c
3
+ metadata.gz: b576303e22f47e9b64ce97b147ecba724b6cc7c4
4
+ data.tar.gz: 461cc3c15db5b26f232e750a93e31e3470d34abf
5
5
  SHA512:
6
- metadata.gz: ffe1ee0d58a2bbd81790c925d5569fb3bcfcbd9fc616f4d5a4d33c56d70608be8f41c5f177eb8ec5e4e2a1942c440ff076d12399aef708fb407f07d2f52bee2c
7
- data.tar.gz: 5b39ec1f75cc546436f6942c4794587b3f2c91554219628be796dfd6c6535f58da01560b3184219da4d661fdb51ec8d0c09f4dd5091a8130a04977bbd91d827e
6
+ metadata.gz: 8928b2cf077fde093a8ca4b7d2fff784293a8e4c88c8ad0ed0254b3fc879b478494f7f44a725440a30dac8c63fd086e567526f6a42fd39efce72f00e1eeed148
7
+ data.tar.gz: 41b36a8a3dee437475d504165594ff46f1125b2b1382c8b4687d018a7de3f2946152e34eec120eab5d75462d6462fa895af9b1b87cc96881b3e1db0af0766d1b
@@ -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
- def all(chunk_size, &block)
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
@@ -1,3 +1,3 @@
1
1
  module Zanders
2
- VERSION = "2.0.2"
2
+ VERSION = "2.0.3"
3
3
  end
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.2
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-30 00:00:00.000000000 Z
11
+ date: 2017-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri