network-client 2.0.1 → 3.0.0

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
- SHA1:
3
- metadata.gz: 8d744e4ef7f2447c1bcc600b3ce026b2de61fcfe
4
- data.tar.gz: c31e62ada023d7b11efc60c709393943fb407141
2
+ SHA256:
3
+ metadata.gz: bcefe9135ac3d265c22e2c9b2e241a3841f7bc75dc61c24b505e43b7d69e3171
4
+ data.tar.gz: 89b76915e7c3ef5d5d2274ef8fbb01a4bad64cb86c2c7f33f211dd66873b72ac
5
5
  SHA512:
6
- metadata.gz: 458e8ff4353c3bf358aadfd25a1ac3ee6dba002b7067e3b373be44d6c33c608b72bb13e7e60d469534056113e7ddbbbdd216ff1424cc2988303cb25891417277
7
- data.tar.gz: 474215650614bd145967951af5a3ffc5011c780225137e6e1dc49fb2c4175d595b9d92cf291ef8daa6982f631683fc93cf472ff0be69da8846e1dc6ad4f82ce1
6
+ metadata.gz: 6f35222a252a1d94ca76fd0cb4c7e2368915f0ef053106bb005a23385d734d328ac1c8121bf99696a69d83ba497fdd29841de34115a6af969a29b8b2a4b84bc6
7
+ data.tar.gz: 9973132d65b81708625d1bec0b1e3dcb107e332829b302e0b0982c51e6e35f21cf29f784226e6a4f2024e59451ace08d970fb665807a4008f56c8c65f346f2fb
@@ -0,0 +1,9 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: bundler
5
+ directory: '/'
6
+ versioning-strategy: increase
7
+ schedule:
8
+ interval: monthly
9
+ open-pull-requests-limit: 1
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.5.5
data/.travis.yml CHANGED
@@ -1,9 +1,18 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.2.4
5
- - 2.3.1
6
- - 2.4.0
7
- - 2.4.1
4
+ - 2.5.0
5
+ - 2.6.0
6
+ - 2.7.0
7
+ - 3.0.0
8
+ before_install: gem install bundler -v 2.2.24
9
+ install: bundle install --jobs=3 --retry=3
8
10
  cache: bundler
9
- before_install: gem install bundler
11
+ before_script:
12
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
13
+ - chmod +x ./cc-test-reporter
14
+ - ./cc-test-reporter before-build
15
+ script:
16
+ - bundle exec rspec
17
+ after_script:
18
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile.lock CHANGED
@@ -1,62 +1,64 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- network-client (2.0.1)
4
+ network-client (2.0.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- activesupport (5.1.1)
9
+ activesupport (6.1.4)
10
10
  concurrent-ruby (~> 1.0, >= 1.0.2)
11
- i18n (~> 0.7)
12
- minitest (~> 5.1)
13
- tzinfo (~> 1.1)
11
+ i18n (>= 1.6, < 2)
12
+ minitest (>= 5.1)
13
+ tzinfo (~> 2.0)
14
+ zeitwerk (~> 2.3)
14
15
  codeclimate-test-reporter (1.0.7)
15
16
  simplecov
16
- concurrent-ruby (1.0.5)
17
- diff-lcs (1.3)
18
- docile (1.1.5)
19
- dotenv (2.2.1)
20
- factory_girl (4.8.0)
21
- activesupport (>= 3.0.0)
22
- i18n (0.8.1)
23
- json (2.1.0)
24
- minitest (5.10.2)
25
- rake (10.5.0)
26
- rspec (3.6.0)
27
- rspec-core (~> 3.6.0)
28
- rspec-expectations (~> 3.6.0)
29
- rspec-mocks (~> 3.6.0)
30
- rspec-core (3.6.0)
31
- rspec-support (~> 3.6.0)
32
- rspec-expectations (3.6.0)
17
+ concurrent-ruby (1.1.9)
18
+ diff-lcs (1.4.4)
19
+ docile (1.4.0)
20
+ dotenv (2.7.6)
21
+ factory_bot (6.2.0)
22
+ activesupport (>= 5.0.0)
23
+ i18n (1.8.10)
24
+ concurrent-ruby (~> 1.0)
25
+ minitest (5.14.4)
26
+ rake (13.0.6)
27
+ rspec (3.10.0)
28
+ rspec-core (~> 3.10.0)
29
+ rspec-expectations (~> 3.10.0)
30
+ rspec-mocks (~> 3.10.0)
31
+ rspec-core (3.10.1)
32
+ rspec-support (~> 3.10.0)
33
+ rspec-expectations (3.10.1)
33
34
  diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.6.0)
