restful_resource 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bde6cf5ec5aad431ca3e9d06e2fad1787d8060dd
4
- data.tar.gz: 6d9a8f2062d2952df9b6d3f3fc1413d093469046
3
+ metadata.gz: 03a7e9a15a400320a4a636f9d010e65e34880b49
4
+ data.tar.gz: ebcae394889e3a8dbe9193a8a43a07d6377aa911
5
5
  SHA512:
6
- metadata.gz: 9a8f4f98f262ef51cf3219acacffc48b2cc1e74d453fa16f71bf224bd49b5238966b30bc9c435f0f76b7d8ea09a2491c259b6166b28edd230cfd6da319a78a56
7
- data.tar.gz: 1e73b6228ba3143e96eec6f2d98ea2014d8061654f30fc34bdf48e8749c07479a1a40cccd5226cd2afc1f12aeb73412f70429224632772d003dc84bdea97a621
6
+ metadata.gz: 3a22f16b829e19e92215c00cadf942b042026cba134aefc4f75bcdaeab66dfdc20b23a6608c639bdfb8faf4fdf07b067f56ff3f2836208f71d80f15410fffb09
7
+ data.tar.gz: 5980a0c3537c0147a947c1470df0f7a79f9850b30377a03bae1dcf699049c9f6f01b74c5e97949d28b94c78fc6bbef2c07cb391aa68a470cce968d3fe79d1fe6
data/.gitignore CHANGED
@@ -16,3 +16,5 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  .idea
19
+ *.swp
20
+ *.swo
@@ -7,7 +7,8 @@ module RestfulResource
7
7
  password: nil,
8
8
  logger: nil,
9
9
  cache_store: nil,
10
- instrumentation: {})
10
+ instrumentation: {},
11
+ faraday_config: nil)
11
12
 
12
13
  @base_url = URI.parse(base_url)
13
14
 
@@ -15,7 +16,8 @@ module RestfulResource
15
16
  password: password,
16
17
  logger: logger,
17
18
  cache_store: cache_store,
18
- instrumentation: instrumentation)
19
+ instrumentation: instrumentation,
20
+ faraday_config: faraday_config)
19
21
  end
20
22
 
21
23
  def self.resource_path(url)
@@ -69,7 +69,8 @@ module RestfulResource
69
69
  connection: nil,
70
70
  instrumentation: {},
71
71
  open_timeout: 2,
72
- timeout: 10)
72
+ timeout: 10,
73
+ faraday_config: nil)
73
74
  api_name = instrumentation[:api_name] ||= 'api'
74
75
  instrumentation[:request_instrument_name] ||= "http.#{api_name}"
75
76
  instrumentation[:cache_instrument_name] ||= "http_cache.#{api_name}"
@@ -91,7 +92,8 @@ module RestfulResource
91
92
  instrumenter: ActiveSupport::Notifications,
92
93
  request_instrument_name: instrumentation.fetch(:request_instrument_name, nil),
93
94
  cache_instrument_name: instrumentation.fetch(:cache_instrument_name, nil),
94
- server_cache_instrument_name: instrumentation.fetch(:server_cache_instrument_name, nil))
95
+ server_cache_instrument_name: instrumentation.fetch(:server_cache_instrument_name, nil),
96
+ faraday_config: faraday_config)
95
97
 
96
98
  @connection.basic_auth(username, password) if username && password
97
99
  @default_open_timeout = open_timeout
@@ -157,7 +159,8 @@ module RestfulResource
157
159
  instrumenter: nil,
158
160
  request_instrument_name: nil,
159
161
  cache_instrument_name: nil,
160
- server_cache_instrument_name: nil)
162
+ server_cache_instrument_name: nil,
163
+ faraday_config: nil)
161
164
 
162
165
  @connection = Faraday.new do |b|
163
166
  b.request :json
@@ -183,6 +186,10 @@ module RestfulResource
183
186
  b.use :instrumentation, name: request_instrument_name
184
187
  end
185
188
 
189
+ if faraday_config
190
+ faraday_config.call(b)
191
+ end
192
+
186
193
  b.response :encoding
187
194
  b.use :gzip
188
195
 
@@ -1,3 +1,3 @@
1
1
  module RestfulResource
2
- VERSION = '2.2.1'
2
+ VERSION = '2.2.2'
3
3
  end
@@ -310,6 +310,32 @@ RSpec.describe RestfulResource::Base do
310
310
  end
311
311
  end
312
312
 
313
+ describe ".configure" do
314
+ let(:username) { double }
315
+ let(:password) { double }
316
+ let(:logger) { double }
317
+ let(:cache_store) { double }
318
+ let(:instrumentation) { double }
319
+ let(:faraday_config) { double }
320
+
321
+ it "passes arguments to HttpClient" do
322
+ expect(RestfulResource::HttpClient).to receive(:new).with(username: username,
323
+ password: password,
324
+ logger: logger,
325
+ cache_store: cache_store,
326
+ instrumentation: instrumentation,
327
+ faraday_config: faraday_config)
328
+
329
+ RestfulResource::Base.configure(base_url: 'http://foo.bar',
330
+ username: username,
331
+ password: password,
332
+ logger: logger,
333
+ cache_store: cache_store,
334
+ instrumentation: instrumentation,
335
+ faraday_config: faraday_config)
336
+ end
337
+ end
338
+
313
339
  def response_with_page_information
314
340
  RestfulResource::Response.new(body: [{ id: 1, name: 'Golf'}, { id: 2, name: 'Polo' }].to_json,
315
341
  headers: { links: '<http://api.carwow.co.uk/makes/Volkswagen/models.json?page=6>;rel="last",<http://api.carwow.co.uk/makes/Volkswagen/models.json?page=2>;rel="next"'})
@@ -137,6 +137,18 @@ describe RestfulResource::HttpClient do
137
137
  end
138
138
  end
139
139
  end
140
+
141
+ describe 'when provided a faraday config block' do
142
+ let(:faraday_config_block) do
143
+ proc { |conn| @block_arg = conn }
144
+ end
145
+ let(:connection) { described_class.new(faraday_config: faraday_config_block).instance_variable_get("@connection") }
146
+
147
+ it 'passes faraday connection instance and calls it' do
148
+ connection
149
+ expect(@block_arg.class).to eq(Faraday::Connection)
150
+ end
151
+ end
140
152
  end
141
153
  end
142
154
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Santoro
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-11-06 00:00:00.000000000 Z
12
+ date: 2018-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -258,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
258
  version: '0'
259
259
  requirements: []
260
260
  rubyforge_project:
261
- rubygems_version: 2.5.2
261
+ rubygems_version: 2.6.13
262
262
  signing_key:
263
263
  specification_version: 4
264
264
  summary: A simple activerecord inspired rest resource base class implemented using