Sha256: 638082681d3651d7cc0a0497a59020900741e6b560ae1deb90d391a695002d1e
Contents?: true
Size: 912 Bytes
Versions: 2
Compression:
Stored size: 912 Bytes
Contents
module FedoraMigrate::DatastreamVerification attr_accessor :datastream def valid?(datastream = nil) @datastream = datastream || @source matching_checksums? || matching_nokogiri_checksums? end def matching_checksums? datastream.checksum == target_checksum || checksum(datastream.content) == target_checksum end def matching_nokogiri_checksums? return false unless datastream.mimeType == "text/xml" checksum(Nokogiri::XML(datastream.content).to_xml) == checksum(Nokogiri::XML(target_content).to_xml) end private def target_checksum target.digest.first.to_s.split(/:/).last end # In some cases, the data is in ldp_source but target.content is empty, so we check both places def target_content target.content.empty? ? target.ldp_source.content : target.content end def checksum(content) Digest::SHA1.hexdigest(content) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fedora-migrate-0.5.0 | lib/fedora_migrate/datastream_verification.rb |
fedora-migrate-0.4.0 | lib/fedora_migrate/datastream_verification.rb |