Class: Mrt::Ingest::IObject
- Inherits:
-
Object
- Object
- Mrt::Ingest::IObject
- Defined in:
- lib/mrt/ingest/iobject.rb
Overview
An object prepared for ingest into Merritt.
Instance Attribute Summary collapse
-
#erc ⇒ Object
Returns the value of attribute erc.
-
#local_identifier ⇒ Object
Returns the value of attribute local_identifier.
-
#primary_identifier ⇒ Object
Returns the value of attribute primary_identifier.
-
#what ⇒ Object
Returns the value of attribute what.
-
#when ⇒ Object
Returns the value of attribute when.
-
#who ⇒ Object
Returns the value of attribute who.
Instance Method Summary collapse
-
#add_component(where, options = {}) ⇒ Object
Add a component to the object.
-
#finish_ingest ⇒ Object
Wait for the ingest of this object to finish.
-
#initialize(options = {}) ⇒ IObject
constructor
Options can have the keys :primary_identifier, :local_identifier, or :erc.
-
#mk_manifest(manifest) ⇒ Object
rubocop:disable Metrics/LineLength.
-
#mk_request(profile, user_agent) ⇒ Object
Make a Mrt::Ingest::Request object for this mrt-object.
-
#start_ingest(client, profile, submitter) ⇒ Object
Begin an ingest on the given client, with a profile and submitter.
Constructor Details
#initialize(options = {}) ⇒ IObject
Options can have the keys :primary_identifier, :local_identifier, or :erc. :erc can be a #File, #Uri or a #Hash of metadata.
20 21 22 23 24 25 |
# File 'lib/mrt/ingest/iobject.rb', line 20 def initialize( = {}) @primary_identifier = [:primary_identifier] @local_identifier = [:local_identifier] @erc = [:erc] || {} @components = [] end |
Instance Attribute Details
#erc ⇒ Object
Returns the value of attribute erc.
15 16 17 |
# File 'lib/mrt/ingest/iobject.rb', line 15 def erc @erc end |
#local_identifier ⇒ Object
Returns the value of attribute local_identifier.
15 16 17 |
# File 'lib/mrt/ingest/iobject.rb', line 15 def local_identifier @local_identifier end |
#primary_identifier ⇒ Object
Returns the value of attribute primary_identifier.
15 16 17 |
# File 'lib/mrt/ingest/iobject.rb', line 15 def primary_identifier @primary_identifier end |
#what ⇒ Object
Returns the value of attribute what.
15 16 17 |
# File 'lib/mrt/ingest/iobject.rb', line 15 def what @what end |
#when ⇒ Object
Returns the value of attribute when.
15 16 17 |
# File 'lib/mrt/ingest/iobject.rb', line 15 def when @when end |
#who ⇒ Object
Returns the value of attribute who.
15 16 17 |
# File 'lib/mrt/ingest/iobject.rb', line 15 def who @who end |
Instance Method Details
#add_component(where, options = {}) ⇒ Object
Add a component to the object. where can be either a #URI or a #File. Options is a hash whose keys may be :name, :digest, :mime_type, or :size. If :digest is supplied, it must be a subclass of Mrt::Ingest::MessageDigest::Base. If where is a #File, it will be hosted on an embedded web server.
32 33 34 |
# File 'lib/mrt/ingest/iobject.rb', line 32 def add_component(where, = {}) @components.push(Component.new(where, )) end |
#finish_ingest ⇒ Object
Wait for the ingest of this object to finish.
67 68 69 70 |
# File 'lib/mrt/ingest/iobject.rb', line 67 def finish_ingest # XXX Right now we only join the hosting server; in the future # we will check the status via the ingest server. end |
#mk_manifest(manifest) ⇒ Object
rubocop:disable Metrics/LineLength
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mrt/ingest/iobject.rb', line 46 def mk_manifest(manifest) # :nodoc: manifest.write("#%checkm_0.7\n") manifest.write("#%profile http://uc3.cdlib.org/registry/ingest/manifest/mrt-ingest-manifest\n") manifest.write("#%prefix | mrt: | http://uc3.cdlib.org/ontology/mom#\n") manifest.write("#%prefix | nfo: | http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#\n") manifest.write("#%fields | nfo:fileUrl | nfo:hashAlgorithm | nfo:hashValue | nfo:fileSize | nfo:fileLastModified | nfo:fileName | mrt:mimeType\n") @components.each do |c| manifest.write(c.to_manifest_entry) end manifest.write("#%EOF\n") end |
#mk_request(profile, user_agent) ⇒ Object
Make a Mrt::Ingest::Request object for this mrt-object
37 38 39 40 41 42 43 |
# File 'lib/mrt/ingest/iobject.rb', line 37 def mk_request(profile, user_agent) manifest_file = Tempfile.new('mrt-ingest') mk_manifest(manifest_file) # reset to beginning manifest_file.open new_request(manifest_file, profile, user_agent) end |
#start_ingest(client, profile, submitter) ⇒ Object
Begin an ingest on the given client, with a profile and submitter.
61 62 63 64 |
# File 'lib/mrt/ingest/iobject.rb', line 61 def start_ingest(client, profile, submitter) request = mk_request(profile, submitter) @response = client.ingest(request) end |