lcbo 0.9.2 → 0.9.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.
data/CHANGELOG.md CHANGED
@@ -1,11 +1,17 @@
1
+ Version 0.9.3
2
+
3
+ * 4x speed boost to InventoryPage.parse courtesy of Justin Giancola.
4
+
1
5
  Version 0.9.2
2
6
 
3
- * Fixed potential bug in some versions of Ruby where Object#send semantics cause a failure when calling private or protected methods.
7
+ * Fixed potential bug in some versions of Ruby where Object#send semantics
8
+ cause a failure when calling private or protected methods.
4
9
 
5
10
  Version 0.9.1
6
11
 
7
12
  * Removed dependency on Addressable.
8
- * Refactored tests to use MiniTest::Spec instead of RSpec, removing another dependency.
13
+ * Refactored tests to use MiniTest::Spec instead of RSpec, removing another
14
+ dependency.
9
15
 
10
16
  Version 0.9.0
11
17
 
data/CONTRIBUTORS ADDED
@@ -0,0 +1,2 @@
1
+ Carsten Nielsen
2
+ Justin Giancola
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # LCBO: The Ruby Gem
2
2
 
3
- This library is used to gather data for [LCBO API](http://lcboapi.com). It allows you to request and parse store, product, inventory, and product list pages directly from the [LCBO](http://lcbo.com) website.
3
+ This library is used to gather data for [LCBO API](http://lcboapi.com). It
4
+ allows you to request and parse store, product, inventory, and product list
5
+ pages directly from the [LCBO](http://lcbo.com) website.
4
6
 
5
7
  ## Synopsis
6
8
 
@@ -20,7 +22,7 @@ This library is used to gather data for [LCBO API](http://lcboapi.com). It allow
20
22
 
21
23
  ## Installation
22
24
 
23
- Use Ruby Gems: `gem install lcbo`
25
+ Use RubyGems: `gem install lcbo`
24
26
 
25
27
  ## Notes
26
28
 
@@ -16,41 +16,15 @@ module LCBO
16
16
 
17
17
  emits :inventories do
18
18
  # [updated_on, store_no, quantity]
19
- inventory_table_rows.reduce([]) do |ary, node|
20
- h = {}
21
- h[:updated_on] = begin
22
- CrawlKit::FastDateHelper[
23
- node.
24
- css('td[width="17%"]')[-1].
25
- text.
26
- strip]
27
- end
28
- h[:store_no] = begin
29
- node.
30
- to_s.
31
- match(/\?STORE=([0-9]{1,3})\&/).
32
- captures[0].
33
- to_s.
34
- to_i
35
- end
36
- h[:quantity] = begin
37
- node.
38
- css('td[width="13%"]')[0].
39
- content.
40
- strip.
41
- to_i
42
- end
43
- ary << h
19
+ doc.css('table[cellpadding="3"] tr[bgcolor] > td[width="17%"] > a.item-details-col5').zip(
20
+ doc.css('table[cellpadding="3"] tr[bgcolor] > td > a.item-details-col0'),
21
+ doc.css('table[cellpadding="3"] tr[bgcolor] > td[width="13%"]')).map do |updated_on, store_no, quantity|
22
+ {
23
+ :updated_on => CrawlKit::FastDateHelper[updated_on.text.strip],
24
+ :store_no => store_no["href"].match(/\?STORE=([0-9]{1,3})\&/)[1].to_i,
25
+ :quantity => quantity.content.strip.to_i,
26
+ }
44
27
  end
45
28
  end
46
-
47
- def inventory_table
48
- doc.css('table[cellpadding="3"]')
49
- end
50
-
51
- def inventory_table_rows
52
- inventory_table.css('tr[bgcolor]')
53
- end
54
-
55
29
  end
56
30
  end
data/lib/lcbo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LCBO
2
- VERSION = '0.9.2'
2
+ VERSION = '0.9.3'
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 2
9
- version: 0.9.2
8
+ - 3
9
+ version: 0.9.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Carsten Nielsen
@@ -55,6 +55,7 @@ extra_rdoc_files: []
55
55
  files:
56
56
  - .gitignore
57
57
  - CHANGELOG.md
58
+ - CONTRIBUTORS
58
59
  - Gemfile
59
60
  - Gemfile.lock
60
61
  - LICENSE