resync-client 0.3.0 → 0.3.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c72554545a2d19f93f85eb0b021de5516041024f
|
4
|
+
data.tar.gz: a285cc547f7c90a4bc6d1ca5ef27ae8e75b2c9fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e4600dffb2cbe106fb2454c402e84085743ccbaed5d3195564bdc79ddb96d26b1c746876aedabbc599ac1d262e6a7f16b37c4bc412b782854f65679fd15bbf4
|
7
|
+
data.tar.gz: ff4b5427c5a8fdbb88d9a56688cb908ccf3bdaae73e0aba580c202a8b30ba7f07e74dd37765e0985499802bc7c57f686672f96dfd07eaf7a499c6ccc08e2c6f9
|
data/CHANGES.md
CHANGED
@@ -9,24 +9,31 @@ module Resync
|
|
9
9
|
prepend ClientDelegator
|
10
10
|
|
11
11
|
# Delegates to {Client#get_and_parse} to get the contents of
|
12
|
-
# +:uri+ as a ResourceSync document
|
12
|
+
# +:uri+ as a ResourceSync document. The downloaded, parsed
|
13
|
+
# document will only be downloaded once; subsequent calls to
|
14
|
+
# this method will return the cached document.
|
13
15
|
def get_and_parse # rubocop:disable Style/AccessorMethodName
|
14
|
-
client.get_and_parse(uri)
|
16
|
+
@parsed_content ||= client.get_and_parse(uri)
|
15
17
|
end
|
16
18
|
|
17
|
-
# Delegates to {Client#get} to get the contents of this +:uri
|
19
|
+
# Delegates to {Client#get} to get the contents of this +:uri+.
|
20
|
+
# The downloaded content will only be downloaded once; subsequent
|
21
|
+
# calls to this method will return the cached content.
|
18
22
|
def get # rubocop:disable Style/AccessorMethodName
|
19
|
-
client.get(uri)
|
23
|
+
@content ||= client.get(uri)
|
20
24
|
end
|
21
25
|
|
22
26
|
# Delegates to {Client#download_to_temp_file} to download the
|
23
|
-
# contents of +:uri+ to a file.
|
27
|
+
# contents of +:uri+ to a file. Subsequent calls will download
|
28
|
+
# the contents again, each time to a fresh temporary file.
|
24
29
|
def download_to_temp_file # rubocop:disable Style/AccessorMethodName
|
25
30
|
client.download_to_temp_file(uri)
|
26
31
|
end
|
27
32
|
|
28
33
|
# Delegates to {Client#download_to_file} to download the
|
29
|
-
# contents of +:uri+ to the specified path.
|
34
|
+
# contents of +:uri+ to the specified path. Subsequent
|
35
|
+
# calls wiill download the contents again, potentially
|
36
|
+
# overwriting the file if given the same path.
|
30
37
|
# @param path [String] the path to download to
|
31
38
|
def download_to_file(path)
|
32
39
|
client.download_to_file(uri: uri, path: path)
|
@@ -2,6 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Resync
|
4
4
|
|
5
|
+
# TODO: Share examples
|
5
6
|
describe 'extensions' do
|
6
7
|
|
7
8
|
# ------------------------------------------------------------
|
@@ -178,6 +179,14 @@ module Resync
|
|
178
179
|
expect(client).to receive(:get_and_parse).with(@resources[0].uri) { resource }
|
179
180
|
expect(@resources[0].get_and_parse).to be(resource)
|
180
181
|
end
|
182
|
+
|
183
|
+
it 'caches the downloaded contents' do
|
184
|
+
client = instance_double(Resync::Client)
|
185
|
+
resource = instance_double(Resync::ResourceList)
|
186
|
+
@list.client = client
|
187
|
+
expect(client).to receive(:get_and_parse).once.with(@resources[0].uri) { resource }
|
188
|
+
expect(@resources[0].get_and_parse).to be(@resources[0].get_and_parse)
|
189
|
+
end
|
181
190
|
end
|
182
191
|
|
183
192
|
describe '#get' do
|
@@ -188,6 +197,14 @@ module Resync
|
|
188
197
|
expect(client).to receive(:get).with(@resources[0].uri) { data }
|
189
198
|
expect(@resources[0].get).to be(data)
|
190
199
|
end
|
200
|
+
|
201
|
+
it 'caches the downloaded contents' do
|
202
|
+
data = 'I am the contents of a resource'
|
203
|
+
client = instance_double(Resync::Client)
|
204
|
+
@list.client = client
|
205
|
+
expect(client).to receive(:get).once.with(@resources[0].uri) { data }
|
206
|
+
expect(@resources[0].get).to be(@resources[0].get)
|
207
|
+
end
|
191
208
|
end
|
192
209
|
|
193
210
|
describe '#download_to_temp_file' do
|
@@ -198,6 +215,16 @@ module Resync
|
|
198
215
|
expect(client).to receive(:download_to_temp_file).with(@resources[0].uri) { path }
|
199
216
|
expect(@resources[0].download_to_temp_file).to be(path)
|
200
217
|
end
|
218
|
+
|
219
|
+
it 'downloads anew each time' do
|
220
|
+
path1 = '/tmp/whatever1.zip'
|
221
|
+
path2 = '/tmp/whatever2.zip'
|
222
|
+
client = instance_double(Resync::Client)
|
223
|
+
@list.client = client
|
224
|
+
expect(client).to receive(:download_to_temp_file).twice.with(@resources[0].uri).and_return(path1, path2)
|
225
|
+
expect(@resources[0].download_to_temp_file).to eq(path1)
|
226
|
+
expect(@resources[0].download_to_temp_file).to eq(path2)
|
227
|
+
end
|
201
228
|
end
|
202
229
|
|
203
230
|
describe '#download_to_file' do
|
@@ -208,6 +235,14 @@ module Resync
|
|
208
235
|
expect(client).to receive(:download_to_file).with(uri: @resources[0].uri, path: path) { path }
|
209
236
|
expect(@resources[0].download_to_file(path)).to be(path)
|
210
237
|
end
|
238
|
+
|
239
|
+
it 'downloads anew each time' do
|
240
|
+
path = '/tmp/whatever.zip'
|
241
|
+
client = instance_double(Resync::Client)
|
242
|
+
@list.client = client
|
243
|
+
expect(client).to receive(:download_to_file).twice.with(uri: @resources[0].uri, path: path) { path }
|
244
|
+
expect(@resources[0].download_to_file(path)).to eq(@resources[0].download_to_file(path))
|
245
|
+
end
|
211
246
|
end
|
212
247
|
end
|
213
248
|
|
@@ -220,6 +255,14 @@ module Resync
|
|
220
255
|
expect(client).to receive(:get_and_parse).with(@links[0].uri) { resource }
|
221
256
|
expect(@links[0].get_and_parse).to be(resource)
|
222
257
|
end
|
258
|
+
|
259
|
+
it 'caches the downloaded contents' do
|
260
|
+
client = instance_double(Resync::Client)
|
261
|
+
resource = instance_double(Resync::ResourceList)
|
262
|
+
@list.client = client
|
263
|
+
expect(client).to receive(:get_and_parse).once.with(@links[0].uri) { resource }
|
264
|
+
expect(@links[0].get_and_parse).to be(@links[0].get_and_parse)
|
265
|
+
end
|
223
266
|
end
|
224
267
|
|
225
268
|
describe '#get' do
|
@@ -230,11 +273,19 @@ module Resync
|
|
230
273
|
expect(client).to receive(:get).with(@links[0].uri) { data }
|
231
274
|
expect(@links[0].get).to be(data)
|
232
275
|
end
|
276
|
+
|
277
|
+
it 'caches the downloaded contents' do
|
278
|
+
data = 'I am the contents of a link'
|
279
|
+
client = instance_double(Resync::Client)
|
280
|
+
@list.client = client
|
281
|
+
expect(client).to receive(:get).once.with(@links[0].uri) { data }
|
282
|
+
expect(@links[0].get).to be(@links[0].get)
|
283
|
+
end
|
233
284
|
end
|
234
285
|
|
235
286
|
describe '#download_to_temp_file' do
|
236
287
|
it 'downloads the link contents to a file using the injected client' do
|
237
|
-
path = '/tmp/
|
288
|
+
path = '/tmp/whatever1.zip'
|
238
289
|
client = instance_double(Resync::Client)
|
239
290
|
@list.client = client
|
240
291
|
expect(client).to receive(:download_to_temp_file).with(@links[0].uri) { path }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resync-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Moles
|
@@ -248,9 +248,9 @@ files:
|
|
248
248
|
- spec/unit/resync/client/client_spec.rb
|
249
249
|
- spec/unit/resync/client/dump_index_spec.rb
|
250
250
|
- spec/unit/resync/client/dump_spec.rb
|
251
|
-
- spec/unit/resync/client/extensions_spec.rb
|
252
251
|
- spec/unit/resync/client/http_helper_spec.rb
|
253
252
|
- spec/unit/resync/client/list_index_spec.rb
|
253
|
+
- spec/unit/resync/client/mixins_spec.rb
|
254
254
|
- spec/unit/resync/client/zip_package_spec.rb
|
255
255
|
homepage: http://github.com/dmolesUC3/resync-client
|
256
256
|
licenses:
|
@@ -313,8 +313,8 @@ test_files:
|
|
313
313
|
- spec/unit/resync/client/client_spec.rb
|
314
314
|
- spec/unit/resync/client/dump_index_spec.rb
|
315
315
|
- spec/unit/resync/client/dump_spec.rb
|
316
|
-
- spec/unit/resync/client/extensions_spec.rb
|
317
316
|
- spec/unit/resync/client/http_helper_spec.rb
|
318
317
|
- spec/unit/resync/client/list_index_spec.rb
|
318
|
+
- spec/unit/resync/client/mixins_spec.rb
|
319
319
|
- spec/unit/resync/client/zip_package_spec.rb
|
320
320
|
has_rdoc:
|