spidy 0.0.7 → 0.0.8

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
  SHA256:
3
- metadata.gz: 772ed6d83c4c58ed738a37577ef560311985a17fb7b9d7124040fa79366f64e7
4
- data.tar.gz: 620e349f88244c5a5a91d82cf999dc62c31441044c41e2fb0a53fe3f816c2156
3
+ metadata.gz: a6e8adabd5eef99735eb1e4ab44609e2f25a859b5604bb2512a8692b72dd0c9e
4
+ data.tar.gz: ab748cec4971ae35044860ddc26465aaac67d56f47677919f47a3562bd29080a
5
5
  SHA512:
6
- metadata.gz: e768f36adeb61e921d54763843ac0d7c7e2663dd5eca4d787b2ba6963af477a38bef5aa2be6e4f7de3ff1d8cdf28594a797088bf528780b50532d1c6d1c56afb
7
- data.tar.gz: 2ef2d5da509e82324135aa5a71439697c5afd78a1313de29cb4f6ecbc43192682719371a2d41b89f94e2f75414ccf90ec2c9e1ea7e943b2affc3c9f84a259cab
6
+ metadata.gz: 747950afd87f68df3572aeb8859af14087a75bd1786c5183719ce94f7964c397e9b81a58c563f1a54883322620b7aa64d580144ec25e0fe4f85c20463ed21d68
7
+ data.tar.gz: c2d972491eedbdb5308ceda060c71c95a409f9b4968a5897baf93a137d8f17411ad1afa9bfed7e93b0b5a177a706a358da56dc28a86e7dfe3f65152174b22ce8
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spidy (0.0.6)
4
+ spidy (0.0.7)
5
5
  activemodel (~> 5.2)
6
6
  activesupport (~> 5.2)
7
7
  mechanize
@@ -17,21 +17,26 @@ module Spidy::Connector::Html
17
17
  @agent.user_agent = USER_AGENT
18
18
 
19
19
  class << self
20
- def call(url, encoding: nil, &yielder)
20
+ attr_reader :agent
21
+
22
+ def call(url, encoding: nil, retry_count: 3, &yielder)
21
23
  if encoding
22
24
  @agent.default_encoding = encoding
23
25
  @agent.force_default_encoding = true
24
26
  end
25
- get(url, yielder)
27
+ get(url, retry_count, yielder)
26
28
  end
27
29
 
28
- def get(url, yielder)
30
+ private
31
+
32
+ def get(url, retry_count, yielder)
29
33
  @agent.get(url, &yielder)
30
34
  rescue Mechanize::ResponseCodeError => e
35
+ retry_count -= 1
31
36
  case e.response_code
32
37
  when '429'
33
38
  sleep 2
34
- @agent.get(url, &yielder)
39
+ retry if retry_count
35
40
  else
36
41
  raise e
37
42
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spidy
4
- VERSION = '0.0.7'
4
+ VERSION = '0.0.8'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spidy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - aileron