aranha-parsers 0.17.0 → 0.17.1

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: c023094e51e5188e1979f5ab406b595a93b58006c656ccf7bb55609d1b828472
4
- data.tar.gz: 1dab0c5d8cb5b000949c3484db3f30494cd893e1f82f194627ae622ece43a457
3
+ metadata.gz: 62f1b799c069d10df8548cab6f80af270b4efe96fd515ed9bb51b52dd41a1fb0
4
+ data.tar.gz: 4277d1ede3d4d766de0578e043e35a0c34483f7e286d2ffaa130e18865793682
5
5
  SHA512:
6
- metadata.gz: 9a3da7fef40ee10d63806ae268939285b3eb7778ff2d4fe5570ce305ddb7b2ee9d07abc5cd9f31c7e79b484fa807bb57aa2dd04bd5a46f76251cf5f677576ba9
7
- data.tar.gz: f96f07f064028911ae1723f97e1cb8543fe44f2e2813e35b70048894788a3a47130e464cef662fa60d75ba07d030eade04fba54b48a04fb6df6c20553622ef32
6
+ metadata.gz: b6bf24b5aac72c3ff02b7b619bdfca517e86a54e96c5a9b4a8edf718837a8cbd4ec5ce1fe941df85a50701e9277753f81ea29e9313d6f8bd9f69126bbede5643
7
+ data.tar.gz: 01feebca673e547d9983eaf6f16f5a13224311db0ca8c77672290d88b19664c6fe7146ce8094fd7fa4a45721980e48c8c3250867921ff07616b543743db00676
@@ -2,10 +2,9 @@
2
2
 
3
3
  require 'aranha/parsers/source_address/fetch_content_error'
4
4
  require 'aranha/parsers/source_address/hash_http_base'
5
+ require 'eac_envs/http/error'
6
+ require 'eac_envs/http/request'
5
7
  require 'eac_ruby_utils/core_ext'
6
- require 'faraday'
7
- require 'faraday/follow_redirects'
8
- require 'faraday/gzip'
9
8
  require 'yaml'
10
9
 
11
10
  module Aranha
@@ -55,21 +54,11 @@ module Aranha
55
54
  source.to_yaml
56
55
  end
57
56
 
58
- # @return [Faraday]
59
- def faraday_connection
60
- ::Faraday.new do |f|
61
- f.request :gzip
62
- f.response :follow_redirects if follow_redirect?
63
- end
64
- end
65
-
66
57
  def content
67
- req = faraday_request
68
- return req.body if req.status == 200
69
-
70
- raise ::Aranha::Parsers::SourceAddress::FetchContentError.new(
71
- "Get #{url} returned #{req.status.to_i}", req
72
- )
58
+ request = http_request
59
+ request.response.body_str
60
+ rescue ::EacEnvs::Http::Error => e
61
+ raise ::Aranha::Parsers::SourceAddress::FetchContentError, e.message, request
73
62
  end
74
63
 
75
64
  def param(key, default_value)
@@ -82,11 +71,13 @@ module Aranha
82
71
 
83
72
  private
84
73
 
85
- def faraday_request_uncached
86
- faraday_connection.send(self.class.http_method, url) do |req|
87
- headers.if_present { |v| req.headers = v }
88
- body.if_present { |v| req.body = v }
89
- end
74
+ # @return [EacEnvs::Http::Request]
75
+ def http_request
76
+ r = ::EacEnvs::Http::Request.new.verb(self.class.http_method).url(url)
77
+ r = headers.if_present(r) { |v| r.headers(v) }
78
+ r = body.if_present(r) { |v| r.body(v) }
79
+ r = r.follow_redirect(true) if follow_redirect?
80
+ r
90
81
  end
91
82
  end
92
83
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  require 'addressable'
4
4
  require 'aranha/parsers/source_address/fetch_content_error'
5
- require 'faraday'
6
- require 'faraday/retry'
5
+ require 'eac_envs/http/error'
6
+ require 'eac_envs/http/request'
7
7
 
8
8
  module Aranha
9
9
  module Parsers
@@ -39,16 +39,10 @@ module Aranha
39
39
  end
40
40
 
41
41
  def content
42
- conn = ::Faraday.new do |f|
43
- f.request :retry # retry transient failures
44
- f.response :follow_redirects # follow redirects
45
- end
46
- c = conn.get(url)
47
- return c.body if c.status == 200
48
-
49
- raise ::Aranha::Parsers::SourceAddress::FetchContentError.new(
50
- "Get #{url} returned #{c.status.to_i}", c
51
- )
42
+ request = ::EacEnvs::Http::Request.new.url(url).retry(true).follow_redirect(true)
43
+ request.response.body_str
44
+ rescue ::EacEnvs::Http::Error => e
45
+ raise ::Aranha::Parsers::SourceAddress::FetchContentError, e.message, request
52
46
  end
53
47
 
54
48
  def serialize
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aranha
4
4
  module Parsers
5
- VERSION = '0.17.0'
5
+ VERSION = '0.17.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aranha-parsers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-20 00:00:00.000000000 Z
11
+ date: 2023-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '2.8'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 2.8.1
36
+ version: 2.8.3
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,43 +43,9 @@ dependencies:
43
43
  version: '2.8'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 2.8.1
46
+ version: 2.8.3
47
47
  - !ruby/object:Gem::Dependency
48
- name: eac_ruby_utils
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '0.112'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '0.112'
61
- - !ruby/object:Gem::Dependency
62
- name: faraday
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '2.7'
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 2.7.4
71
- type: :runtime
72
- prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - "~>"
76
- - !ruby/object:Gem::Version
77
- version: '2.7'
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: 2.7.4
81
- - !ruby/object:Gem::Dependency
82
- name: faraday-follow_redirects
48
+ name: eac_envs-http
83
49
  requirement: !ruby/object:Gem::Requirement
84
50
  requirements:
85
51
  - - "~>"
@@ -93,33 +59,19 @@ dependencies:
93
59
  - !ruby/object:Gem::Version
94
60
  version: '0.3'
95
61
  - !ruby/object:Gem::Dependency
96
- name: faraday-gzip
97
- requirement: !ruby/object:Gem::Requirement
98
- requirements:
99
- - - "~>"
100
- - !ruby/object:Gem::Version
101
- version: '0.1'
102
- type: :runtime
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - "~>"
107
- - !ruby/object:Gem::Version
108
- version: '0.1'
109
- - !ruby/object:Gem::Dependency
110
- name: faraday-retry
62
+ name: eac_ruby_utils
111
63
  requirement: !ruby/object:Gem::Requirement
112
64
  requirements:
113
65
  - - "~>"
114
66
  - !ruby/object:Gem::Version
115
- version: '2.1'
67
+ version: '0.112'
116
68
  type: :runtime
117
69
  prerelease: false
118
70
  version_requirements: !ruby/object:Gem::Requirement
119
71
  requirements:
120
72
  - - "~>"
121
73
  - !ruby/object:Gem::Version
122
- version: '2.1'
74
+ version: '0.112'
123
75
  - !ruby/object:Gem::Dependency
124
76
  name: nokogiri
125
77
  requirement: !ruby/object:Gem::Requirement