Class: SHACL::ValidationReport
- Inherits:
-
Object
- Object
- SHACL::ValidationReport
- Includes:
- RDF::Enumerable
- Defined in:
- lib/shacl/validation_report.rb
Overview
A SHACL Validateion Report.
Collects the individual ValidationResult instances and provides a conforms
boolean accessor.
Allows the report to be serialized as a set of RDF Statements
Instance Attribute Summary collapse
-
#all_results ⇒ Object
readonly
All results, both conforming and non-conforming.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Two reports are eq if they have the same number of results and each result equals a result in the other report.
-
#conform? ⇒ Boolean
Do the individual results indicate conformance?.
-
#count ⇒ Integer
The number of non-conforming results.
-
#each {|statement| ... }
Yields statements for this report.
-
#initialize(results) ⇒ ValidationReport
constructor
Creates a report from the set of results.
-
#linter_messages ⇒ Hash{Symbol => Hash{Symbol => Array<String>}}
Create a hash of messages appropriate for linter-like output.
-
#results ⇒ Array<ValidationResult>
The non-conforming results.
- #to_s ⇒ Object
-
#to_sxp(**options) ⇒ String
Transform Report to SXP.
-
#to_sxp_bin ⇒ Object
The number of results.
Constructor Details
#initialize(results) ⇒ ValidationReport
Creates a report from the set of results
27 28 29 |
# File 'lib/shacl/validation_report.rb', line 27 def initialize(results) @all_results = Array(results) end |
Instance Attribute Details
#all_results ⇒ Object (readonly)
All results, both conforming and non-conforming
20 21 22 |
# File 'lib/shacl/validation_report.rb', line 20 def all_results @all_results end |
Instance Method Details
#==(other) ⇒ Boolean
Two reports are eq if they have the same number of results and each result equals a result in the other report.
78 79 80 81 |
# File 'lib/shacl/validation_report.rb', line 78 def ==(other) return false unless other.is_a?(ValidationReport) count == other.count && other.results.all? {|r| results.include?(r)} end |
#conform? ⇒ Boolean
Do the individual results indicate conformance?
51 52 53 |
# File 'lib/shacl/validation_report.rb', line 51 def conform? results.empty? end |
#count ⇒ Integer
The number of non-conforming results
43 44 45 |
# File 'lib/shacl/validation_report.rb', line 43 def count results.length end |
#each {|statement| ... }
This method returns an undefined value.
Yields statements for this report
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/shacl/validation_report.rb', line 99 def each(&block) subject = RDF::Node.new block.call(RDF::Statement(subject, RDF.type, RDF::Vocab::SHACL.ValidationReport)) block.call(RDF::Statement(subject, RDF::Vocab::SHACL.conforms, RDF::Literal(conform?))) results.each do |result| result_subject = nil result.each do |statement| result_subject ||= statement.subject yield(statement) end yield(RDF::Statement(subject, RDF::Vocab::SHACL.result, result_subject)) end end |
#linter_messages ⇒ Hash{Symbol => Hash{Symbol => Array<String>}}
Create a hash of messages appropriate for linter-like output.
87 88 89 |
# File 'lib/shacl/validation_report.rb', line 87 def results.inject({}) {|memo, result| memo.deep_merge(result.)} end |
#results ⇒ Array<ValidationResult>
The non-conforming results
35 36 37 |
# File 'lib/shacl/validation_report.rb', line 35 def results @all_results.reject(&:conform?) end |
#to_s ⇒ Object
70 71 72 |
# File 'lib/shacl/validation_report.rb', line 70 def to_s results.map(&:to_s).join("\n") end |
#to_sxp(**options) ⇒ String
Transform Report to SXP
66 67 68 |
# File 'lib/shacl/validation_report.rb', line 66 def to_sxp(**) self.to_sxp_bin.to_sxp(**) end |
#to_sxp_bin ⇒ Object
The number of results
58 59 60 |
# File 'lib/shacl/validation_report.rb', line 58 def to_sxp_bin [:ValidationReport, conform?, results].to_sxp_bin end |