Skip to content

Commit

Permalink
Finish 0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Nov 21, 2023
2 parents a82df96 + a4860f0 commit 9dd0268
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0
0.4.1
2 changes: 1 addition & 1 deletion lib/shacl/algebra/node_shape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def conforms(node, depth: 0, **options)
resultSeverity: options[:severity],
component: RDF::Vocab::SHACL.ClosedConstraintComponent,
**options)
end.compact
end.flatten.compact
elsif @options[:ignoredProperties]
raise SHACL::Error, "shape has ignoredProperties without being closed"
end
Expand Down
80 changes: 80 additions & 0 deletions spec/shapes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,86 @@
sxp: [:ValidationReport, true, []].to_sxp
}
}
},
"nested node shape with closed properties": {
shape: %(
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://example.org/ns#> .
ex:WithLabelShape a sh:NodeShape ;
sh:closed true ;
sh:property [
sh:path rdfs:label ;
sh:minCount 1 ;
sh:maxCount 1 ;
] .
ex:WithCommentShape a sh:NodeShape ;
sh:closed true ;
sh:property [
sh:path rdfs:comment ;
sh:minCount 1 ;
sh:maxCount 1 ;
] .
ex:ResourceShape a sh:NodeShape ;
sh:targetClass ex:Resource ;
sh:or ( ex:WithLabelShape ex:WithCommentShape ) .
),
sxp: %{(shapes
(
(NodeShape
(id <http://example.org/ns#WithLabelShape>)
(type shacl:NodeShape)
(closed true)
(PropertyShape (id _:b0) (path rdfs:label) (minCount 1) (maxCount 1)))
(NodeShape
(id <http://example.org/ns#WithCommentShape>)
(type shacl:NodeShape)
(closed true)
(PropertyShape (id _:b1) (path rdfs:comment) (minCount 1) (maxCount 1)))
(NodeShape
(id <http://example.org/ns#ResourceShape>)
(type shacl:NodeShape)
(targetClass <http://example.org/ns#Resource>)
(or
(NodeShape
(id <http://example.org/ns#WithLabelShape>)
(type shacl:NodeShape)
(closed true)
(PropertyShape (id _:b0) (path rdfs:label) (minCount 1) (maxCount 1)))
(NodeShape
(id <http://example.org/ns#WithCommentShape>)
(type shacl:NodeShape)
(closed true)
(PropertyShape (id _:b1) (path rdfs:comment) (minCount 1) (maxCount 1)))
)) ))},
data: {
"node which is neither of given shapes": {
input: %(
@prefix ex: <http://example.org/ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
ex:Resource1 a ex:Resource ;
rdfs:label "A Resource with a label" ;
ex:extraProperty "This should not be here" .),
valid: false,
sxp: %{
(ValidationReport #f
(
(ValidationResult
(value <http://example.org/ns#Resource1>)
(focus <http://example.org/ns#Resource1>)
(shape <http://example.org/ns#ResourceShape>)
(resultSeverity shacl:Violation)
(component shacl:OrConstraintComponent)
(message "node does not conform to any shape")) ))
}
}
}
}
}.each do |name, params|
context name do
Expand Down

0 comments on commit 9dd0268

Please sign in to comment.