Skip to content

Commit

Permalink
Update some calling sequences for Ruby 3.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Feb 2, 2021
1 parent 3c6dc89 commit 8306b15
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/shacl/algebra/node_shape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def conforms(node, depth: 0, **options)
shape_properties = shape_paths.select {|p| p.is_a?(RDF::URI)}
shape_properties += Array(@options[:ignoredProperties])

closed_results = graph.query(subject: node).map do |statement|
closed_results = graph.query({subject: node}).map do |statement|
next if shape_properties.include?(statement.predicate)
not_satisfied(focus: node,
value: statement.object,
Expand Down
6 changes: 3 additions & 3 deletions lib/shacl/algebra/property_shape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def conforms(node, depth: 0, **options)

# Turn the `path` attribute into a SPARQL Property Path and evaluate to find related nodes.
value_nodes = if path.is_a?(RDF::URI)
graph.query(subject: node, predicate: path).objects
graph.query({subject: node, predicate: path}).objects
elsif path.evaluatable?
path.execute(graph,
subject: node,
Expand Down Expand Up @@ -100,7 +100,7 @@ def path
# @param [Array<RDF::Term>] value_nodes
# @return [Array<SHACL::ValidationResult>]
def builtin_lessThan(property, node, path, value_nodes, **options)
terms = graph.query(subject: node, predicate: property).objects
terms = graph.query({subject: node, predicate: property}).objects
compare(:<, terms, node, path, value_nodes,
RDF::Vocab::SHACL.LessThanConstraintComponent, **options)
end
Expand All @@ -113,7 +113,7 @@ def builtin_lessThan(property, node, path, value_nodes, **options)
# @param [Array<RDF::Term>] value_nodes
# @return [Array<SHACL::ValidationResult>]
def builtin_lessThanOrEquals(property, node, path, value_nodes, **options)
terms = graph.query(subject: node, predicate: property).objects
terms = graph.query({subject: node, predicate: property}).objects
compare(:<=, terms, node, path, value_nodes,
RDF::Vocab::SHACL.LessThanOrEqualsConstraintComponent, **options)
end
Expand Down
14 changes: 7 additions & 7 deletions lib/shacl/algebra/shape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ class Shape < Operator
def targetNodes
(Array(@options[:targetNode]) +
Array(@options[:targetClass]).map do |cls|
graph.query(predicate: RDF.type, object: cls).subjects
graph.query({predicate: RDF.type, object: cls}).subjects
end +
Array(@options[:targetSubjectsOf]).map do |pred|
graph.query(predicate: pred).subjects
graph.query({predicate: pred}).subjects
end +
Array(@options[:targetObjectsOf]).map do |pred|
graph.query(predicate: pred).objects
graph.query({predicate: pred}).objects
end + (
Array(type).include?(RDF::RDFS.Class) ?
graph.query(predicate: RDF.type, object: id).subjects :
graph.query({predicate: RDF.type, object: id}).subjects :
[]
)).flatten.uniq
end
Expand Down Expand Up @@ -52,7 +52,7 @@ def targetNodes
def builtin_class(types, node, path, value_nodes, **options)
value_nodes.map do |n|
has_type = n.resource? && begin
objects = graph.query(subject: n, predicate: RDF.type).objects
objects = graph.query({subject: n, predicate: RDF.type}).objects
types.all? {|t| objects.include?(t)}
end
satisfy(focus: node, path: path,
Expand Down Expand Up @@ -110,7 +110,7 @@ def builtin_datatype(datatype, node, path, value_nodes, **options)
# @return [Array<SHACL::ValidationResult>]
def builtin_disjoint(properties, node, path, value_nodes, **options)
disjoint_nodes = properties.map do |prop|
graph.query(subject: node, predicate: prop).objects
graph.query({subject: node, predicate: prop}).objects
end.flatten.compact
value_nodes.map do |n|
has_value = disjoint_nodes.include?(n)
Expand Down Expand Up @@ -140,7 +140,7 @@ def builtin_disjoint(properties, node, path, value_nodes, **options)
# @param [Array<RDF::Term>] value_nodes
# @return [Array<SHACL::ValidationResult>]
def builtin_equals(property, node, path, value_nodes, **options)
equal_nodes = graph.query(subject: node, predicate: property).objects
equal_nodes = graph.query({subject: node, predicate: property}).objects
(value_nodes.map do |n|
has_value = equal_nodes.include?(n)
satisfy(focus: node, path: path,
Expand Down
2 changes: 1 addition & 1 deletion lib/shacl/algebra/xone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def conforms(node, path: nil, depth: 0, **options)
log_debug(NAME, depth: depth) {SXP::Generator.string({node: node}.to_sxp_bin)}
num_conform = operands.inject(0) do |memo, op|
results = op.conforms(node, depth: depth + 1, **options)
memo += (results.all?(&:conform?) ? 1 : 0)
memo += (results.flatten.all?(&:conform?) ? 1 : 0)
end
case num_conform
when 0
Expand Down
4 changes: 2 additions & 2 deletions lib/shacl/shapes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def self.from_graph(graph, loaded_graphs: [], **options)
@loded_graphs = loaded_graphs

import_count = 0
while (imports = graph.query(predicate: RDF::OWL.imports).map(&:object)).count > import_count
while (imports = graph.query({predicate: RDF::OWL.imports}).map(&:object)).count > import_count
# Load each imported graph
imports.each do |ref|
graph.load(imports)
Expand Down Expand Up @@ -65,7 +65,7 @@ def self.from_graph(graph, loaded_graphs: [], **options)
# @raise [SHACL::Error]
def self.from_queryable(queryable, **options)
# Query queryable to find one ore more shapes graphs
graphs = queryable.query(predicate: RDF::Vocab::SHACL.shapesGraph).objects
graphs = queryable.query({predicate: RDF::Vocab::SHACL.shapesGraph}).objects
graph = RDF::Graph.new do |g|
graphs.each {|iri| g.load(iri)}
end
Expand Down
2 changes: 1 addition & 1 deletion spec/suite_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def self.open(file)
g = RDF::OrderedRepo.load(file)
label = g.first_object(predicate: RDF::RDFS.label).to_s

g.query(predicate: RDF::URI("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#include")).objects.each do |f|
g.query({predicate: RDF::URI("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#include")}).objects.each do |f|
g.load(f)
end
JSON::LD::API.fromRDF(g, useNativeTypes: true) do |expanded|
Expand Down

0 comments on commit 8306b15

Please sign in to comment.