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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d590c5b6411af716a57b781db5d2957701c197f1ee0a35ade6934b9012f8a4ea
4
- data.tar.gz: f8ebee1f895654763ce8bc69b400aef5aaf5f57e36ccddbdb3326cbb0da5c863
3
+ metadata.gz: e45bfef778f047d77b25295bf5c41cfc1ed69d040a1ea76dd145734a755faffd
4
+ data.tar.gz: 91b81f28e0db8a507924627fd94bfc8265301588346715a9102dbf9cea091ab1
5
5
  SHA512:
6
- metadata.gz: afb67c8fcb7c69393d60e70a8035e7066e5a4fcb4009a64232d82cc3b724758bd2cdcc42774e49765a32d2b15b87b9dd5a74ae593b840f969022ba9def8ae89c
7
- data.tar.gz: d8c30c1ae94fcbd59cdb17f8190daf2cda101471e5076d76b81f80645fe8b26d72eca48c385ee0e73c5772f15415511b16883527c9401aa010b2a72f299976c6
6
+ metadata.gz: e6e9ecf3bbb822070f1d870233eed17ac5ac3a353fca09f8a782b3d31c3538f27d2c4ff2f53336fbcade2b65460c9598309c7bbb2cdb790f90edbc229fab2a17
7
+ data.tar.gz: 83fa124c1fb95b385ff86fdf707c2a0778261c4f92fce32becca03d7cd29b1e73b7fc56c86746a1dff2d6ba60306d55aa7c81918952142b60f80197bc1edf032
data/AUTHORS CHANGED
@@ -1 +1 @@
1
- * Gregg Kellogg <gregg@kellogg-assoc.com>
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 <http://unlicense.org>
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
- <http://ruby-rdf.github.com/shex>
6
-
7
- [![Gem Version](https://badge.fury.io/rb/shex.png)](http://badge.fury.io/rb/shex)
8
- [![Build Status](https://travis-ci.org/ruby-rdf/shex.png?branch=master)](http://travis-ci.org/ruby-rdf/shex)
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](http://unlicense.org/) software.
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](http://en.wikipedia.org/wiki/S-expression).
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
- <TestShape> EXTRA a {
38
- a doap:Project;
39
- (doap:name;doap:description|dc:title;dc:description)+;
40
- doap:category*;
41
- doap:developer IRI;
42
- doap:implements [<http://shex.io/shex-semantics/>]
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
- "http://rubygems.org/gems/shex" => "TestShape"
50
+ RDF::URI("https://rubygems.org/gems/shex") => RDF::URI("http://example.com/TestShape")
49
51
  }
50
- schema.satisfies?("http://rubygems.org/gems/shex", graph, map)
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
- "prefixes": {
61
- "doap": "http://usefulinc.com/ns/doap#",
62
- "dc": "http://purl.org/dc/terms/"
63
- },
64
- "shapes": {
65
- "TestShape": {
66
- "type": "Shape",
67
- "extra": ["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"],
68
- "expression": {
69
- "type": "EachOf",
70
- "expressions": [
71
- {
72
- "type": "TripleConstraint",
73
- "predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
74
- "valueExpr": {
75
- "type": "NodeConstraint",
76
- "values": ["http://usefulinc.com/ns/doap#Project"]
77
- }
78
- },
79
- {
80
- "type": "OneOf",
81
- "expressions": [
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
- "min": 1, "max": -1
114
- },
115
- {
116
- "type": "TripleConstraint",
117
- "predicate": "http://usefulinc.com/ns/doap#category",
118
- "valueExpr": {"type": "NodeConstraint", "nodeKind": "iri"},
119
- "min": 0, "max": -1
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
- "type": "TripleConstraint",
123
- "predicate": "http://usefulinc.com/ns/doap#developer",
124
- "valueExpr": {"type": "NodeConstraint", "nodeKind": "iri"},
125
- "min": 1, "max": -1
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
- "type": "TripleConstraint",
129
- "predicate": "http://usefulinc.com/ns/doap#implements",
130
- "valueExpr": {
131
- "type": "NodeConstraint",
132
- "values": ["http://shex.io/shex-semantics/"]
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 = {"http://rubygems.org/gems/shex" => "TestShape"}
143
- schema.satisfies?("http://rubygems.org/gems/shex", graph, map)
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 http://rubygems.org/gems/shex
189
+ --focus https://rubygems.org/gems/shex
181
190
 
182
191
  ## Documentation
183
192
 
184
- <http://rubydoc.info/github/ruby-rdf/shex>
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 first, follow and branch tables, and uses the `Parser` and `Lexer` modules to implement the ShExC parser.
197
+ The ShExC parser uses the [EBNF][] gem to generate a [PEG][] parser.
189
198
 
190
- The parser takes branch and follow tables generated from the [ShEx Grammar](file.shex.html) described in the [specification][ShExSpec]. Branch and Follow tables are specified in the generated {ShEx::Meta}.
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](http://ruby-lang.org/) (>= 2.4)
197
- * [RDF.rb](http://rubygems.org/gems/rdf) (~> 3.1)
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](http://rubygems.org/).
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 http://github.com/ruby-rdf/shex/tarball/master
223
+ % wget https://github.com/ruby-rdf/shex/tarball/master
216
224
 
217
225
  ## Resources
218
226
 
219
- * <http://rubydoc.info/github/ruby-rdf/shex>
220
- * <http://github.com/ruby-rdf/shex>
221
- * <http://rubygems.org/gems/shex>
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
- * <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
233
+ * <https://lists.w3.org/Archives/Public/public-rdf-ruby/>
226
234
 
227
235
  ## Author
228
236
 
229
- * [Gregg Kellogg](http://github.com/gkellogg) - <http://greggkellogg.net/>
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 <http://unlicense.org/> or the accompanying {file:LICENSE} file.
254
-
255
- [ShExSpec]: http://shex.io/shex-semantics/
256
- [RDF]: http://www.w3.org/RDF/
257
- [RDF.rb]: http://rubydoc.info/github/ruby-rdf/rdf
258
- [EBNF]: http://rubygems.org/gems/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.0
1
+ 0.6.4
data/etc/doap.ttl CHANGED
@@ -1,4 +1,4 @@
1
- @base <http://rubygems.org/gems/shex> .
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
- <http://rubygems.org/gems/shex> a doap:Project, earl:TestSubject, earl:Software ;
12
- doap:name "ShEx.rb" ;
13
- doap:homepage <http://ruby-rdf.github.com/shex> ;
14
- doap:license <http://creativecommons.org/licenses/publicdomain/> ;
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 <http://rubygems.org/gems/shex> ;
23
- doap:mailing-list <http://lists.w3.org/Archives/Public/public-rdf-ruby/> ;
24
- doap:bug-database <http://github.com/ruby-rdf/shex/issues> ;
25
- doap:blog <http://greggkellogg.net/> ;
26
- doap:developer <http://greggkellogg.net/foaf#me> ;
27
- doap:maintainer <http://greggkellogg.net/foaf#me> ;
28
- doap:documenter <http://greggkellogg.net/foaf#me> ;
29
- foaf:maker <http://greggkellogg.net/foaf#me> ;
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 <http://greggkellogg.net/foaf#me> ;
34
- dc:isPartOf <http://rubygems.org/gems/rdf> .
31
+ dc:creator <https://greggkellogg.net/foaf#me> ;
32
+ dc:isPartOf <https://rubygems.org/gems/rdf> .
@@ -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
- expressions.each do |op|
70
- case op
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
 
@@ -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
- expressions.each do |op|
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
@@ -0,0 +1,6 @@
1
+ module ShEx::Algebra
2
+ ##
3
+ class Import < Operator::Unary
4
+ NAME = :import
5
+ end
6
+ end
@@ -45,20 +45,13 @@ module ShEx::Algebra
45
45
  end
46
46
 
47
47
  ##
48
- # expression must be a ShapeExpression
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
- case expression
54
- when ShapeExpression
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
 
@@ -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
- expressions.each do |op|
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