35
- rspec-mocks (3.6.0)
35
+ rspec-support (~> 3.10.0)
36
+ rspec-mocks (3.10.2)
36
37
  diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.6.0)
38
- rspec-support (3.6.0)
39
- simplecov (0.14.1)
40
- docile (~> 1.1.0)
41
- json (>= 1.8, < 3)
42
- simplecov-html (~> 0.10.0)
43
- simplecov-html (0.10.0)
44
- thread_safe (0.3.6)
45
- tzinfo (1.2.3)
46
- thread_safe (~> 0.1)
38
+ rspec-support (~> 3.10.0)
39
+ rspec-support (3.10.2)
40
+ simplecov (0.21.2)
41
+ docile (~> 1.1)
42
+ simplecov-html (~> 0.11)
43
+ simplecov_json_formatter (~> 0.1)
44
+ simplecov-html (0.12.3)
45
+ simplecov_json_formatter (0.1.3)
46
+ tzinfo (2.0.4)
47
+ concurrent-ruby (~> 1.0)
48
+ zeitwerk (2.4.2)
47
49
 
48
50
  PLATFORMS
49
51
  ruby
50
52
 
51
53
  DEPENDENCIES
52
- bundler (~> 1.14)
54
+ bundler (~> 2.2.20)
53
55
  codeclimate-test-reporter (~> 1.0)
54
- dotenv (~> 2.2)
55
- factory_girl (~> 4.5)
56
+ dotenv (~> 2.7)
57
+ factory_bot (~> 6.2)
56
58
  network-client!
57
- rake (~> 10.0)
59
+ rake (~> 13.0)
58
60
  rspec (~> 3.6)
59
- simplecov (~> 0.14.1)
61
+ simplecov (~> 0.21)
60
62
 
61
63
  BUNDLED WITH
