shex 0.6.0 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHORS +1 -1
- data/LICENSE +1 -1
- data/README.md +133 -118
- data/VERSION +1 -1
- data/etc/doap.ttl +17 -19
- data/lib/shex/algebra/and.rb +3 -12
- data/lib/shex/algebra/each_of.rb +2 -12
- data/lib/shex/algebra/import.rb +6 -0
- data/lib/shex/algebra/not.rb +3 -10
- data/lib/shex/algebra/one_of.rb +2 -12
- data/lib/shex/algebra/operator.rb +32 -20
- data/lib/shex/algebra/or.rb +3 -12
- data/lib/shex/algebra/schema.rb +4 -11
- data/lib/shex/algebra/semact.rb +8 -8
- data/lib/shex/algebra/shape.rb +6 -4
- data/lib/shex/algebra/shape_expression.rb +29 -0
- data/lib/shex/algebra/start.rb +2 -10
- data/lib/shex/algebra/stem.rb +5 -1
- data/lib/shex/algebra/stem_range.rb +3 -1
- data/lib/shex/algebra/triple_constraint.rb +1 -1
- data/lib/shex/algebra/triple_expression.rb +18 -0
- data/lib/shex/algebra.rb +1 -2
- data/lib/shex/extensions/test.rb +18 -16
- data/lib/shex/format.rb +2 -4
- data/lib/shex/meta.rb +325 -9859
- data/lib/shex/parser.rb +563 -478
- data/lib/shex/terminals.rb +5 -25
- data/lib/shex.rb +7 -4
- metadata +48 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e45bfef778f047d77b25295bf5c41cfc1ed69d040a1ea76dd145734a755faffd
|
4
|
+
data.tar.gz: 91b81f28e0db8a507924627fd94bfc8265301588346715a9102dbf9cea091ab1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6e9ecf3bbb822070f1d870233eed17ac5ac3a353fca09f8a782b3d31c3538f27d2c4ff2f53336fbcade2b65460c9598309c7bbb2cdb790f90edbc229fab2a17
|
7
|
+
data.tar.gz: 83fa124c1fb95b385ff86fdf707c2a0778261c4f92fce32becca03d7cd29b1e73b7fc56c86746a1dff2d6ba60306d55aa7c81918952142b60f80197bc1edf032
|
data/AUTHORS
CHANGED
@@ -1 +1 @@
|
|
1
|
-
* Gregg Kellogg <gregg@
|
1
|
+
* Gregg Kellogg <gregg@greggkellogg.net>
|
data/LICENSE
CHANGED
@@ -21,4 +21,4 @@ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
21
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
22
|
OTHER DEALINGS IN THE SOFTWARE.
|
23
23
|
|
24
|
-
For more information, please refer to <
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
data/README.md
CHANGED
@@ -2,52 +2,54 @@
|
|
2
2
|
|
3
3
|
This is a pure-Ruby library for working with the [Shape Expressions Language][ShExSpec] to validate the shape of [RDF][] graphs.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
[![
|
8
|
-
[![
|
9
|
-
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/shex/badge.svg)](https://coveralls.io/r/ruby-rdf/shex)
|
10
|
-
[![Join the chat at https://gitter.im/ruby-rdf/rdf](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ruby-rdf/rdf?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/shex.png)](https://badge.fury.io/rb/shex)
|
6
|
+
[![Build Status](https://github.com/ruby-rdf/shex/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/shex/actions?query=workflow%3ACI)
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/shex/badge.svg?branch=develop)](https://coveralls.io/github/ruby-rdf/shex?branch=develop)
|
8
|
+
[![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf)
|
11
9
|
[![DOI](https://zenodo.org/badge/74419330.svg)](https://zenodo.org/badge/latestdoi/74419330)
|
12
10
|
|
13
11
|
## Features
|
14
12
|
|
15
13
|
* 100% pure Ruby with minimal dependencies and no bloat.
|
16
14
|
* Fully compatible with [ShEx][ShExSpec] specifications.
|
17
|
-
* 100% free and unencumbered [public domain](
|
15
|
+
* 100% free and unencumbered [public domain](https://unlicense.org/) software.
|
18
16
|
|
19
17
|
## Description
|
20
18
|
|
21
|
-
The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine.
|
19
|
+
The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine version 2.0.
|
22
20
|
|
23
|
-
* `ShEx::Parser` parses ShExC and ShExJ formatted documents generating executable operators which can be serialized as [S-Expressions]
|
21
|
+
* `ShEx::Parser` parses ShExC and ShExJ formatted documents generating executable operators which can be serialized as [S-Expressions][].
|
24
22
|
* `ShEx::Algebra` executes operators against Any `RDF::Graph`, including compliant [RDF.rb][].
|
25
23
|
* [Implementation Report](file.earl.html)
|
26
24
|
|
27
25
|
## Examples
|
28
26
|
### Validating a node using ShExC
|
29
27
|
|
30
|
-
require 'rubygems'
|
31
28
|
require 'rdf/turtle'
|
32
29
|
require 'shex'
|
33
30
|
|
34
|
-
shexc
|
31
|
+
shexc = %(
|
35
32
|
PREFIX doap: <http://usefulinc.com/ns/doap#>
|
36
33
|
PREFIX dc: <http://purl.org/dc/terms/>
|
37
|
-
<
|
38
|
-
|
39
|
-
|
40
|
-
doap:
|
41
|
-
doap:
|
42
|
-
|
34
|
+
PREFIX ex: <http://example.com/>
|
35
|
+
|
36
|
+
ex:TestShape EXTRA a {
|
37
|
+
a [doap:Project];
|
38
|
+
( doap:name Literal;
|
39
|
+
doap:description Literal
|
40
|
+
| dc:title Literal;
|
41
|
+
dc:description Literal)+;
|
42
|
+
doap:category IRI*;
|
43
|
+
doap:developer IRI+;
|
44
|
+
doap:implements [<http://shex.io/shex-semantics/>]
|
43
45
|
}
|
44
46
|
)
|
45
47
|
graph = RDF::Graph.load("etc/doap.ttl")
|
46
48
|
schema = ShEx.parse(shexc)
|
47
49
|
map = {
|
48
|
-
"
|
50
|
+
RDF::URI("https://rubygems.org/gems/shex") => RDF::URI("http://example.com/TestShape")
|
49
51
|
}
|
50
|
-
schema.satisfies?(
|
52
|
+
schema.satisfies?(graph, map)
|
51
53
|
# => true
|
52
54
|
### Validating a node using ShExJ
|
53
55
|
|
@@ -55,92 +57,99 @@ The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine.
|
|
55
57
|
require 'rdf/turtle'
|
56
58
|
require 'shex'
|
57
59
|
|
58
|
-
shexj
|
60
|
+
shexj = %({
|
61
|
+
"@context": "http://www.w3.org/ns/shex.jsonld",
|
59
62
|
"type": "Schema",
|
60
|
-
"
|
61
|
-
"
|
62
|
-
"
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
"
|
67
|
-
|
68
|
-
|
69
|
-
"
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
"type": "EachOf",
|
84
|
-
"expressions": [
|
85
|
-
{
|
86
|
-
"type": "TripleConstraint",
|
87
|
-
"predicate": "http://usefulinc.com/ns/doap#name",
|
88
|
-
"valueExpr": {"type": "NodeConstraint", "nodeKind": "literal"}
|
89
|
-
},
|
90
|
-
{
|
91
|
-
"type": "TripleConstraint",
|
92
|
-
"predicate": "http://usefulinc.com/ns/doap#description",
|
93
|
-
"valueExpr": {"type": "NodeConstraint", "nodeKind": "literal"}
|
94
|
-
}
|
95
|
-
]
|
96
|
-
},
|
97
|
-
{
|
98
|
-
"type": "EachOf",
|
99
|
-
"expressions": [
|
100
|
-
{
|
101
|
-
"type": "TripleConstraint",
|
102
|
-
"predicate": "http://purl.org/dc/terms/title",
|
103
|
-
"valueExpr": {"type": "NodeConstraint", "nodeKind": "literal"}
|
104
|
-
},
|
105
|
-
{
|
106
|
-
"type": "TripleConstraint",
|
107
|
-
"predicate": "http://purl.org/dc/terms/description",
|
108
|
-
"valueExpr": {"type": "NodeConstraint", "nodeKind": "literal"}
|
109
|
-
}
|
110
|
-
]
|
63
|
+
"shapes": [{
|
64
|
+
"id": "http://example.com/TestShape",
|
65
|
+
"type": "Shape",
|
66
|
+
"extra": ["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"],
|
67
|
+
"expression": {
|
68
|
+
"type": "EachOf",
|
69
|
+
"expressions": [{
|
70
|
+
"type": "TripleConstraint",
|
71
|
+
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
|
72
|
+
"valueExpr": {
|
73
|
+
"type": "NodeConstraint",
|
74
|
+
"values": ["http://usefulinc.com/ns/doap#Project"]
|
75
|
+
}
|
76
|
+
}, {
|
77
|
+
"type": "OneOf",
|
78
|
+
"expressions": [{
|
79
|
+
"type": "EachOf",
|
80
|
+
"expressions": [{
|
81
|
+
"type": "TripleConstraint",
|
82
|
+
"predicate": "http://usefulinc.com/ns/doap#name",
|
83
|
+
"valueExpr": {
|
84
|
+
"type": "NodeConstraint",
|
85
|
+
"nodeKind": "literal"
|
111
86
|
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
87
|
+
}, {
|
88
|
+
"type": "TripleConstraint",
|
89
|
+
"predicate": "http://usefulinc.com/ns/doap#description",
|
90
|
+
"valueExpr": {
|
91
|
+
"type": "NodeConstraint",
|
92
|
+
"nodeKind": "literal"
|
93
|
+
}
|
94
|
+
}]
|
95
|
+
}, {
|
96
|
+
"type": "EachOf",
|
97
|
+
"expressions": [{
|
98
|
+
"type": "TripleConstraint",
|
99
|
+
"predicate": "http://purl.org/dc/terms/title",
|
100
|
+
"valueExpr": {
|
101
|
+
"type": "NodeConstraint",
|
102
|
+
"nodeKind": "literal"
|
103
|
+
}
|
104
|
+
}, {
|
105
|
+
"type": "TripleConstraint",
|
106
|
+
"predicate": "http://purl.org/dc/terms/description",
|
107
|
+
"valueExpr": {
|
108
|
+
"type": "NodeConstraint",
|
109
|
+
"nodeKind": "literal"
|
110
|
+
}
|
111
|
+
}]
|
112
|
+
}],
|
113
|
+
"min": 1,
|
114
|
+
"max": -1
|
115
|
+
}, {
|
116
|
+
"type": "TripleConstraint",
|
117
|
+
"predicate": "http://usefulinc.com/ns/doap#category",
|
118
|
+
"valueExpr": {
|
119
|
+
"type": "NodeConstraint",
|
120
|
+
"nodeKind": "iri"
|
120
121
|
},
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
122
|
+
"min": 0,
|
123
|
+
"max": -1
|
124
|
+
}, {
|
125
|
+
"type": "TripleConstraint",
|
126
|
+
"predicate": "http://usefulinc.com/ns/doap#developer",
|
127
|
+
"valueExpr": {
|
128
|
+
"type": "NodeConstraint",
|
129
|
+
"nodeKind": "iri"
|
126
130
|
},
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
131
|
+
"min": 1,
|
132
|
+
"max": -1
|
133
|
+
}, {
|
134
|
+
"type": "TripleConstraint",
|
135
|
+
"predicate": "http://usefulinc.com/ns/doap#implements",
|
136
|
+
"valueExpr": {
|
137
|
+
"type": "NodeConstraint",
|
138
|
+
"values": [
|
139
|
+
"http://shex.io/shex-semantics/"
|
140
|
+
]
|
134
141
|
}
|
135
|
-
|
136
|
-
|
142
|
+
}
|
143
|
+
]
|
137
144
|
}
|
138
145
|
}
|
139
|
-
})
|
146
|
+
]})
|
140
147
|
graph = RDF::Graph.load("etc/doap.ttl")
|
141
148
|
schema = ShEx.parse(shexj, format: :shexj)
|
142
|
-
map = {
|
143
|
-
|
149
|
+
map = {
|
150
|
+
RDF::URI("https://rubygems.org/gems/shex") => RDF::URI("http://example.com/TestShape")
|
151
|
+
}
|
152
|
+
schema.satisfies?(graph, map)
|
144
153
|
# => true
|
145
154
|
|
146
155
|
## Extensions
|
@@ -177,28 +186,27 @@ Example usage:
|
|
177
186
|
|
178
187
|
rdf shex https://raw.githubusercontent.com/ruby-rdf/shex/develop/etc/doap.ttl \
|
179
188
|
--schema https://raw.githubusercontent.com/ruby-rdf/shex/develop/etc/doap.shex \
|
180
|
-
--focus
|
189
|
+
--focus https://rubygems.org/gems/shex
|
181
190
|
|
182
191
|
## Documentation
|
183
192
|
|
184
|
-
<
|
193
|
+
<https://rubydoc.info/github/ruby-rdf/shex>
|
185
194
|
|
186
195
|
|
187
196
|
## Implementation Notes
|
188
|
-
The ShExC parser uses the [EBNF][] gem to generate
|
197
|
+
The ShExC parser uses the [EBNF][] gem to generate a [PEG][] parser.
|
189
198
|
|
190
|
-
The parser
|
191
|
-
|
192
|
-
The result of parsing either ShExC or ShExJ is the creation of a set of executable {ShEx::Algebra} Operators which are directly executed to perform shape validation.
|
199
|
+
The parser uses the executable [S-Expressions][] generated from the EBNF ShExC grammar to create a set of executable {ShEx::Algebra} Operators which are directly executed to perform shape validation.
|
193
200
|
|
194
201
|
## Dependencies
|
195
202
|
|
196
|
-
* [Ruby](
|
197
|
-
* [RDF.rb](
|
203
|
+
* [Ruby](https://ruby-lang.org/) (>= 2.4)
|
204
|
+
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1)
|
205
|
+
* [SPARQL gem](https://rubygems.org/gems/sparql) (~> 3.1)
|
198
206
|
|
199
207
|
## Installation
|
200
208
|
|
201
|
-
The recommended installation method is via [RubyGems](
|
209
|
+
The recommended installation method is via [RubyGems](https://rubygems.org/).
|
202
210
|
To install the latest official release of RDF.rb, do:
|
203
211
|
|
204
212
|
% [sudo] gem install shex
|
@@ -212,21 +220,21 @@ To get a local working copy of the development repository, do:
|
|
212
220
|
Alternatively, download the latest development version as a tarball as
|
213
221
|
follows:
|
214
222
|
|
215
|
-
% wget
|
223
|
+
% wget https://github.com/ruby-rdf/shex/tarball/master
|
216
224
|
|
217
225
|
## Resources
|
218
226
|
|
219
|
-
* <
|
220
|
-
* <
|
221
|
-
* <
|
227
|
+
* <https://rubydoc.info/github/ruby-rdf/shex>
|
228
|
+
* <https://github.com/ruby-rdf/shex>
|
229
|
+
* <https://rubygems.org/gems/shex>
|
222
230
|
|
223
231
|
## Mailing List
|
224
232
|
|
225
|
-
* <
|
233
|
+
* <https://lists.w3.org/Archives/Public/public-rdf-ruby/>
|
226
234
|
|
227
235
|
## Author
|
228
236
|
|
229
|
-
* [Gregg Kellogg](
|
237
|
+
* [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>
|
230
238
|
|
231
239
|
## Contributing
|
232
240
|
|
@@ -245,14 +253,21 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
|
|
245
253
|
enough, be assured we will eventually add you in there.
|
246
254
|
* Do note that in order for us to merge any non-trivial changes (as a rule
|
247
255
|
of thumb, additions larger than about 15 lines of code), we need an
|
248
|
-
explicit [public domain dedication][PDD] on record from you
|
256
|
+
explicit [public domain dedication][PDD] on record from you,
|
257
|
+
which you will be asked to agree to on the first commit to a repo within the organization.
|
258
|
+
Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.
|
249
259
|
|
250
260
|
## License
|
251
261
|
|
252
262
|
This is free and unencumbered public domain software. For more information,
|
253
|
-
see <
|
254
|
-
|
255
|
-
[ShExSpec]: http://shex.io/shex-semantics/
|
256
|
-
[RDF]:
|
257
|
-
[RDF.rb]:
|
258
|
-
[EBNF]:
|
263
|
+
see <https://unlicense.org/> or the accompanying {file:LICENSE} file.
|
264
|
+
|
265
|
+
[ShExSpec]: http://shex.io/shex-semantics-20170713/
|
266
|
+
[RDF]: https://www.w3.org/RDF/
|
267
|
+
[RDF.rb]: https://rubydoc.info/github/ruby-rdf/rdf
|
268
|
+
[EBNF]: https://rubygems.org/gems/ebnf
|
269
|
+
[YARD]: https://yardoc.org/
|
270
|
+
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
271
|
+
[PDD]: https://unlicense.org/#unlicensing-contributions
|
272
|
+
[PEG]: https://en.wikipedia.org/wiki/Parsing_expression_grammar "Parsing Expression Grammar"
|
273
|
+
[S-Expression]: https://en.wikipedia.org/wiki/S-expression
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.4
|
data/etc/doap.ttl
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
@base <
|
1
|
+
@base <https://rubygems.org/gems/shex> .
|
2
2
|
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
3
3
|
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
4
4
|
@prefix dc: <http://purl.org/dc/terms/> .
|
@@ -8,27 +8,25 @@
|
|
8
8
|
@prefix ex: <http://example.org/> .
|
9
9
|
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
10
10
|
|
11
|
-
<
|
12
|
-
doap:name "ShEx
|
13
|
-
doap:homepage <
|
14
|
-
doap:license <
|
15
|
-
doap:shortdesc "ShEx is a Shape Expression engine for Ruby."@en ;
|
16
|
-
doap:description "ShEx is an Shape Expression engine for the RDF.rb library suite."@en ;
|
11
|
+
<https://rubygems.org/gems/shex> a doap:Project, earl:TestSubject, earl:Software ;
|
12
|
+
doap:name "ShEx" ;
|
13
|
+
doap:homepage <https://ruby-rdf.github.com/shex> ;
|
14
|
+
doap:license <https://unlicense.org/1.0/> ;
|
15
|
+
doap:shortdesc "ShEx is a Shape Expression engine for Ruby RDF.rb."@en ;
|
16
|
+
doap:description "ShEx is an Shape Expression engine for the Ruby RDF.rb library suite."@en ;
|
17
17
|
doap:created "2016-12-09"^^xsd:date ;
|
18
18
|
doap:programming-language "Ruby" ;
|
19
19
|
doap:implements <http://shex.io/shex-semantics/> ;
|
20
20
|
doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
|
21
21
|
<http://dbpedia.org/resource/Ruby_(programming_language)> ;
|
22
|
-
doap:download-page <
|
23
|
-
doap:mailing-list <
|
24
|
-
doap:bug-database <
|
25
|
-
doap:blog <
|
26
|
-
doap:developer <
|
27
|
-
doap:maintainer <
|
28
|
-
doap:documenter <
|
29
|
-
foaf:maker <
|
30
|
-
dc:title "ShEx.rb" ;
|
31
|
-
dc:description "ShEx is an Shape Expression engine for the RDF.rb library suite."@en ;
|
22
|
+
doap:download-page <https://rubygems.org/gems/shex> ;
|
23
|
+
doap:mailing-list <https://lists.w3.org/Archives/Public/public-rdf-ruby/> ;
|
24
|
+
doap:bug-database <https://github.com/ruby-rdf/shex/issues> ;
|
25
|
+
doap:blog <https://greggkellogg.net/> ;
|
26
|
+
doap:developer <https://greggkellogg.net/foaf#me> ;
|
27
|
+
doap:maintainer <https://greggkellogg.net/foaf#me> ;
|
28
|
+
doap:documenter <https://greggkellogg.net/foaf#me> ;
|
29
|
+
foaf:maker <https://greggkellogg.net/foaf#me> ;
|
32
30
|
dc:date "2016-12-09"^^xsd:date ;
|
33
|
-
dc:creator <
|
34
|
-
dc:isPartOf <
|
31
|
+
dc:creator <https://greggkellogg.net/foaf#me> ;
|
32
|
+
dc:isPartOf <https://rubygems.org/gems/rdf> .
|
data/lib/shex/algebra/and.rb
CHANGED
@@ -61,22 +61,13 @@ module ShEx::Algebra
|
|
61
61
|
end
|
62
62
|
|
63
63
|
##
|
64
|
-
# expressions must be ShapeExpressions
|
64
|
+
# expressions must be ShapeExpressions or references to ShapeExpressions
|
65
65
|
#
|
66
66
|
# @return [Operator] `self`
|
67
67
|
# @raise [ShEx::StructureError] if the value is invalid
|
68
68
|
def validate!
|
69
|
-
|
70
|
-
|
71
|
-
when ShapeExpression
|
72
|
-
when RDF::Resource
|
73
|
-
ref = schema.find(op)
|
74
|
-
ref.is_a?(ShapeExpression) ||
|
75
|
-
structure_error("#{json_type} must reference a ShapeExpression: #{ref}")
|
76
|
-
else
|
77
|
-
structure_error("#{json_type} must reference a ShapeExpression: #{ref}")
|
78
|
-
end
|
79
|
-
end
|
69
|
+
validate_expressions!
|
70
|
+
validate_self_references!
|
80
71
|
super
|
81
72
|
end
|
82
73
|
|
data/lib/shex/algebra/each_of.rb
CHANGED
@@ -73,22 +73,12 @@ module ShEx::Algebra
|
|
73
73
|
end
|
74
74
|
|
75
75
|
##
|
76
|
-
# expressions must be TripleExpressions
|
76
|
+
# expressions must be TripleExpressions or references to TripleExpressions
|
77
77
|
#
|
78
78
|
# @return [Operator] `self`
|
79
79
|
# @raise [ShEx::StructureError] if the value is invalid
|
80
80
|
def validate!
|
81
|
-
|
82
|
-
case op
|
83
|
-
when TripleExpression
|
84
|
-
when RDF::Resource
|
85
|
-
ref = schema.find(op)
|
86
|
-
ref.is_a?(TripleExpression) ||
|
87
|
-
structure_error("#{json_type} must reference a TripleExpression: #{ref}")
|
88
|
-
else
|
89
|
-
structure_error("#{json_type} must reference a TripleExpression: #{ref}")
|
90
|
-
end
|
91
|
-
end
|
81
|
+
validate_expressions!
|
92
82
|
super
|
93
83
|
end
|
94
84
|
end
|
data/lib/shex/algebra/not.rb
CHANGED
@@ -45,20 +45,13 @@ module ShEx::Algebra
|
|
45
45
|
end
|
46
46
|
|
47
47
|
##
|
48
|
-
#
|
48
|
+
# expressions must be ShapeExpressions or references to ShapeExpressions and must not reference itself recursively.
|
49
49
|
#
|
50
50
|
# @return [Operator] `self`
|
51
51
|
# @raise [ShEx::StructureError] if the value is invalid
|
52
52
|
def validate!
|
53
|
-
|
54
|
-
|
55
|
-
when RDF::Resource
|
56
|
-
ref = schema.find(expression)
|
57
|
-
ref.is_a?(ShapeExpression) ||
|
58
|
-
structure_error("#{json_type} must reference a ShapeExpression: #{ref}")
|
59
|
-
else
|
60
|
-
structure_error("#{json_type} must reference a ShapeExpression: #{ref}")
|
61
|
-
end
|
53
|
+
validate_expressions!
|
54
|
+
validate_self_references!
|
62
55
|
super
|
63
56
|
end
|
64
57
|
|
data/lib/shex/algebra/one_of.rb
CHANGED
@@ -65,22 +65,12 @@ module ShEx::Algebra
|
|
65
65
|
end
|
66
66
|
|
67
67
|
##
|
68
|
-
# expressions must be TripleExpressions
|
68
|
+
# expressions must be TripleExpressions or references to TripleExpressions
|
69
69
|
#
|
70
70
|
# @return [Operator] `self`
|
71
71
|
# @raise [ShEx::StructureError] if the value is invalid
|
72
72
|
def validate!
|
73
|
-
|
74
|
-
case op
|
75
|
-
when TripleExpression
|
76
|
-
when RDF::Resource
|
77
|
-
ref = schema.find(op)
|
78
|
-
ref.is_a?(TripleExpression) ||
|
79
|
-
structure_error("#{json_type} must reference a TripleExpression: #{ref}")
|
80
|
-
else
|
81
|
-
structure_error("#{json_type} must reference a TripleExpression: #{ref}")
|
82
|
-
end
|
83
|
-
end
|
73
|
+
validate_expressions!
|
84
74
|
super
|
85
75
|
end
|
86
76
|
end
|