class SHACL::ValidationReport
A SHACL
[Validateion Report](www.w3.org/TR/shacl/#results-validation-report).
Collects the individual {SHACL::ValidationResult} instances and provides a `conforms` boolean accessor.
Allows the report to be serialized as a set of RDF
Statements
Attributes
All results, both conforming and non-conforming
Public Class Methods
Creates a report from the set of results
@param [Array<ValidationResult>] results @return [ValidationReport]
# File lib/shacl/validation_report.rb, line 27 def initialize(results) @all_results = Array(results) end
Public Instance Methods
Two reports are eq if they have the same number of results and each result equals a result in the other report. @param [ValidationReport] other @return [Boolean]
# File lib/shacl/validation_report.rb, line 74 def ==(other) return false unless other.is_a?(ValidationReport) count == other.count && other.results.all? {|r| results.include?(r)} end
Do the individual results indicate conformance?
@return [Boolean]
# File lib/shacl/validation_report.rb, line 51 def conform? results.empty? end
The number of non-conforming results
@return [Integer]
# File lib/shacl/validation_report.rb, line 43 def count results.length end
Yields statements for this report
@yield [statement]
each statement
@yieldparam [RDF::Statement] statement @yieldreturn [void] ignored @return [void]
# File lib/shacl/validation_report.rb, line 95 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
Create a hash of messages appropriate for linter-like output.
@return [Hash{Symbol => Hash{Symbol => Array<String>}}]
# File lib/shacl/validation_report.rb, line 83 def linter_messages results.inject({}) {|memo, result| memo.deep_merge(result.linter_message)} end
The non-conforming results
@return [Array<ValidationResult>]
# File lib/shacl/validation_report.rb, line 35 def results @all_results.reject(&:conform?) end
# File lib/shacl/validation_report.rb, line 66 def to_s results.map(&:to_s).join("\n") end
# File lib/shacl/validation_report.rb, line 62 def to_sxp self.to_sxp_bin.to_sxp end
The number of results
# File lib/shacl/validation_report.rb, line 58 def to_sxp_bin [:ValidationReport, conform?, results].to_sxp_bin end