lcbo 0.9.3 → 0.9.4

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.
@@ -3,13 +3,12 @@ module LCBO
3
3
 
4
4
  MAX_RETRIES = 10
5
5
 
6
- class Error < StandardError; end
7
- class EpicTimeoutError < Error; end
6
+ class EpicTimeoutError < StandardError; end
8
7
 
9
8
  def self.run(params = {}, tries = 0, &block)
10
9
  raise ArgumentError, 'block expected' unless block_given?
11
10
  begin
12
- payload = ProductListRequest.parse(params).as_hash
11
+ payload = LCBO.product_list(params[:page] || 1)
13
12
  yield(payload)
14
13
  run(:page => payload[:next_page], &block) if payload[:next_page]
15
14
  rescue Errno::ETIMEDOUT, Timeout::Error
@@ -1,14 +1,23 @@
1
1
  module LCBO
2
2
  class StoresCrawler
3
3
 
4
- def self.run(&block)
5
- raise ArgumentError, 'block expected' unless block_given?
6
- (1..720).each do |store_no|
7
- begin
8
- yield StoreRequest.parse(:store_no => store_no).as_hash
9
- rescue CrawlKit::MissingResourceError, Errno::ETIMEDOUT, Timeout::Error
10
- # Ignore stores that don't exist and timeouts.
11
- end
4
+ MAX_STORE_NO = 850
5
+ MAX_RETRIES = 10
6
+
7
+ class EpicTimeoutError < StandardError; end
8
+
9
+ def self.run(params, tries = 0, &block)
10
+ begin
11
+ payload = LCBO.store(params[:store_no])
12
+ yield payload
13
+ params[:store_no] = params[:store_nos].pop
14
+ run(params, &block)
15
+ rescue Errno::ETIMEDOUT, Timeout::Error
16
+ raise EpicTimeoutError if tries > MAX_RETRIES
17
+ run(params, (tries + 1), &block)
18
+ rescue LCBO::StorePage::MissingResourceError
19
+ params[:store_no] = params[:store_nos].pop
20
+ run(params, &block)
12
21
  end
13
22
  end
14
23
 
@@ -1,3 +1,3 @@
1
1
  module LCBO
2
- VERSION = '0.9.3'
2
+ VERSION = '0.9.4'
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 3
9
- version: 0.9.3
8
+ - 4
9
+ version: 0.9.4
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: 2010-09-24 00:00:00 -04:00
17
+ date: 2010-11-24 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency