Class: SHACL::ValidationReport
- Includes:
- RDF::Enumerable
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/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.
Attributes included from RDF::Enumerable
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.
Methods included from RDF::Enumerable
add_entailment, #canonicalize, #canonicalize!, #dump, #each_graph, #each_object, #each_predicate, #each_quad, #each_statement, #each_subject, #each_term, #each_triple, #entail, #enum_graph, #enum_object, #enum_predicate, #enum_quad, #enum_statement, #enum_subject, #enum_term, #enum_triple, #graph?, #graph_names, #invalid?, #method_missing, #object?, #objects, #predicate?, #predicates, #project_graph, #quad?, #quads, #respond_to_missing?, #statement?, #statements, #subject?, #subjects, #supports?, #term?, #terms, #to_a, #to_h, #to_set, #triple?, #triples, #valid?, #validate!
Methods included from RDF::Util::Aliasing::LateBound
Methods included from RDF::Isomorphic
#bijection_to, #isomorphic_with?
Methods included from RDF::Countable
Constructor Details
#initialize(results) ⇒ ValidationReport
Creates a report from the set of results
27 28 29 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/validation_report.rb', line 27 def initialize(results) @all_results = Array(results) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RDF::Enumerable
Instance Attribute Details
#all_results ⇒ Object (readonly)
All results, both conforming and non-conforming
20 21 22 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/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 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/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 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/validation_report.rb', line 51 def conform? results.empty? end |
#count ⇒ Integer
The number of non-conforming results
43 44 45 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/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 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/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 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/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 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/validation_report.rb', line 35 def results @all_results.reject(&:conform?) end |
#to_s ⇒ Object
70 71 72 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/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 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/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 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/validation_report.rb', line 58 def to_sxp_bin [:ValidationReport, conform?, results].to_sxp_bin end |