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[R]

All results, both conforming and non-conforming

Public Class Methods

new(results) click to toggle source

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

==(other) click to toggle source

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
conform?() click to toggle source

Do the individual results indicate conformance?

@return [Boolean]

# File lib/shacl/validation_report.rb, line 51
def conform?
  results.empty?
end
count() click to toggle source

The number of non-conforming results

@return [Integer]

# File lib/shacl/validation_report.rb, line 43
def count
  results.length
end
each() { |statement| ... } click to toggle source

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
linter_messages() click to toggle source

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
results() click to toggle source

The non-conforming results

@return [Array<ValidationResult>]

# File lib/shacl/validation_report.rb, line 35
def results
  @all_results.reject(&:conform?)
end
to_s() click to toggle source
# File lib/shacl/validation_report.rb, line 66
def to_s
  results.map(&:to_s).join("\n")
end
to_sxp() click to toggle source
# File lib/shacl/validation_report.rb, line 62
def to_sxp
  self.to_sxp_bin.to_sxp
end
to_sxp_bin() click to toggle source

The number of results

# File lib/shacl/validation_report.rb, line 58
def to_sxp_bin
  [:ValidationReport, conform?, results].to_sxp_bin
end