Class: Replication::Replica
- Inherits:
-
Object
- Object
- Replication::Replica
- Defined in:
- lib/replication/replica.rb
Overview
Copyright © 2014 by The Board of Trustees of the Leland Stanford Junior University. All rights reserved. See LICENSE for details.
The metadata concerning the digital object/version that is the subject of replication.
Constant Summary collapse
- @@replica_cache_pathname =
nil
Instance Attribute Summary collapse
-
#bagit_bag ⇒ BagitBag
A bag containing a copy of the replica.
-
#create_date ⇒ Time
The timestamp of the datetime at which the replica was created.
-
#home_repository ⇒ String
The original home location of the replica (sdr or dpn).
-
#payload_fixity ⇒ String
The value of the checksum/digest.
-
#payload_fixity_type ⇒ String
The type of checksum/digest type (:sha1, :sha256).
-
#payload_size ⇒ Integer
The size (in bytes) of the replic bag’s payload.
-
#replica_id ⇒ String
The unique identifier for the digital object replica.
Class Method Summary collapse
-
.replica_cache_pathname ⇒ Pathname
The base location of the replica cache.
-
.replica_cache_pathname=(replica_cache_pathname) ⇒ Pathname
Set the base location of the replica cache.
Instance Method Summary collapse
-
#bag_pathname ⇒ Pathname
The location of the replica bag.
-
#catalog_replica_data ⇒ Boolean
Update the replicas table of the Archive Catalog.
-
#get_bag_data ⇒ Replica
Open the replica’s bag and extract its properties.
-
#initialize(replica_id, home_repository) ⇒ Replica
constructor
Initialize a new Replica object.
Constructor Details
#initialize(replica_id, home_repository) ⇒ Replica
Returns Initialize a new Replica object.
49 50 51 52 |
# File 'lib/replication/replica.rb', line 49 def initialize(replica_id, home_repository) @replica_id = replica_id @home_repository = home_repository end |
Instance Attribute Details
#bagit_bag ⇒ BagitBag
Returns A bag containing a copy of the replica.
35 36 37 |
# File 'lib/replication/replica.rb', line 35 def bagit_bag @bagit_bag end |
#create_date ⇒ Time
Returns The timestamp of the datetime at which the replica was created.
32 33 34 |
# File 'lib/replication/replica.rb', line 32 def create_date @create_date end |
#home_repository ⇒ String
Returns The original home location of the replica (sdr or dpn).
29 30 31 |
# File 'lib/replication/replica.rb', line 29 def home_repository @home_repository end |
#payload_fixity ⇒ String
Returns The value of the checksum/digest.
44 45 46 |
# File 'lib/replication/replica.rb', line 44 def payload_fixity @payload_fixity end |
#payload_fixity_type ⇒ String
Returns The type of checksum/digest type (:sha1, :sha256).
41 42 43 |
# File 'lib/replication/replica.rb', line 41 def payload_fixity_type @payload_fixity_type end |
#payload_size ⇒ Integer
Returns The size (in bytes) of the replic bag’s payload.
38 39 40 |
# File 'lib/replication/replica.rb', line 38 def payload_size @payload_size end |
#replica_id ⇒ String
Returns The unique identifier for the digital object replica.
26 27 28 |
# File 'lib/replication/replica.rb', line 26 def replica_id @replica_id end |
Class Method Details
.replica_cache_pathname ⇒ Pathname
Returns The base location of the replica cache.
15 16 17 |
# File 'lib/replication/replica.rb', line 15 def Replica.replica_cache_pathname @@replica_cache_pathname end |
.replica_cache_pathname=(replica_cache_pathname) ⇒ Pathname
Returns Set the base location of the replica cache.
21 22 23 |
# File 'lib/replication/replica.rb', line 21 def Replica.replica_cache_pathname=(replica_cache_pathname) @@replica_cache_pathname = Pathname(replica_cache_pathname) end |
Instance Method Details
#bag_pathname ⇒ Pathname
Returns The location of the replica bag.
55 56 57 |
# File 'lib/replication/replica.rb', line 55 def bag_pathname @@replica_cache_pathname.join(@home_repository,@replica_id) end |
#catalog_replica_data ⇒ Boolean
Returns Update the replicas table of the Archive Catalog.
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/replication/replica.rb', line 74 def catalog_replica_data replica_data = { :replica_id => @replica_id, :home_repository => @home_repository, :create_date => @create_date, :payload_size => @payload_size, :payload_fixity_type => @payload_fixity_type, :payload_fixity => @payload_fixity } ArchiveCatalog.add_or_update_item(:replicas, replica_data) true end |
#get_bag_data ⇒ Replica
Returns Open the replica’s bag and extract its properties.
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/replication/replica.rb', line 60 def get_bag_data bag = BagitBag.open_bag(bag_pathname) @create_date = UtcTime.output(bag_pathname.ctime) size_hash = bag.info_payload_size @payload_size = size_hash[:bytes] file_fixity_hash = bag.read_manifest_files('manifest') tarfile_fixity = file_fixity_hash.values.first checksums = tarfile_fixity.checksums @payload_fixity_type = checksums.keys.last.to_s @payload_fixity = checksums[@payload_fixity_type.to_sym] self end |