bill_hicks 1.2.4 → 1.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/bill_hicks/brand_converter.rb +6 -4
- data/lib/bill_hicks/catalog.rb +0 -4
- data/lib/bill_hicks/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: e48de64ff5d527cc8f31b9566ca0d107528717fd
|
4
|
+
data.tar.gz: 9ba44e2e1ca079346a50fa276d27cbce5d970a49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c92a2b46442174db39669efe922fb6d89c81a0e6b479a79666fea72d2f6c846e30bae0e5557676bc8570abd3fdba16bab8adb56f99c447b992a64b0f17da2a35
|
7
|
+
data.tar.gz: f00e75bf53fad3b5c29cae8a09f4610462db23cc7585ed312204c470a778bff267333e725516b3258580555a9fcb4c0a74716037d0bbd5f4208623109ff921af
|
@@ -2,11 +2,13 @@ module BillHicks
|
|
2
2
|
class BrandConverter
|
3
3
|
|
4
4
|
def self.convert(value)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
# Strip out all non-word characters and upcase
|
6
|
+
normalized_value = value.gsub(/\W/, '').split[0].upcase
|
7
|
+
if brand = self.brands.detect { |brand| brand[:prefix] == normalized_value }
|
8
|
+
return brand[:company]
|
9
9
|
end
|
10
|
+
# No brand matched with the given prefix
|
11
|
+
normalized_value
|
10
12
|
end
|
11
13
|
|
12
14
|
def self.brands
|
data/lib/bill_hicks/catalog.rb
CHANGED
@@ -73,10 +73,6 @@ module BillHicks
|
|
73
73
|
ftp.getbinaryfile(CATALOG_FILENAME, tempfile.path)
|
74
74
|
|
75
75
|
SmarterCSV.process(File.open(tempfile, "r:iso-8859-1"), { chunk_size: size, force_utf8: true, convert_values_to_numeric: false }) do |chunk|
|
76
|
-
chunk.each do |item|
|
77
|
-
item[:brand_name] = BillHicks::BrandConverter.convert(item[:product_name])
|
78
|
-
end
|
79
|
-
|
80
76
|
yield(chunk)
|
81
77
|
end
|
82
78
|
|
data/lib/bill_hicks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bill_hicks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dale Campbell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: smarter_csv
|