lcbo 1.0.0 → 1.0.1

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.
@@ -1,3 +1,8 @@
1
+ Version 1.0.1
2
+
3
+ * Fixed issue where `TagHelper` was not including words with apostrophes (')
4
+ or dashes (-).
5
+
1
6
  Version 1.0.0
2
7
 
3
8
  * Fixed issue that affected about 10 products in where if the name began
@@ -1,7 +1,7 @@
1
1
  module LCBO
2
2
  module CrawlKit
3
3
  module TagHelper
4
- DELETION_RE = /\'|\"|\\|\/|\(|\)|\[|\]|\./
4
+ DELETION_RE = /\"|\\|\/|\(|\)|\[|\]|\./
5
5
  WHITESPACE_RE = /\*|\+|\&|\_|\,|\s/
6
6
 
7
7
  def self.flatten(values)
@@ -21,14 +21,27 @@ module LCBO
21
21
  end
22
22
 
23
23
  def self.stem(word)
24
- if word.include?('-')
25
- parts = word.split('-')
26
- a = parts.dup
27
- a << parts.join
28
- a
29
- else
30
- word
31
- end
24
+ split = lambda { |word|
25
+ if word.include?('-')
26
+ words = word.split('-')
27
+ a = words.dup
28
+ a << word
29
+ a << words.join
30
+ a
31
+ else
32
+ [word]
33
+ end
34
+ }
35
+
36
+ tokenize = lambda { |words|
37
+ words.reduce([]) do |tokens, word|
38
+ tokens << word
39
+ tokens << word.gsub("'", '') if word.include?("'")
40
+ tokens
41
+ end
42
+ }
43
+
44
+ tokenize.(split.(word))
32
45
  end
33
46
 
34
47
  def self.[](*values)
@@ -1,3 +1,3 @@
1
1
  module LCBO
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -6,8 +6,9 @@ describe LCBO::CrawlKit::TagHelper do
6
6
  ['Hello World'] => %w[hello world],
7
7
  ['Éve Picard'] => %w[éve picard eve],
8
8
  ['Hello Hello World'] => %w[hello world],
9
+ ['É\'ve Picard-Rowe'] => %w[é've éve picard rowe picard-rowe picardrowe e've eve],
9
10
  ['Hello', 'Éve Picard'] => %w[hello éve picard eve],
10
- ['Hello', 'Éve-Picard'] => %w[hello éve picard évepicard eve evepicard],
11
+ ['Hello', 'Éve-Picard'] => %w[hello éve picard éve-picard évepicard eve eve-picard evepicard],
11
12
  ['Hello', nil, 'World'] => %w[hello world]
12
13
  }
13
14
 
@@ -48,7 +48,7 @@
48
48
  :expectation:
49
49
  :id: 18
50
50
  :name: Heineken Lager
51
- :tags: ["heineken", "lager", "beer", "netherlands", "heinekens", "brouwerijen", "nederland", "bv", "bottle"]
51
+ :tags: ["heineken", "lager", "beer", "netherlands", "heineken's", "heinekens", "brouwerijen", "nederland", "bv", "bottle"]
52
52
  :price_in_cents: 1250
53
53
  :regular_price_in_cents: 1350
54
54
  :limited_time_offer_savings_in_cents: 100
@@ -336,7 +336,7 @@
336
336
  :expectation:
337
337
  :id: 56796
338
338
  :name: Heineken Draught Keg
339
- :tags: ["heineken", "draught", "keg", "beer", "lager", "netherlands", "heinekens", "brouwerijen", "nederland", "bv", "can"]
339
+ :tags: ["heineken", "draught", "keg", "beer", "lager", "netherlands", "heineken's", "heinekens", "brouwerijen", "nederland", "bv", "can"]
340
340
  :price_in_cents: 2995
341
341
  :regular_price_in_cents: 2995
342
342
  :limited_time_offer_savings_in_cents: 0
@@ -7,7 +7,7 @@
7
7
  :expectation:
8
8
  :id: 444
9
9
  :name: Kennedy & Sheppard
10
- :tags: ["kennedy", "sheppard", "2356", "road", "agincourt", "mall", "toronto", "scarborough", "torontoscarborough", "m1t3h1"]
10
+ :tags: ["kennedy", "sheppard", "2356", "road", "agincourt", "mall", "toronto", "scarborough", "toronto-scarborough", "torontoscarborough", "m1t3h1"]
11
11
  :address_line_1: 2356 Kennedy Road
12
12
  :address_line_2: Agincourt Mall
13
13
  :city: Toronto-Scarborough
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 0
9
- version: 1.0.0
8
+ - 1
9
+ version: 1.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Carsten Nielsen
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-17 00:00:00 -05:00
17
+ date: 2011-01-20 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency