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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d576d59a7255cc36e5c5f191c3008f019447a0a7
4
- data.tar.gz: de1ea3509600b34de25bee0d26e3767af9b2d880
3
+ metadata.gz: e48de64ff5d527cc8f31b9566ca0d107528717fd
4
+ data.tar.gz: 9ba44e2e1ca079346a50fa276d27cbce5d970a49
5
5
  SHA512:
6
- metadata.gz: 27072dfd0a92e2e7ba2653261b3d6a25ec17f1778c594c4e5a45b82cedb8c0e4e9973f702c6687d582b825ddb328a4dfc9534fd294b46c26bfaa9892c37e4986
7
- data.tar.gz: b7279e8a9c67fad9d748d20f63e2bea2614470707ae1c27c26d58ad535266a43225a32989b496689c021414bc887e88ae61afad154bfbcb607a915a3dd3b1c25
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
- if brand = self.brands.detect { |brand| brand[:prefix] == value.split[0].upcase }
6
- brand[:company].empty? ? value.split[0] : brand[:company]
7
- else
8
- value.split[0].upcase
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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module BillHicks
2
- VERSION = '1.2.4'
2
+ VERSION = '1.3.0'
3
3
  end
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.2.4
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-04-26 00:00:00.000000000 Z
11
+ date: 2017-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smarter_csv