module SHACL

A SHACL runtime for RDF.rb.

@see www.w3.org/TR/shacl/

Constants

ValidationResult

A SHACL [Validateion Result](www.w3.org/TR/shacl/#results-validation-result).

Also allows for a successful result, if the `resultSeverity` `nil`.

Public Class Methods

execute(input, queryable = nil, **options) click to toggle source

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`.

@param [String, IO, StringIO, to_s] input @param [RDF::Queryable] queryable @param [Hash{Symbol => Object}] options @options (see Shapes#initialize) @return (see Shapes#execute) @raise (see Shapes#execute)

# File lib/shacl.rb, line 64
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) click to toggle source

Retrieve shapes from a sh:shapesGraph reference within queryable

@param (see Shapes#from_queryable) @option (see Shapes#from_queryable) @return (see Shapes#from_queryable) @raise (see Shapes#from_queryable)

# File lib/shacl.rb, line 47
def self.from_queryable(queryable, **options)
  Shapes.from_queryable(queryable, **options)
end
get_shapes(shape_graph, **options) click to toggle source

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.

@param (see Shapes#from_graph) @option (see Shapes#from_graph) @return (see Shapes#from_graph) @raise (see Shapes#from_graph)

# File lib/shacl.rb, line 24
def self.get_shapes(shape_graph, **options)
  Shapes.from_graph(shape_graph, **options)
end
open(input, **options) click to toggle source

Parse a given resource into a _Shapes Graph_.

@param [String, IO, StringIO, to_s] input @option (see Shapes#from_graph) @return (see Shapes#from_graph) @raise (see Shapes#from_graph)

# File lib/shacl.rb, line 35
def self.open(input, **options)
  graph = RDF::Graph.load(input, **options)
  self.get_shapes(graph, loaded_graphs: [RDF::URI(input, canonicalize: true)], **options)
end