module FedoraMigrate::DatastreamVerification
Attributes
datastream[RW]
Public Instance Methods
matching_checksums?()
click to toggle source
# File lib/fedora_migrate/datastream_verification.rb, line 9 def matching_checksums? datastream.checksum == target_checksum || checksum(datastream.content) == target_checksum end
matching_nokogiri_checksums?()
click to toggle source
# File lib/fedora_migrate/datastream_verification.rb, line 13 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
valid?(datastream = nil)
click to toggle source
# File lib/fedora_migrate/datastream_verification.rb, line 4 def valid?(datastream = nil) @datastream = datastream || @source matching_checksums? || matching_nokogiri_checksums? end
Private Instance Methods
checksum(content)
click to toggle source
# File lib/fedora_migrate/datastream_verification.rb, line 29 def checksum(content) Digest::SHA1.hexdigest(content) end
target_checksum()
click to toggle source
# File lib/fedora_migrate/datastream_verification.rb, line 20 def target_checksum target.digest.first.to_s.split(/:/).last end
target_content()
click to toggle source
In some cases, the data is in ldp_source but target.content is empty, so we check both places
# File lib/fedora_migrate/datastream_verification.rb, line 25 def target_content target.content.empty? ? target.ldp_source.content : target.content end