Class: ActiveFedora::FixityService
- Inherits:
-
Object
- Object
- ActiveFedora::FixityService
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_fedora/fixity_service.rb
Instance Attribute Summary collapse
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
-
#check ⇒ Object
For backwards compat, check always insists on doing a new request.
-
#expected_message_digest ⇒ Object
the currently calculated checksum, as a string URI, like “urn:sha1:09a848b79f86f3a4f3f301b8baafde455d6f8e0e”.
-
#expected_size ⇒ Object
integer, as reported by fedora.
-
#initialize(target) ⇒ FixityService
constructor
A new instance of FixityService.
- #response ⇒ Object
-
#response_graph ⇒ Object
Fedora response as an ::RDF::Graph object.
-
#status ⇒ Object
An array of 1 or more literals reported by Fedora.
-
#verified? ⇒ Boolean
Executes a fixity check on Fedora.
Constructor Details
#initialize(target) ⇒ FixityService
Returns a new instance of FixityService.
8 9 10 11 |
# File 'lib/active_fedora/fixity_service.rb', line 8 def initialize(target) raise ArgumentError, 'You must provide a uri' unless target @target = target.to_s end |
Instance Attribute Details
#target ⇒ Object
Returns the value of attribute target.
5 6 7 |
# File 'lib/active_fedora/fixity_service.rb', line 5 def target @target end |
Instance Method Details
#check ⇒ Object
For backwards compat, check always insists on doing a new request. you might want verified? instead which uses a cached request.
20 21 22 23 |
# File 'lib/active_fedora/fixity_service.rb', line 20 def check @response = nil verified? end |
#expected_message_digest ⇒ Object
the currently calculated checksum, as a string URI, like “urn:sha1:09a848b79f86f3a4f3f301b8baafde455d6f8e0e”
40 41 42 |
# File 'lib/active_fedora/fixity_service.rb', line 40 def fixity_graph.query(predicate: ::RDF::Vocab::PREMIS.hasMessageDigest).first.try(:object).try(:to_s) end |
#expected_size ⇒ Object
integer, as reported by fedora. bytes maybe?
45 46 47 |
# File 'lib/active_fedora/fixity_service.rb', line 45 def expected_size fixity_graph.query(predicate: ::RDF::Vocab::PREMIS.hasSize).first.try(:object).try(:to_s).try(:to_i) end |
#response ⇒ Object
13 14 15 |
# File 'lib/active_fedora/fixity_service.rb', line 13 def response @response ||= fixity_response_from_fedora end |
#response_graph ⇒ Object
Fedora response as an ::RDF::Graph object. Public API, so consumers can do with it what they will, especially if future fedora versions add more things to it.
52 53 54 |
# File 'lib/active_fedora/fixity_service.rb', line 52 def response_graph fixity_graph end |
#status ⇒ Object
An array of 1 or more literals reported by Fedora. See ‘success’ for which one indicates fixity check is good.
33 34 35 36 |
# File 'lib/active_fedora/fixity_service.rb', line 33 def status fixity_graph.query(predicate: premis_status_predicate).map(&:object) + fixity_graph.query(predicate: fedora_status_predicate).map(&:object) end |
#verified? ⇒ Boolean
Executes a fixity check on Fedora
27 28 29 |
# File 'lib/active_fedora/fixity_service.rb', line 27 def verified? status.include?(success) end |