Class: Resync::ZipPackage
- Inherits:
-
Object
- Object
- Resync::ZipPackage
- Defined in:
- lib/resync/client/zip_package.rb
Overview
A ZIP package of resources or changes, providing access to individual bitstreams based on the included manifest file.
Instance Attribute Summary collapse
-
#manifest ⇒ ResourceDumpManifest, ChangeDumpManifest
readonly
The manifest for the ZIP package.
-
#zipfile ⇒ Zip::File
readonly
The ZIP file wrapped by this package.
Instance Method Summary collapse
-
#bitstream_for(resource) ⇒ Bitstream
Gets the bitstream for the specified resource.
-
#bitstreams ⇒ Array<Bitstream>
Gets all bitstreams declared in the package manifest.
-
#initialize(zipfile) ⇒ ZipPackage
constructor
Creates a new
ZipPackagefor the specified file.
Constructor Details
#initialize(zipfile) ⇒ ZipPackage
Creates a new ZipPackage for the specified file.
27 28 29 |
# File 'lib/resync/client/zip_package.rb', line 27 def initialize(zipfile) self.zipfile = zipfile end |
Instance Attribute Details
#manifest ⇒ ResourceDumpManifest, ChangeDumpManifest (readonly)
Returns the manifest for the ZIP package.
19 20 21 |
# File 'lib/resync/client/zip_package.rb', line 19 def manifest @manifest end |
#zipfile ⇒ Zip::File
Returns the ZIP file wrapped by this package.
15 16 17 |
# File 'lib/resync/client/zip_package.rb', line 15 def zipfile @zipfile end |
Instance Method Details
#bitstream_for(resource) ⇒ Bitstream
Gets the bitstream for the specified resource. (Note that this does no validation; if the resource is not in the manifest, or the corresponding entry is not in the ZIP file, the behavior of the returned Bitstream is undefined.)
41 42 43 |
# File 'lib/resync/client/zip_package.rb', line 41 def bitstream_for(resource) Bitstream.new(zipfile: @zipfile, resource: resource) end |
#bitstreams ⇒ Array<Bitstream>
Gets all bitstreams declared in the package manifest.
47 48 49 |
# File 'lib/resync/client/zip_package.rb', line 47 def bitstreams manifest.resources.map { |r| bitstream_for(r) } end |