Module: SHACL

Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/format.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/shapes.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/version.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/validation_report.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/validation_result.rb

Overview

A SHACL runtime for RDF.rb.

Defined Under Namespace

Modules: Algebra, Refinements, VERSION Classes: Error, Format, Shapes, StructureError, ValidationReport, ValidationResult

Class Method Summary collapse

Class Method Details

.execute(input, queryable = nil, **options) ⇒ Hash{RDF::Term => Array<ValidationResult>}, SHACL::ValidationReport

The Shapes Graph, is established similar to the Data Graph, but may be nil. If nil, the Data Graph may reference a Shapes Graph thorugh an sh:shapesGraph property.

Additionally, a Shapes Graph may contain an owl:imports property referencing additional Shapes Graphs, which are resolved until no more imports are found.

Load and validate the given SHACL expression string against queriable.

Parameters:

Returns:



69
70
71
72
73
74
75
76
77
78
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl.rb', line 69

def self.execute(input, queryable = nil, **options)
  queryable = queryable || RDF::Graph.new
  shapes = if input
    self.open(input, **options)
  else
    Shapes.from_queryable(queryable)
  end

  shapes.execute(queryable, **options)
end

.from_queryable(queryable, **options) ⇒ Object

Retrieve shapes from a sh:shapesGraph reference within queryable



52
53
54
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl.rb', line 52

def self.from_queryable(queryable, **options)
  Shapes.from_queryable(queryable, **options)
end

.get_shapes(shapes_graph, **options) ⇒ Object

Transform the given Shapes Graph into a set of executable shapes.

A Shapes Graph may contain an owl:imports property referencing additional Shapes Graphs, which are resolved until no more imports are found.



24
25
26
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl.rb', line 24

def self.get_shapes(shapes_graph, **options)
  Shapes.from_graph(shapes_graph, **options)
end

.open(input, **options) ⇒ Object

Parse a given resource into a Shapes Graph.

Parameters:

  • input (String, IO, StringIO, #to_s)


35
36
37
38
39
40
41
42
43
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl.rb', line 35

def self.open(input, **options)
  # Create graph backed by repo to allow a graph_name
  graph = RDF::Graph.load(input,
                          graph_name: RDF::URI(input),
                          data: RDF::Repository.new)
  self.get_shapes(graph,
    loaded_graphs: [RDF::URI(input, canonicalize: true)],
    **options)
end