class Mrt::Ingest::IObject
An object prepared for ingest into Merritt.
Attributes
erc[RW]
local_identifier[RW]
primary_identifier[RW]
server[R]
Public Class Methods
new(options = {})
click to toggle source
Options can have the keys :primary_identifier, :local_identifier, :server, or :erc. :erc can be a #File, #Uri or a #Hash of metadata. :server is a #OneTimeServer.
# File lib/mrt/ingest/iobject.rb, line 21 def initialize(options = {}) @primary_identifier = options[:primary_identifier] @local_identifier = options[:local_identifier] @erc = options[:erc] || {} @components = [] @server = options[:server] || Mrt::Ingest::OneTimeServer.new end
Public Instance Methods
add_component(where, options = {})
click to toggle source
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.
# File lib/mrt/ingest/iobject.rb, line 34 def add_component(where, options = {}) @components.push(Component.new(@server, where, options)) end
finish_ingest()
click to toggle source
Wait for the ingest of this object to finish.
# File lib/mrt/ingest/iobject.rb, line 84 def finish_ingest # XXX Right now we only join the hosting server; in the future # we will check the status via the ingest server. join_server end
mk_request(profile, user_agent)
click to toggle source
Make a Mrt::Ingest::Request
object for this mrt-object
# File lib/mrt/ingest/iobject.rb, line 39 def mk_request(profile, user_agent) manifest_file = Tempfile.new('mrt-ingest') erc_component = Component.from_erc(@server, @erc) mk_manifest(manifest_file, erc_component) # reset to beginning manifest_file.open new_request(manifest_file, profile, user_agent) end
start_ingest(client, profile, submitter)
click to toggle source
Begin an ingest on the given client, with a profile and submitter.
# File lib/mrt/ingest/iobject.rb, line 77 def start_ingest(client, profile, submitter) request = mk_request(profile, submitter) start_server @response = client.ingest(request) end
Private Instance Methods
new_request(manifest_file, profile, user_agent)
click to toggle source
# File lib/mrt/ingest/iobject.rb, line 92 def new_request(manifest_file, profile, user_agent) Mrt::Ingest::Request.new( file: manifest_file, filename: manifest_file.path.split(%r{/}).last, type: 'object-manifest', submitter: user_agent, profile: profile, local_identifier: @local_identifier, primary_identifier: @primary_identifier ) end