class FedoraMigrate::RDFDatastreamMover
Public Instance Methods
migrate()
click to toggle source
Calls superclass method
FedoraMigrate::Mover#migrate
# File lib/fedora_migrate/rdf_datastream_mover.rb, line 5 def migrate before_rdf_datastream_migration migrate_rdf_triples after_rdf_datastream_migration save super end
migrate_rdf_triples()
click to toggle source
# File lib/fedora_migrate/rdf_datastream_mover.rb, line 13 def migrate_rdf_triples target.resource << updated_graph end
Private Instance Methods
correct_encoding(input)
click to toggle source
Scholarsphere has some ISO-8859 encoded data, which violates the NTriples spec. Here we correct that.
# File lib/fedora_migrate/rdf_datastream_mover.rb, line 33 def correct_encoding(input) input.encode!(Encoding::UTF_8) rescue Encoding::UndefinedConversionError cd = ::CharDet.detect(input) input.force_encoding(Encoding.find(cd["encoding"].upcase)).encode!(Encoding::UTF_8) end
datastream_content()
click to toggle source
# File lib/fedora_migrate/rdf_datastream_mover.rb, line 27 def datastream_content source.content end
reader()
click to toggle source
# File lib/fedora_migrate/rdf_datastream_mover.rb, line 40 def reader RDF::Reader.for(:ntriples) end
updated_datastream_content()
click to toggle source
# File lib/fedora_migrate/rdf_datastream_mover.rb, line 23 def updated_datastream_content correct_encoding(datastream_content).gsub(/<.+#{source.pid}>/, "<#{target.uri}>") end
updated_graph()
click to toggle source
# File lib/fedora_migrate/rdf_datastream_mover.rb, line 19 def updated_graph reader.new(updated_datastream_content) end