aranha 0.17.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aranha/address_processor.rb +2 -22
- data/lib/aranha/temporary_errors.rb +32 -0
- data/lib/aranha/temporary_errors_manager.rb +39 -0
- data/lib/aranha/version.rb +1 -1
- metadata +14 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaf36e792490fa400227bba2f46b8653e7c5f832e3ddfa8e3369a0d66efdbf6c
|
4
|
+
data.tar.gz: e7f52f89ba5bb1e60dbb3404b108cfa16e7db45d2124d9b803967018cd7bd665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9139a3fa904e1b4853e230c4b2fd4c21e7893603862966ba3936b002c8c40e3df82b81d67d51656897dfbf67247949ccb5f480b5cbcd1bde3ae1d03dc0825b71
|
7
|
+
data.tar.gz: 60c6ca44c1a229458eefc1e21c29cd6d5be49ce9eba3af78d0058f6cb21d6f4e47065aa24b65b853e40f4c14b04dcca0a00c1a911a6ac16166bb57b8e94b2c03
|
@@ -1,30 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'aranha/temporary_errors_manager'
|
4
5
|
|
5
6
|
module Aranha
|
6
7
|
class AddressProcessor
|
7
|
-
ARANHA_EXCEPTIONS = [::Aranha::Parsers::InvalidStateException].freeze
|
8
|
-
CORE_EXCEPTIONS = [::SocketError].freeze
|
9
|
-
ERRNO_EXCEPTIONS = [Errno::ECONNREFUSED, ::Errno::ECONNRESET].freeze
|
10
|
-
HTTPCLIENT_EXCEPTIONS = [
|
11
|
-
::HTTPClient::BadResponseError,
|
12
|
-
::HTTPClient::ConnectTimeoutError,
|
13
|
-
::HTTPClient::ReceiveTimeoutError
|
14
|
-
].freeze
|
15
|
-
NET_EXCEPTIONS = [::Net::HTTPFatalError, ::Net::HTTPServerException, ::Net::OpenTimeout].freeze
|
16
|
-
|
17
|
-
NETWORK_EXCEPTIONS = ARANHA_EXCEPTIONS + CORE_EXCEPTIONS + ERRNO_EXCEPTIONS +
|
18
|
-
HTTPCLIENT_EXCEPTIONS + NET_EXCEPTIONS
|
19
|
-
|
20
|
-
class << self
|
21
|
-
def rescuable_error?(error)
|
22
|
-
return true if NETWORK_EXCEPTIONS.any? { |klass| error.is_a?(klass) }
|
23
|
-
|
24
|
-
error.cause.present? ? network_error?(error.cause) : false
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
8
|
enable_simple_cache
|
29
9
|
common_constructor :address
|
30
10
|
|
@@ -33,7 +13,7 @@ module Aranha
|
|
33
13
|
end
|
34
14
|
|
35
15
|
def rescuable_error?
|
36
|
-
|
16
|
+
::Aranha::TemporaryErrorsManager.temporary_error?(error)
|
37
17
|
end
|
38
18
|
|
39
19
|
private
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/invalid_state_exception'
|
4
|
+
require 'aranha/parsers/source_address/fetch_content_error'
|
5
|
+
require 'httpclient'
|
6
|
+
require 'eac_ruby_utils/core_ext'
|
7
|
+
require 'selenium-webdriver'
|
8
|
+
|
9
|
+
module Aranha
|
10
|
+
module TemporaryErrors
|
11
|
+
ARANHA_ERRORS = [::Aranha::Parsers::InvalidStateException,
|
12
|
+
::Aranha::Parsers::SourceAddress::FetchContentError].freeze
|
13
|
+
CORE_ERRORS = [::SocketError].freeze
|
14
|
+
ERRNO_ERRORS = [Errno::ECONNREFUSED, ::Errno::ECONNRESET].freeze
|
15
|
+
HTTPCLIENT_ERRORS = [
|
16
|
+
::HTTPClient::BadResponseError,
|
17
|
+
::HTTPClient::ConnectTimeoutError,
|
18
|
+
::HTTPClient::ReceiveTimeoutError
|
19
|
+
].freeze
|
20
|
+
NET_ERRORS = [::Net::HTTPFatalError, ::Net::HTTPServerException, ::Net::OpenTimeout].freeze
|
21
|
+
SELENIUM_ERRORS = [::Selenium::WebDriver::Error::TimeoutError].freeze
|
22
|
+
|
23
|
+
ALL_ERRORS = ARANHA_ERRORS + CORE_ERRORS + ERRNO_ERRORS +
|
24
|
+
HTTPCLIENT_ERRORS + NET_ERRORS + SELENIUM_ERRORS
|
25
|
+
|
26
|
+
class << self
|
27
|
+
def errors
|
28
|
+
ALL_ERRORS
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/gems_registry'
|
5
|
+
|
6
|
+
module Aranha
|
7
|
+
module TemporaryErrorsManager
|
8
|
+
GEMS_REGISTRY_MODULE_SUFFIX = 'TemporaryErrors'
|
9
|
+
|
10
|
+
class << self
|
11
|
+
enable_simple_cache
|
12
|
+
|
13
|
+
# @return [Exception]
|
14
|
+
def errors
|
15
|
+
errors_providers.flat_map(&:errors)
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Array]
|
19
|
+
def errors_providers
|
20
|
+
gems_registry.registered.map(&:registered_module)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param error Exception
|
24
|
+
# @return [Boolean]
|
25
|
+
def temporary_error?(error)
|
26
|
+
return true if errors.any? { |klass| error.is_a?(klass) }
|
27
|
+
|
28
|
+
error.cause.present? ? temporary_error?(error.cause) : false
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# @return [EacRubyUtils::GemsRegistry]
|
34
|
+
def gems_registry_uncached
|
35
|
+
::EacRubyUtils::GemsRegistry.new(GEMS_REGISTRY_MODULE_SUFFIX)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/aranha/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aranha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo H. Bogoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha-parsers
|
@@ -36,34 +36,34 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0.
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 0.4.2
|
39
|
+
version: '0.5'
|
43
40
|
type: :runtime
|
44
41
|
prerelease: false
|
45
42
|
version_requirements: !ruby/object:Gem::Requirement
|
46
43
|
requirements:
|
47
44
|
- - "~>"
|
48
45
|
- !ruby/object:Gem::Version
|
49
|
-
version: '0.
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 0.4.2
|
46
|
+
version: '0.5'
|
53
47
|
- !ruby/object:Gem::Dependency
|
54
48
|
name: eac_ruby_utils
|
55
49
|
requirement: !ruby/object:Gem::Requirement
|
56
50
|
requirements:
|
57
51
|
- - "~>"
|
58
52
|
- !ruby/object:Gem::Version
|
59
|
-
version: '0.
|
53
|
+
version: '0.106'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.106.1
|
60
57
|
type: :runtime
|
61
58
|
prerelease: false
|
62
59
|
version_requirements: !ruby/object:Gem::Requirement
|
63
60
|
requirements:
|
64
61
|
- - "~>"
|
65
62
|
- !ruby/object:Gem::Version
|
66
|
-
version: '0.
|
63
|
+
version: '0.106'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.106.1
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: httpclient
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,6 +118,8 @@ files:
|
|
118
118
|
- lib/aranha/default_processor.rb
|
119
119
|
- lib/aranha/manager.rb
|
120
120
|
- lib/aranha/processor.rb
|
121
|
+
- lib/aranha/temporary_errors.rb
|
122
|
+
- lib/aranha/temporary_errors_manager.rb
|
121
123
|
- lib/aranha/version.rb
|
122
124
|
homepage:
|
123
125
|
licenses:
|