62
- 1.14.6
64
+ 2.2.24
data/README.md CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/network-client.svg)](https://rubygems.org/gems/network-client)
4
4
  [![Gem](https://img.shields.io/gem/dt/network-client.svg?colorB=8b0000)](https://rubygems.org/gems/network-client)
5
- [![Build Status](https://travis-ci.org/abarrak/network-client.svg?branch=master)](https://travis-ci.org/abarrak/network-client)
6
- [![Dependency Status](https://gemnasium.com/badges/github.com/abarrak/network-client.svg)](https://gemnasium.com/github.com/abarrak/network-client)
5
+ [![Build Status](https://www.travis-ci.com/abarrak/network-client.svg?branch=master)](https://www.travis-ci.com/abarrak/network-client)
7
6
  [![Test Coverage](https://codeclimate.com/github/abarrak/network-client/badges/coverage.svg)](https://codeclimate.com/github/abarrak/network-client/coverage)
8
7
  [![Code Climate](https://lima.codeclimate.com/github/abarrak/network-client/badges/gpa.svg)](https://lima.codeclimate.com/github/abarrak/network-client)
9
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -46,8 +45,7 @@ We can perform the following requests:
46
45
  ```ruby
47
46
  client.get '/todos/10'
48
47
 
49
- #=> #<struct Network::Client::Response code=200,
50
- body={"userId"=>1, "id"=>10, "title"=>"illo est ...", "completed"=>true}>
48
+ #=> #<struct Network::Client::Response code=200, body={"userId"=>1, "id"=>10, "title"=>"illo est ...", "completed"=>true}>
51
49
  ```
52
50
 
53
51
  * **POST**
@@ -55,8 +53,7 @@ We can perform the following requests:
55
53
  ```ruby
56
54
  client.post '/todos', params: { title: 'foo bar', completed: 'false', userId: 1 }.to_json
57
55
 
58
- #=> #<struct Network::Client::Response code=201,
59
- body={"title"=>"foo bar", "completed"=>false, "userId"=>1, "id"=>201}>
56
+ #=> #<struct Network::Client::Response code=201, body={"title"=>"foo bar", "completed"=>false, "userId"=>1, "id"=>201}>
60
57
  ```
61
58
 
62
59
  * **PATCH**
@@ -64,8 +61,7 @@ We can perform the following requests:
64
61
  ```ruby
65
62
  client.patch '/todos/10', params: { title: 'new title' }.to_json
66
63
 
67
- #=> #<struct Network::Client::Response code=200,
68
- body={"userId"=>1, "id"=>10, "title"=>"new title", "completed"=>true}>
64
+ #=> #<struct Network::Client::Response code=200, body={"userId"=>1, "id"=>10, "title"=>"new title", "completed"=>true}>
69
65
  ```
70
66
 
71
67
  * **PUT**
@@ -91,9 +87,8 @@ It holds the response's HTTP code and body parsed as JSON.
91
87
 
92
88
  ```ruby
93
89
  response = client.get '/posts/30'
94
- response.code #=> 200
95
- response.body #=> { "userId"=>3, "id"=>30, "title"=>"a quo magni similique perferendis",
96
- "body"=>"alias dolor cumque ..." }
90
+ response.code #=> 200
91
+ response.body #=> { "userId"=>3, "id"=>30, "title"=>"a quo magni similique perferendis", "body"=>"alias dolor cumque ..." }
97
92
  ```
98
93
 
99
94
  #### Setting Request Headers
@@ -121,20 +116,20 @@ client.get 'posts/', headers: { 'X-SPECIAL-KEY' => '123456' }
121
116
  client = Network::Client.new(endpoint: 'https://api.example.com',
122
117
  username: 'ABC',
123
118
  password: '999')
124
- client.username #=> "ABC"
125
- client.password #=> "999"
119
+ client.username #=> "ABC"
120
+ client.password #=> "999"
126
121
 
127
122
  # or via `#set_basic_auth`:
128
123
 
129
124
  client.set_basic_auth('John Doe', '112233')
130
- client.username #=> "John Doe"
131
- client.password #=> "112233"
125
+ client.username #=> "John Doe"
126
+ client.password #=> "112233"
132
127
  ```
133
128
 
134
129
  2. **OAuth Bearer:**
135
130
  ```ruby
136
131
  client.set_bearer_auth(token: 'e08f7739c3abb78c')
137
- client.bearer_token
132
+ client.bearer_token
138
133
  #=> "e08f7739c3abb78c"
139
134
  ```
140
135
 
@@ -150,14 +145,14 @@ You can set the user agent header during initialization:
150
145
 
151
146
  ```ruby
152
147
  client = Network::Client.new(endpoint: 'https://maps.googleapis.com', user_agent: 'App Service')
153
- client.user_agent #=> "App Service"
148
+ client.user_agent #=> "App Service"
154
149
  ```
155
150
 
156
151
  Or later on via `#set_user_agent` method:
157
152
 
158
153
  ```ruby
159
154
  client.set_user_agent('Gateway Server')
160
- client.user_agent #=> "Gateway Server"
155
+ client.user_agent #=> "Gateway Server"
161
156
  ```
162
157
 
163
158
  The default user agent is `Network Client`.
@@ -167,7 +162,7 @@ Set the `tries:` named argument to define the number of tries when request fails
167
162
 
168
163
  ```ruby
169
164
  client = Network::Client.new(endpoint: 'https://api.foursquare.com', tries: 3)
170
- client.tries #=> 3
165
+ client.tries #=> 3
171
166
  ```
172
167
 
173
168
  The default `#tries` is 2.
@@ -177,15 +172,11 @@ To retrieve or extend the list of triable errors through `#errors_to_recover`:
177
172
  ```ruby
178
173
  client.errors_to_recover
179
174
 
180
- #=> [Net::HTTPTooManyRequests, Net::HTTPServerError, Net::ProtocolError,
181
- Net::HTTPBadResponse,Net::ReadTimeout, Net::OpenTimeout, Errno::ECONNREFUSED,
182
- Errno::ETIMEDOUT, OpenSSL::SSL::SSLError, SocketError]
175
+ #=> [Net::HTTPTooManyRequests, Net::HTTPServerError, Net::ProtocolError, Net::HTTPBadResponse,Net::ReadTimeout, Net::OpenTimeout, Errno::ECONNREFUSED, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError, SocketError]
183
176
 
184
177
  client.errors_to_recover << Net::HTTPRequestTimeOut
185
178
 
186
- #=> [Net::HTTPTooManyRequests, Net::HTTPServerError, Net::ProtocolError,
187
- Net::HTTPBadResponse,Net::ReadTimeout, Net::OpenTimeout, Errno::ECONNREFUSED,
188
- Errno::ETIMEDOUT, OpenSSL::SSL::SSLError, SocketError, Net::HTTPRequestTimeOut]
179
+ #=> [Net::HTTPTooManyRequests, Net::HTTPServerError, Net::ProtocolError, Net::HTTPBadResponse,Net::ReadTimeout, Net::OpenTimeout, Errno::ECONNREFUSED, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError, SocketError, Net::HTTPRequestTimeOut]
189
180
  ```
190
181
 
191
182
  The list of `errors_to_propagate` takes precedence over `errors_to_recover`, and they are not retried.
@@ -32,6 +32,9 @@ module Network
32
32
  # Do not assign ancestor error classes here that prevent retry for descendant ones.
33
33
  attr_accessor :errors_to_propagate
34
34
 
35
+ # Gives access to underlying NET::HTTP client instance.
36
+ attr_accessor :http
37
+
35
38
  ##
36
39
  # Construct and prepare client for requests targeting +endpoint+.
37
40
  #
@@ -240,10 +243,17 @@ module Network
240
243
  Net::OpenTimeout,
241
244
  Errno::ECONNREFUSED,
242
245
  Errno::ETIMEDOUT,
246
+ Errno::ECONNRESET,
247
+ Errno::EHOSTUNREACH,
248
+ Timeout::Error,
243
249
  OpenSSL::SSL::SSLError,
244
- SocketError]
250
+ EOFError,
251
+ SocketError,
252
+ IOError]
245
253
  @errors_to_propagate = [Net::HTTPRequestURITooLarge,
246
- Net::HTTPMethodNotAllowed]
254
+ Net::HTTPMethodNotAllowed,
255
+ Zlib::BufError,
256
+ OpenSSL::X509::CertificateError]
247
257
  end
248
258
 
249
259
  def request_json(http_method, path, params, headers)
@@ -1,3 +1,3 @@
1
1
  module Network
2
- VERSION = "2.0.1"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -24,11 +24,11 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.require_paths = %w(lib)
26
26
 
27
- spec.add_development_dependency "bundler", "~> 1.14"
28
- spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "bundler", "~> 2.2.20"
28
+ spec.add_development_dependency "rake", "~> 13.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.6"
30
- spec.add_development_dependency "factory_girl", "~> 4.5"
31
- spec.add_development_dependency "simplecov", "~> 0.14.1"
30
+ spec.add_development_dependency "factory_bot", "~> 6.2"
31
+ spec.add_development_dependency "simplecov", "~> 0.21"
32
32
  spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0"
33
- spec.add_development_dependency "dotenv", "~> 2.2"
33
+ spec.add_development_dependency "dotenv", "~> 2.7"
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: network-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdullah Barrak (abarrak)
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-02 00:00:00.000000000 Z
11
+ date: 2021-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.14'
19
+ version: 2.2.20
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.14'
26
+ version: 2.2.20
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,33 +53,33 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.6'
55
55
  - !ruby/object:Gem::Dependency
56
- name: factory_girl
56
+ name: factory_bot
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '4.5'
61
+ version: '6.2'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '4.5'
68
+ version: '6.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.14.1
75
+ version: '0.21'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.14.1
82
+ version: '0.21'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: codeclimate-test-reporter
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '2.2'
103
+ version: '2.7'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '2.2'
110
+ version: '2.7'
111
111
  description: network-client is a drop-in thin layer on top of Net::HTTP classes for JSON
112
112
  web requests with retry functionality and simple error handling
113
113
  email:
@@ -116,6 +116,7 @@ executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
+ - ".github/dependabot.yml"
119
120
  - ".gitignore"
120
121
  - ".rspec"
121
122
  - ".ruby-gemset"
@@ -134,7 +135,7 @@ homepage: https://github.com/abarrak/network-client
134
135
  licenses:
135
136
  - MIT
136
137
  metadata: {}
137
- post_install_message:
138
+ post_install_message:
138
139
  rdoc_options: []
139
140
  require_paths:
140
141
  - lib
@@ -149,9 +150,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
150
  - !ruby/object:Gem::Version
150
151
  version: '0'
151
152
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.6.11
154
- signing_key:
153
+ rubyforge_project:
154
+ rubygems_version: 2.7.6.2
155
+ signing_key:
155
156
  specification_version: 4
156
157
  summary: A thin resilient JSON web client built around Net::HTTP
157
158
  test_files: []