network-client 2.0.1 → 2.0.2

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
  SHA1:
3
- metadata.gz: 8d744e4ef7f2447c1bcc600b3ce026b2de61fcfe
4
- data.tar.gz: c31e62ada023d7b11efc60c709393943fb407141
3
+ metadata.gz: 56aada63bd81789e38be5a2342d81fdf796e7268
4
+ data.tar.gz: ef57566bb79e5d3d7da617c3e7db3c48b93f0c0a
5
5
  SHA512:
6
- metadata.gz: 458e8ff4353c3bf358aadfd25a1ac3ee6dba002b7067e3b373be44d6c33c608b72bb13e7e60d469534056113e7ddbbbdd216ff1424cc2988303cb25891417277
7
- data.tar.gz: 474215650614bd145967951af5a3ffc5011c780225137e6e1dc49fb2c4175d595b9d92cf291ef8daa6982f631683fc93cf472ff0be69da8846e1dc6ad4f82ce1
6
+ metadata.gz: 5e47c917bd8e65d96b9930cd23d6a6c2002eb80c13fe3559bf9939a3e52b9137b9c81c287246ada29ddbd5bc1ad622d03848718f1f38f807b9f6f87f22a52741
7
+ data.tar.gz: 410bea9155649cc9141d2f14c67144d9a27ca41c9aaa32b3d9b1051ee2091188c4b0da15d9455cfa1cfd7f172038722204ef60e9ee66e6ca08e4f7ff2ffa1e7a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- network-client (2.0.1)
4
+ network-client (2.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -46,8 +46,7 @@ We can perform the following requests:
46
46
  ```ruby
47
47
  client.get '/todos/10'
48
48
 
49
- #=> #<struct Network::Client::Response code=200,
50
- body={"userId"=>1, "id"=>10, "title"=>"illo est ...", "completed"=>true}>
49
+ #=> #<struct Network::Client::Response code=200, body={"userId"=>1, "id"=>10, "title"=>"illo est ...", "completed"=>true}>
51
50
  ```
52
51
 
53
52
  * **POST**
@@ -55,8 +54,7 @@ We can perform the following requests:
55
54
  ```ruby
56
55
  client.post '/todos', params: { title: 'foo bar', completed: 'false', userId: 1 }.to_json
57
56
 
58
- #=> #<struct Network::Client::Response code=201,
59
- body={"title"=>"foo bar", "completed"=>false, "userId"=>1, "id"=>201}>
57
+ #=> #<struct Network::Client::Response code=201, body={"title"=>"foo bar", "completed"=>false, "userId"=>1, "id"=>201}>
60
58
  ```
61
59
 
62
60
  * **PATCH**
@@ -64,8 +62,7 @@ We can perform the following requests:
64
62
  ```ruby
65
63
  client.patch '/todos/10', params: { title: 'new title' }.to_json
66
64
 
67
- #=> #<struct Network::Client::Response code=200,
68
- body={"userId"=>1, "id"=>10, "title"=>"new title", "completed"=>true}>
65
+ #=> #<struct Network::Client::Response code=200, body={"userId"=>1, "id"=>10, "title"=>"new title", "completed"=>true}>
69
66
  ```
70
67
 
71
68
  * **PUT**
@@ -91,9 +88,8 @@ It holds the response's HTTP code and body parsed as JSON.
91
88
 
92
89
  ```ruby
93
90
  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 ..." }
91
+ response.code #=> 200
92
+ response.body #=> { "userId"=>3, "id"=>30, "title"=>"a quo magni similique perferendis", "body"=>"alias dolor cumque ..." }
97
93
  ```
98
94
 
99
95
  #### Setting Request Headers
@@ -121,20 +117,20 @@ client.get 'posts/', headers: { 'X-SPECIAL-KEY' => '123456' }
121
117
  client = Network::Client.new(endpoint: 'https://api.example.com',
122
118
  username: 'ABC',
123
119
  password: '999')
124
- client.username #=> "ABC"
125
- client.password #=> "999"
120
+ client.username #=> "ABC"
121
+ client.password #=> "999"
126
122
 
127
123
  # or via `#set_basic_auth`:
128
124
 
129
125
  client.set_basic_auth('John Doe', '112233')
130
- client.username #=> "John Doe"
131
- client.password #=> "112233"
126
+ client.username #=> "John Doe"
127
+ client.password #=> "112233"
132
128
  ```
133
129
 
134
130
  2. **OAuth Bearer:**
135
131
  ```ruby
136
132
  client.set_bearer_auth(token: 'e08f7739c3abb78c')
137
- client.bearer_token
133
+ client.bearer_token
138
134
  #=> "e08f7739c3abb78c"
139
135
  ```
140
136
 
@@ -150,14 +146,14 @@ You can set the user agent header during initialization:
150
146
 
151
147
  ```ruby
152
148
  client = Network::Client.new(endpoint: 'https://maps.googleapis.com', user_agent: 'App Service')
153
- client.user_agent #=> "App Service"
149
+ client.user_agent #=> "App Service"
154
150
  ```
155
151
 
156
152
  Or later on via `#set_user_agent` method:
157
153
 
158
154
  ```ruby
159
155
  client.set_user_agent('Gateway Server')
160
- client.user_agent #=> "Gateway Server"
156
+ client.user_agent #=> "Gateway Server"
161
157
  ```
162
158
 
163
159
  The default user agent is `Network Client`.
@@ -167,7 +163,7 @@ Set the `tries:` named argument to define the number of tries when request fails
167
163
 
168
164
  ```ruby
169
165
  client = Network::Client.new(endpoint: 'https://api.foursquare.com', tries: 3)
170
- client.tries #=> 3
166
+ client.tries #=> 3
171
167
  ```
172
168
 
173
169
  The default `#tries` is 2.
@@ -177,15 +173,11 @@ To retrieve or extend the list of triable errors through `#errors_to_recover`:
177
173
  ```ruby
178
174
  client.errors_to_recover
179
175
 
180
- #=> [Net::HTTPTooManyRequests, Net::HTTPServerError, Net::ProtocolError,
181
- Net::HTTPBadResponse,Net::ReadTimeout, Net::OpenTimeout, Errno::ECONNREFUSED,
182
- Errno::ETIMEDOUT, OpenSSL::SSL::SSLError, SocketError]
176
+ #=> [Net::HTTPTooManyRequests, Net::HTTPServerError, Net::ProtocolError, Net::HTTPBadResponse,Net::ReadTimeout, Net::OpenTimeout, Errno::ECONNREFUSED, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError, SocketError]
183
177
 
184
178
  client.errors_to_recover << Net::HTTPRequestTimeOut
185
179
 
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]
180
+ #=> [Net::HTTPTooManyRequests, Net::HTTPServerError, Net::ProtocolError, Net::HTTPBadResponse,Net::ReadTimeout, Net::OpenTimeout, Errno::ECONNREFUSED, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError, SocketError, Net::HTTPRequestTimeOut]
189
181
  ```
190
182
 
191
183
  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
  #
@@ -1,3 +1,3 @@
1
1
  module Network
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  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: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdullah Barrak (abarrak)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-02 00:00:00.000000000 Z
11
+ date: 2017-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler