resync-client 0.3.2 → 0.3.3

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: bd8d1fac9a7feece07634eca0cb2b9b4e9d2ce93
4
- data.tar.gz: 27e94c732902e0f9b42be6ce9ec9df74f16d641a
3
+ metadata.gz: b55fd1ce8dd18d7acd6b75515e5a31393d5e114f
4
+ data.tar.gz: fa122d38b47bb1399663f89b730b6cd763b1f603
5
5
  SHA512:
6
- metadata.gz: 188aab78224fc2e642aa7759a3c9c5a4a97d156c332ef66df771d6a305758126b64352ff9651d6c68ccff3bb3da226d1f47d7f83b22ff0abc5576ed1bc13d0f9
7
- data.tar.gz: 4eebbc3ba5cb6ecb5115eec09015d22fca5155a4da3fb79e6b4c99ac99c935fbda05cc93d4b444483f4a0273483306560df4d0e2bf5859a879106049e4c10b89
6
+ metadata.gz: 71704d10c967d97d1d260b79d405ac047c2c38a3c41dbacca9b2ffdff5477aa2898a324f10cb734e6f92bd42dc89fbe073f23715454b0dfa75308408264d5c7f
7
+ data.tar.gz: e171456275ef6cbc7416781343977d4f0e8b7f243253a5fcb238e0ef0e51957599bb9e0ee350ca0704f9e4c980f639c1c78f12c31f464a0b1a47591ec7212c5e
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.3.3
2
+
3
+ - Make `#all_zip_packages` on `ChangeDump` and `ResourceDump` return `Enumerator::Lazy` to improve interoperation with the corresponding methods on `ResourceDumpIndex/ChangeDumpIndex`
4
+
1
5
  # 0.3.2
2
6
 
3
7
  - Added utility methods to `CapabilityList` to simplify downloading and parsing ResourceSync documents by capability
@@ -26,19 +26,19 @@ module Resync
26
26
  @zip_packages ||= resources.map { |r| Lazy.promise { r.zip_package } }
27
27
  end
28
28
 
29
- # Aliases +:zip_packages+ as +:all_zip_packages+ for transparent
30
- # interoperability between +ResourceDump+ and +ResourceDumpIndex+,
31
- # +ChangeDump+ and +ChangeDumpIndex+
32
- def self.prepended(ext)
33
- ext.send(:alias_method, :all_zip_packages, :zip_packages)
34
- end
35
-
36
29
  end
37
30
  end
38
31
  end
39
32
 
40
33
  class ResourceDump
41
34
  prepend Client::Mixins::Dump
35
+
36
+ # Delegates to {#zip_packages} for interoperation with {DumpIndex#all_zip_packages}.
37
+ # @return [Enumerator::Lazy<Resync::Resource>] a lazy enumeration of the packages for each
38
+ # resource
39
+ def all_zip_packages
40
+ zip_packages.lazy
41
+ end
42
42
  end
43
43
 
44
44
  class ChangeDump
@@ -59,6 +59,11 @@ module Resync
59
59
  end
60
60
  end
61
61
 
62
- alias_method :all_zip_packages, :zip_packages
62
+ # Delegates to {#zip_packages} for interoperation with {ChangeDumpIndex#all_zip_packages}.
63
+ # @return [Enumerator::Lazy<Resync::Resource>] a lazy enumeration of the packages for each
64
+ # resource
65
+ def all_zip_packages(in_range: nil)
66
+ zip_packages(in_range: in_range).lazy
67
+ end
63
68
  end
64
69
  end
@@ -11,7 +11,7 @@ module Resync
11
11
  # Downloads and parses each resource list and returns a flattened enumeration
12
12
  # of all zip packages in each contained list. Each contained list is only downloaded
13
13
  # as needed, and only downloaded once.
14
- # @return [Enumerator::Lazy<Resync::Client::Zip::ZipPackage>] the flattened enumeration of resources
14
+ # @return [Enumerator::Lazy<Resync::Client::Zip::ZipPackage>] the flattened enumeration of packages
15
15
  def all_zip_packages
16
16
  resources.lazy.flat_map do |r|
17
17
  package_for(r)
@@ -43,7 +43,7 @@ module Resync
43
43
  # and +until_time+, in non-strict mode (only excluding those lists provably not in the range,
44
44
  # i.e., including packages without +from_time+ or +until_time+).
45
45
  # @param in_range [Range<Time>] the range of times to filter by
46
- # @return [Enumerator::Lazy<Resync::Client::Zip::ZipPackage>] the flattened enumeration of resources
46
+ # @return [Enumerator::Lazy<Resync::Client::Zip::ZipPackage>] the flattened enumeration of packages
47
47
  def all_zip_packages(in_range: nil)
48
48
  if in_range
49
49
  dump_resources = change_lists(in_range: in_range, strict: false)
@@ -1,6 +1,6 @@
1
1
  module Resync
2
2
  class Client
3
3
  # The version of this gem.
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.3'
5
5
  end
6
6
  end
@@ -7,7 +7,7 @@
7
7
  at="2015-05-22T16:06:04Z"
8
8
  completed="2015-05-05T16:23:20Z"/>
9
9
  <url>
10
- <loc>http://example.com/resourcedump.zip</loc>
10
+ <loc>http://example.com/bitstream-package.zip</loc>
11
11
  <rs:md type="application/zip"
12
12
  length="1334"
13
13
  at="2015-05-22T16:06:04Z"
@@ -6,10 +6,10 @@ module Resync
6
6
  describe '#zip_packages' do
7
7
  it 'transparently exposes bitstreams' do
8
8
  path = 'spec/data/resourcedump/resourcedump.xml'
9
- package_uri = URI('http://example.com/resourcedump.zip')
9
+ package_uri = URI('http://example.com/bitstream-package.zip')
10
10
 
11
11
  client = instance_double(Client)
12
- expect(client).to receive(:download_to_temp_file).once.with(package_uri).and_return('spec/data/resourcedump/resourcedump.zip')
12
+ expect(client).to receive(:download_to_temp_file).once.with(package_uri).and_return('spec/data/resourcedump/bitstream-package.zip')
13
13
 
14
14
  dump = XMLParser.parse(File.read(path))
15
15
  dump.client = client
@@ -81,21 +81,24 @@ module Resync
81
81
  end
82
82
 
83
83
  describe '#all_zip_packages' do
84
- it 'is an alias for #zip_packages' do
84
+ it 'delegates to #zip_packages, lazily' do
85
85
  path = 'spec/data/resourcedump/resourcedump.xml'
86
- package_uri = URI('http://example.com/resourcedump.zip')
86
+ package_uri = URI('http://example.com/bitstream-package.zip')
87
87
 
88
88
  client = instance_double(Client)
89
- expect(client).to receive(:download_to_temp_file).once.with(package_uri).and_return('spec/data/resourcedump/resourcedump.zip')
89
+ expect(client).to receive(:download_to_temp_file).once.with(package_uri).and_return('spec/data/resourcedump/bitstream-package.zip')
90
90
 
91
91
  dump = XMLParser.parse(File.read(path))
92
92
  dump.client = client
93
93
 
94
94
  all_zip_packages = dump.all_zip_packages
95
- expect(all_zip_packages.size).to eq(1)
96
- expect(all_zip_packages[0]).to be_a(Client::Zip::ZipPackage)
95
+ expect(all_zip_packages).to be_a(Enumerator::Lazy)
97
96
 
98
- bitstreams = all_zip_packages[0].bitstreams
97
+ all_zip_packages_array = all_zip_packages.to_a
98
+ expect(all_zip_packages_array.size).to eq(1)
99
+ expect(all_zip_packages_array[0]).to be_a(Client::Zip::ZipPackage)
100
+
101
+ bitstreams = all_zip_packages_array[0].bitstreams
99
102
  expect(bitstreams.size).to eq(2)
100
103
  expect(bitstreams[0].content).to eq(File.read('spec/data/resourcedump/resources/res1'))
101
104
  expect(bitstreams[1].content).to eq(File.read('spec/data/resourcedump/resources/res2'))
@@ -110,7 +113,7 @@ module Resync
110
113
  package_uri = URI('http://example.com/changedump.zip')
111
114
 
112
115
  client = instance_double(Client)
113
- expect(client).to receive(:download_to_temp_file).once.with(package_uri).and_return('spec/data/resourcedump/resourcedump.zip')
116
+ expect(client).to receive(:download_to_temp_file).once.with(package_uri).and_return('spec/data/resourcedump/bitstream-package.zip')
114
117
 
115
118
  dump = XMLParser.parse(File.read(path))
116
119
  dump.client = client
@@ -182,21 +185,24 @@ module Resync
182
185
  end
183
186
 
184
187
  describe '#all_zip_packages' do
185
- it 'is an alias for #zip_packages' do
188
+ it 'delegates to #zip_packages, lazily' do
186
189
  path = 'spec/data/resourcedump/changedump.xml'
187
190
  package_uri = URI('http://example.com/changedump.zip')
188
191
 
189
192
  client = instance_double(Client)
190
- expect(client).to receive(:download_to_temp_file).once.with(package_uri).and_return('spec/data/resourcedump/resourcedump.zip')
193
+ expect(client).to receive(:download_to_temp_file).once.with(package_uri).and_return('spec/data/resourcedump/bitstream-package.zip')
191
194
 
192
195
  dump = XMLParser.parse(File.read(path))
193
196
  dump.client = client
194
197
 
195
- zip_packages = dump.all_zip_packages
196
- expect(zip_packages.size).to eq(1)
197
- expect(zip_packages[0]).to be_a(Client::Zip::ZipPackage)
198
+ all_zip_packages = dump.all_zip_packages
199
+ expect(all_zip_packages).to be_a(Enumerator::Lazy)
198
200
 
199
- bitstreams = zip_packages[0].bitstreams
201
+ all_zip_packages_array = all_zip_packages.to_a
202
+ expect(all_zip_packages_array.size).to eq(1)
203
+ expect(all_zip_packages_array[0]).to be_a(Client::Zip::ZipPackage)
204
+
205
+ bitstreams = all_zip_packages_array[0].bitstreams
200
206
  expect(bitstreams.size).to eq(2)
201
207
  expect(bitstreams[0].content).to eq(File.read('spec/data/resourcedump/resources/res1'))
202
208
  expect(bitstreams[1].content).to eq(File.read('spec/data/resourcedump/resources/res2'))
@@ -6,7 +6,7 @@ module Resync
6
6
  describe ZipPackage do
7
7
  describe '#new' do
8
8
  it 'accepts a path to a ZIP file' do
9
- path = 'spec/data/resourcedump/resourcedump.zip'
9
+ path = 'spec/data/resourcedump/bitstream-package.zip'
10
10
  pkg = ZipPackage.new(path)
11
11
  zipfile = pkg.zipfile
12
12
  expect(zipfile).to be_a(::Zip::File)
@@ -14,19 +14,19 @@ module Resync
14
14
  end
15
15
 
16
16
  it 'accepts a Zip::File object' do
17
- zipfile = ::Zip::File.open('spec/data/resourcedump/resourcedump.zip')
17
+ zipfile = ::Zip::File.open('spec/data/resourcedump/bitstream-package.zip')
18
18
  pkg = ZipPackage.new(zipfile)
19
19
  expect(pkg.zipfile).to eq(zipfile)
20
20
  end
21
21
 
22
22
  it 'extracts a manifest' do
23
- pkg = ZipPackage.new('spec/data/resourcedump/resourcedump.zip')
23
+ pkg = ZipPackage.new('spec/data/resourcedump/bitstream-package.zip')
24
24
  manifest = pkg.manifest
25
25
  expect(manifest).to be_a(Resync::ResourceDumpManifest)
26
26
  end
27
27
 
28
28
  it 'extracts entries' do
29
- pkg = ZipPackage.new('spec/data/resourcedump/resourcedump.zip')
29
+ pkg = ZipPackage.new('spec/data/resourcedump/bitstream-package.zip')
30
30
  bitstreams = pkg.bitstreams
31
31
  expect(bitstreams.size).to eq(2)
32
32
 
@@ -42,7 +42,7 @@ module Resync
42
42
  end
43
43
 
44
44
  it 'provides direct access to bitstreams for each resource in the manifest' do
45
- pkg = ZipPackage.new('spec/data/resourcedump/resourcedump.zip')
45
+ pkg = ZipPackage.new('spec/data/resourcedump/bitstream-package.zip')
46
46
  bitstreams = pkg.bitstreams
47
47
 
48
48
  manifest = pkg.manifest
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resync-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-26 00:00:00.000000000 Z
11
+ date: 2015-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lazy
@@ -231,10 +231,10 @@ files:
231
231
  - spec/data/examples/resource-list-index.xml
232
232
  - spec/data/examples/resource-list.xml
233
233
  - spec/data/examples/source-description.xml
234
+ - spec/data/resourcedump/bitstream-package.zip
234
235
  - spec/data/resourcedump/changedump.xml
235
236
  - spec/data/resourcedump/manifest.xml
236
237
  - spec/data/resourcedump/resourcedump.xml
237
- - spec/data/resourcedump/resourcedump.zip
238
238
  - spec/data/resourcedump/resources/res1
239
239
  - spec/data/resourcedump/resources/res2
240
240
  - spec/data/simulator/capability-list.xml
@@ -297,10 +297,10 @@ test_files:
297
297
  - spec/data/examples/resource-list-index.xml
298
298
  - spec/data/examples/resource-list.xml
299
299
  - spec/data/examples/source-description.xml
300
+ - spec/data/resourcedump/bitstream-package.zip
300
301
  - spec/data/resourcedump/changedump.xml
301
302
  - spec/data/resourcedump/manifest.xml
302
303
  - spec/data/resourcedump/resourcedump.xml
303
- - spec/data/resourcedump/resourcedump.zip
304
304
  - spec/data/resourcedump/resources/res1
305
305
  - spec/data/resourcedump/resources/res2
306
306
  - spec/data/simulator/capability-list.xml