Class: Resync::Client::Zip::ZipPackage
- Inherits:
-
Object
- Object
- Resync::Client::Zip::ZipPackage
- Defined in:
- lib/resync/client/zip/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
Gets 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
ZipPackage
for the specified file.
Constructor Details
#initialize(zipfile) ⇒ ZipPackage
Creates a new ZipPackage
for the specified file.
32 33 34 35 |
# File 'lib/resync/client/zip/zip_package.rb', line 32 def initialize(zipfile) self.zipfile = zipfile @bitstreams = {} end |
Instance Attribute Details
#manifest ⇒ ResourceDumpManifest, ChangeDumpManifest
Gets the manifest for the ZIP package. Resources in the manifest are each decorated with a bitstream
method that returns the bitstream for that resource.
24 25 26 |
# File 'lib/resync/client/zip/zip_package.rb', line 24 def manifest @manifest end |
#zipfile ⇒ ::Zip::File
Returns the ZIP file wrapped by this package.
17 18 19 |
# File 'lib/resync/client/zip/zip_package.rb', line 17 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.)
47 48 49 |
# File 'lib/resync/client/zip/zip_package.rb', line 47 def bitstream_for(resource) @bitstreams[resource] ||= Bitstream.new(zipfile: @zipfile, resource: resource) end |
#bitstreams ⇒ Array<Bitstream>
Gets all bitstreams declared in the package manifest.
53 54 55 |
# File 'lib/resync/client/zip/zip_package.rb', line 53 def bitstreams manifest.resources.to_a.map { |r| bitstream_for(r) } end |