Module: FedoraMigrate::DatastreamVerification

Included in:
ContentMover
Defined in:
lib/fedora_migrate/datastream_verification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#datastreamObject

Returns the value of attribute datastream.



3
4
5
# File 'lib/fedora_migrate/datastream_verification.rb', line 3

def datastream
  @datastream
end

Instance Method Details

#has_matching_checksums?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/fedora_migrate/datastream_verification.rb', line 10

def has_matching_checksums?
  datastream.checksum == target_checksum || checksum(datastream.content) == target_checksum
end

#has_matching_nokogiri_checksums?Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/fedora_migrate/datastream_verification.rb', line 14

def has_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) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
# File 'lib/fedora_migrate/datastream_verification.rb', line 5

def valid? datastream=nil
  @datastream = datastream || @source
  has_matching_checksums? || has_matching_nokogiri_checksums?
end