Sha256: e62619518f5aa1ae22e68d03531fe568e7bd891648ce19226fe3104f9694d772
Contents?: true
Size: 1.07 KB
Versions: 33
Compression:
Stored size: 1.07 KB
Contents
module ActiveFedora class FixtureLoader attr_accessor :path def initialize(path) self.path = path end def filename_for_pid(pid) File.join(path, "#{pid.gsub(":","_")}.foxml.xml") end def self.delete(pid) begin ActiveFedora::Base.load_instance(pid).delete 1 rescue ActiveFedora::ObjectNotFoundError logger.debug "The object #{pid} has already been deleted (or was never created)." 0 end end def reload(pid) self.class.delete(pid) import_and_index(pid) end def import_and_index(pid) body = self.class.import_to_fedora(filename_for_pid(pid)) self.class.index(pid) body end def self.index(pid) solrizer = Solrizer::Fedora::Solrizer.new solrizer.solrize(pid) end def self.import_to_fedora(filename) file = File.new(filename, "r") result = ActiveFedora::RubydoraConnection.instance.connection.ingest(:file=>file.read) raise "Failed to ingest the fixture." unless result result.body end end end
Version data entries
33 entries across 33 versions & 1 rubygems