shex 0.4.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/AUTHORS +1 -1
- data/LICENSE +1 -1
- data/README.md +45 -30
- data/VERSION +1 -1
- data/etc/doap.ttl +15 -14
- data/lib/shex.rb +22 -21
- data/lib/shex/algebra.rb +48 -36
- data/lib/shex/algebra/and.rb +1 -1
- data/lib/shex/algebra/annotation.rb +1 -1
- data/lib/shex/algebra/each_of.rb +1 -1
- data/lib/shex/algebra/language.rb +22 -0
- data/lib/shex/algebra/node_constraint.rb +13 -4
- data/lib/shex/algebra/not.rb +2 -2
- data/lib/shex/algebra/one_of.rb +1 -1
- data/lib/shex/algebra/operator.rb +70 -44
- data/lib/shex/algebra/or.rb +1 -1
- data/lib/shex/algebra/schema.rb +107 -34
- data/lib/shex/algebra/semact.rb +9 -9
- data/lib/shex/algebra/shape.rb +1 -1
- data/lib/shex/algebra/shape_expression.rb +1 -1
- data/lib/shex/algebra/stem.rb +47 -3
- data/lib/shex/algebra/stem_range.rb +71 -3
- data/lib/shex/algebra/triple_constraint.rb +1 -1
- data/lib/shex/algebra/value.rb +1 -1
- data/lib/shex/extensions/extension.rb +2 -2
- data/lib/shex/extensions/test.rb +18 -16
- data/lib/shex/format.rb +110 -0
- data/lib/shex/meta.rb +4282 -2334
- data/lib/shex/parser.rb +242 -86
- data/lib/shex/shex_context.rb +64 -70
- data/lib/shex/terminals.rb +36 -21
- metadata +31 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e10c5d06f3b45a96dc3f2437680bde6eb406fad42c44efce5102d2d763da3281
|
4
|
+
data.tar.gz: 70afaf45c7d88efb782e85d3de232ec48484d2d69683070920ab1b905e94d790
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5b825dd6fe24fc3ceaee231942756eecb30883650dfb67aa8ae590e5a089a795211b51afac134f8e8ed62161b6a2de13dd2e787da810fd05c771bd29af77481
|
7
|
+
data.tar.gz: 1f6c4189937468a6c0e7505a16f7e8f432beb8f308645c6ef96609f9e570eef30504fd5eac969f156bfd9f5cd95b814f51940b514dc4e024e32d084228e6a28d
|
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,24 +2,25 @@
|
|
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
|
-
<
|
5
|
+
<https://ruby-rdf.github.com/shex>
|
6
6
|
|
7
|
-
[](
|
8
|
-
[](
|
7
|
+
[](https://badge.fury.io/rb/shex)
|
8
|
+
[](https://travis-ci.org/ruby-rdf/shex)
|
9
9
|
[](https://coveralls.io/r/ruby-rdf/shex)
|
10
10
|
[](https://gitter.im/ruby-rdf/rdf?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
11
|
+
[](https://zenodo.org/badge/latestdoi/74419330)
|
11
12
|
|
12
13
|
## Features
|
13
14
|
|
14
15
|
* 100% pure Ruby with minimal dependencies and no bloat.
|
15
16
|
* Fully compatible with [ShEx][ShExSpec] specifications.
|
16
|
-
* 100% free and unencumbered [public domain](
|
17
|
+
* 100% free and unencumbered [public domain](https://unlicense.org/) software.
|
17
18
|
|
18
19
|
## Description
|
19
20
|
|
20
21
|
The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine.
|
21
22
|
|
22
|
-
* `ShEx::Parser` parses ShExC and ShExJ formatted documents generating executable operators which can be serialized as [S-Expressions](
|
23
|
+
* `ShEx::Parser` parses ShExC and ShExJ formatted documents generating executable operators which can be serialized as [S-Expressions](https://en.wikipedia.org/wiki/S-expression).
|
23
24
|
* `ShEx::Algebra` executes operators against Any `RDF::Graph`, including compliant [RDF.rb][].
|
24
25
|
* [Implementation Report](file.earl.html)
|
25
26
|
|
@@ -38,15 +39,15 @@ The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine.
|
|
38
39
|
(doap:name;doap:description|dc:title;dc:description)+;
|
39
40
|
doap:category*;
|
40
41
|
doap:developer IRI;
|
41
|
-
doap:implements [<
|
42
|
+
doap:implements [<http://shex.io/shex-semantics/>]
|
42
43
|
}
|
43
44
|
)
|
44
45
|
graph = RDF::Graph.load("etc/doap.ttl")
|
45
46
|
schema = ShEx.parse(shexc)
|
46
47
|
map = {
|
47
|
-
"
|
48
|
+
"https://rubygems.org/gems/shex" => "TestShape"
|
48
49
|
}
|
49
|
-
schema.satisfies?("
|
50
|
+
schema.satisfies?("https://rubygems.org/gems/shex", graph, map)
|
50
51
|
# => true
|
51
52
|
### Validating a node using ShExJ
|
52
53
|
|
@@ -109,26 +110,26 @@ The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine.
|
|
109
110
|
]
|
110
111
|
}
|
111
112
|
],
|
112
|
-
"min": 1, "max":
|
113
|
+
"min": 1, "max": -1
|
113
114
|
},
|
114
115
|
{
|
115
116
|
"type": "TripleConstraint",
|
116
117
|
"predicate": "http://usefulinc.com/ns/doap#category",
|
117
118
|
"valueExpr": {"type": "NodeConstraint", "nodeKind": "iri"},
|
118
|
-
"min": 0, "max":
|
119
|
+
"min": 0, "max": -1
|
119
120
|
},
|
120
121
|
{
|
121
122
|
"type": "TripleConstraint",
|
122
123
|
"predicate": "http://usefulinc.com/ns/doap#developer",
|
123
124
|
"valueExpr": {"type": "NodeConstraint", "nodeKind": "iri"},
|
124
|
-
"min": 1, "max":
|
125
|
+
"min": 1, "max": -1
|
125
126
|
},
|
126
127
|
{
|
127
128
|
"type": "TripleConstraint",
|
128
129
|
"predicate": "http://usefulinc.com/ns/doap#implements",
|
129
130
|
"valueExpr": {
|
130
131
|
"type": "NodeConstraint",
|
131
|
-
"values": ["
|
132
|
+
"values": ["http://shex.io/shex-semantics/"]
|
132
133
|
}
|
133
134
|
}
|
134
135
|
]
|
@@ -138,12 +139,12 @@ The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine.
|
|
138
139
|
})
|
139
140
|
graph = RDF::Graph.load("etc/doap.ttl")
|
140
141
|
schema = ShEx.parse(shexj, format: :shexj)
|
141
|
-
map = {"
|
142
|
-
schema.satisfies?("
|
142
|
+
map = {"https://rubygems.org/gems/shex" => "TestShape"}
|
143
|
+
schema.satisfies?("https://rubygems.org/gems/shex", graph, map)
|
143
144
|
# => true
|
144
145
|
|
145
146
|
## Extensions
|
146
|
-
ShEx has an extension mechanism using [Semantic Actions](
|
147
|
+
ShEx has an extension mechanism using [Semantic Actions](http://shex.io/shex-semantics/#semantic-actions). Extensions may be implemented in Ruby ShEx by sub-classing {ShEx::Extension} and implementing {ShEx::Extension#visit} and possibly {ShEx::Extension#initialize}, {ShEx::Extension#enter}, {ShEx::Extension#exit}, and {ShEx::Extension#close}. The `#visit` method will be called as part of the `#satisfies?` operation.
|
147
148
|
|
148
149
|
require 'shex'
|
149
150
|
class ShEx::Test < ShEx::Extension("http://shex.io/extensions/Test/")
|
@@ -164,9 +165,23 @@ The `#initialize` method is called when {ShEx::Algebra::Schema#execute} starts a
|
|
164
165
|
|
165
166
|
To make sure your extension is found, make sure to require it before the shape is executed.
|
166
167
|
|
168
|
+
## Command Line
|
169
|
+
When the `linkeddata` gem is installed, RDF.rb includes a `rdf` executable which acts as a wrapper to perform a number of different
|
170
|
+
operations on RDF files, including ShEx. The commands specific to ShEx is
|
171
|
+
|
172
|
+
* `shex`: Validate repository given shape
|
173
|
+
|
174
|
+
Using this command requires either a `shex-input` where the ShEx schema is URI encoded, or `shex`, which references a URI or file path to the schema. Other required options are `shape` and `focus`.
|
175
|
+
|
176
|
+
Example usage:
|
177
|
+
|
178
|
+
rdf shex https://raw.githubusercontent.com/ruby-rdf/shex/develop/etc/doap.ttl \
|
179
|
+
--schema https://raw.githubusercontent.com/ruby-rdf/shex/develop/etc/doap.shex \
|
180
|
+
--focus https://rubygems.org/gems/shex
|
181
|
+
|
167
182
|
## Documentation
|
168
183
|
|
169
|
-
<
|
184
|
+
<https://rubydoc.info/github/ruby-rdf/shex>
|
170
185
|
|
171
186
|
|
172
187
|
## Implementation Notes
|
@@ -178,12 +193,12 @@ The result of parsing either ShExC or ShExJ is the creation of a set of executab
|
|
178
193
|
|
179
194
|
## Dependencies
|
180
195
|
|
181
|
-
* [Ruby](
|
182
|
-
* [RDF.rb](
|
196
|
+
* [Ruby](https://ruby-lang.org/) (>= 2.4)
|
197
|
+
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1)
|
183
198
|
|
184
199
|
## Installation
|
185
200
|
|
186
|
-
The recommended installation method is via [RubyGems](
|
201
|
+
The recommended installation method is via [RubyGems](https://rubygems.org/).
|
187
202
|
To install the latest official release of RDF.rb, do:
|
188
203
|
|
189
204
|
% [sudo] gem install shex
|
@@ -197,21 +212,21 @@ To get a local working copy of the development repository, do:
|
|
197
212
|
Alternatively, download the latest development version as a tarball as
|
198
213
|
follows:
|
199
214
|
|
200
|
-
% wget
|
215
|
+
% wget https://github.com/ruby-rdf/shex/tarball/master
|
201
216
|
|
202
217
|
## Resources
|
203
218
|
|
204
|
-
* <
|
205
|
-
* <
|
206
|
-
* <
|
219
|
+
* <https://rubydoc.info/github/ruby-rdf/shex>
|
220
|
+
* <https://github.com/ruby-rdf/shex>
|
221
|
+
* <https://rubygems.org/gems/shex>
|
207
222
|
|
208
223
|
## Mailing List
|
209
224
|
|
210
|
-
* <
|
225
|
+
* <https://lists.w3.org/Archives/Public/public-rdf-ruby/>
|
211
226
|
|
212
227
|
## Author
|
213
228
|
|
214
|
-
* [Gregg Kellogg](
|
229
|
+
* [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>
|
215
230
|
|
216
231
|
## Contributing
|
217
232
|
|
@@ -235,9 +250,9 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
|
|
235
250
|
## License
|
236
251
|
|
237
252
|
This is free and unencumbered public domain software. For more information,
|
238
|
-
see <
|
253
|
+
see <https://unlicense.org/> or the accompanying {file:LICENSE} file.
|
239
254
|
|
240
|
-
[ShExSpec]: https://
|
241
|
-
[RDF]:
|
242
|
-
[RDF.rb]:
|
243
|
-
[EBNF]:
|
255
|
+
[ShExSpec]: https://shex.io/shex-semantics/
|
256
|
+
[RDF]: https://www.w3.org/RDF/
|
257
|
+
[RDF.rb]: https://rubydoc.info/github/ruby-rdf/rdf
|
258
|
+
[EBNF]: https://rubygems.org/gems/ebnf
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.1
|
data/etc/doap.ttl
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
@base <https://rubygems.org/gems/shex> .
|
1
2
|
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
2
3
|
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
3
4
|
@prefix dc: <http://purl.org/dc/terms/> .
|
@@ -7,27 +8,27 @@
|
|
7
8
|
@prefix ex: <http://example.org/> .
|
8
9
|
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
9
10
|
|
10
|
-
<
|
11
|
+
<https://rubygems.org/gems/shex> a doap:Project, earl:TestSubject, earl:Software ;
|
11
12
|
doap:name "ShEx.rb" ;
|
12
|
-
doap:homepage <
|
13
|
-
doap:license <
|
13
|
+
doap:homepage <https://ruby-rdf.github.com/shex> ;
|
14
|
+
doap:license <https://unlicense.org/1.0/> ;
|
14
15
|
doap:shortdesc "ShEx is a Shape Expression engine for Ruby."@en ;
|
15
16
|
doap:description "ShEx is an Shape Expression engine for the RDF.rb library suite."@en ;
|
16
17
|
doap:created "2016-12-09"^^xsd:date ;
|
17
18
|
doap:programming-language "Ruby" ;
|
18
|
-
doap:implements <
|
19
|
+
doap:implements <http://shex.io/shex-semantics/> ;
|
19
20
|
doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
|
20
21
|
<http://dbpedia.org/resource/Ruby_(programming_language)> ;
|
21
|
-
doap:download-page <
|
22
|
-
doap:mailing-list <
|
23
|
-
doap:bug-database <
|
24
|
-
doap:blog <
|
25
|
-
doap:developer <
|
26
|
-
doap:maintainer <
|
27
|
-
doap:documenter <
|
28
|
-
foaf:maker <
|
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> ;
|
29
30
|
dc:title "ShEx.rb" ;
|
30
31
|
dc:description "ShEx is an Shape Expression engine for the RDF.rb library suite."@en ;
|
31
32
|
dc:date "2016-12-09"^^xsd:date ;
|
32
|
-
dc:creator <
|
33
|
-
dc:isPartOf <
|
33
|
+
dc:creator <https://greggkellogg.net/foaf#me> ;
|
34
|
+
dc:isPartOf <https://rubygems.org/gems/rdf> .
|
data/lib/shex.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
##
|
2
2
|
# A ShEx runtime for RDF.rb.
|
3
3
|
#
|
4
|
-
# @see https://
|
4
|
+
# @see https://shex.io/shex-semantics/#shexc
|
5
5
|
module ShEx
|
6
|
+
require 'shex/format'
|
6
7
|
autoload :Algebra, 'shex/algebra'
|
7
8
|
autoload :Meta, 'shex/meta'
|
8
9
|
autoload :Parser, 'shex/parser'
|
@@ -11,7 +12,7 @@ module ShEx
|
|
11
12
|
autoload :VERSION, 'shex/version'
|
12
13
|
|
13
14
|
# Location of the ShEx JSON-LD context
|
14
|
-
CONTEXT = "
|
15
|
+
CONTEXT = "http://www.w3.org/ns/shex.jsonld"
|
15
16
|
|
16
17
|
# Extensions defined in this gem
|
17
18
|
EXTENSIONS = %w{test}
|
@@ -32,13 +33,13 @@ module ShEx
|
|
32
33
|
# @raise (see ShEx::Parser#parse)
|
33
34
|
def self.parse(expression, format: 'shexc', **options)
|
34
35
|
case format.to_s
|
35
|
-
when 'shexc' then Parser.new(expression, options).parse
|
36
|
+
when 'shexc' then Parser.new(expression, **options).parse
|
36
37
|
when 'shexj'
|
37
38
|
expression = expression.read if expression.respond_to?(:read)
|
38
|
-
Algebra.from_shexj(JSON.parse(expression), options)
|
39
|
+
Algebra.from_shexj(JSON.parse(expression), **options)
|
39
40
|
when 'sxp'
|
40
41
|
expression = expression.read if expression.respond_to?(:read)
|
41
|
-
Algebra.from_sxp(expression, options)
|
42
|
+
Algebra.from_sxp(expression, **options)
|
42
43
|
else raise "Unknown expression format: #{format.inspect}"
|
43
44
|
end
|
44
45
|
end
|
@@ -55,8 +56,8 @@ module ShEx
|
|
55
56
|
# @return (see ShEx::Parser#parse)
|
56
57
|
# @raise (see ShEx::Parser#parse)
|
57
58
|
def self.open(filename, format: 'shexc', **options, &block)
|
58
|
-
RDF::Util::File.open_file(filename, options) do |file|
|
59
|
-
self.parse(file,
|
59
|
+
RDF::Util::File.open_file(filename, **options) do |file|
|
60
|
+
self.parse(file, format: format, **options)
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
@@ -65,17 +66,17 @@ module ShEx
|
|
65
66
|
#
|
66
67
|
# @example executing a ShExC schema
|
67
68
|
# graph = RDF::Graph.load("etc/doap.ttl")
|
68
|
-
# ShEx.execute('etc/doap.shex', graph, "
|
69
|
+
# ShEx.execute('etc/doap.shex', graph, "https://rubygems.org/gems/shex", "")
|
69
70
|
#
|
70
71
|
# @param [IO, StringIO, String, #to_s] expression (ShExC or ShExJ)
|
71
72
|
# @param (see ShEx::Algebra::Schema#execute)
|
72
73
|
# @return (see ShEx::Algebra::Schema#execute)
|
73
74
|
# @raise (see ShEx::Algebra::Schema#execute)
|
74
|
-
def self.execute(expression, queryable,
|
75
|
-
shex = self.parse(expression,
|
75
|
+
def self.execute(expression, queryable, map, format: 'shexc', **options)
|
76
|
+
shex = self.parse(expression, format: format, **options)
|
76
77
|
queryable = queryable || RDF::Graph.new
|
77
78
|
|
78
|
-
shex.execute(
|
79
|
+
shex.execute(queryable, map, **options)
|
79
80
|
end
|
80
81
|
|
81
82
|
##
|
@@ -83,17 +84,17 @@ module ShEx
|
|
83
84
|
#
|
84
85
|
# @example executing a ShExC schema
|
85
86
|
# graph = RDF::Graph.load("etc/doap.ttl")
|
86
|
-
# ShEx.execute('etc/doap.shex', graph, "
|
87
|
+
# ShEx.execute('etc/doap.shex', graph, "https://rubygems.org/gems/shex", "")
|
87
88
|
#
|
88
89
|
# @param [IO, StringIO, String, #to_s] expression (ShExC or ShExJ)
|
89
90
|
# @param (see ShEx::Algebra::Schema#satisfies?)
|
90
91
|
# @return (see ShEx::Algebra::Schema#satisfies?)
|
91
92
|
# @raise (see ShEx::Algebra::Schema#satisfies?)
|
92
|
-
def self.satisfies?(expression, queryable,
|
93
|
-
shex = self.parse(expression,
|
93
|
+
def self.satisfies?(expression, queryable, map, format: 'shexc', **options)
|
94
|
+
shex = self.parse(expression, format: format, **options)
|
94
95
|
queryable = queryable || RDF::Graph.new
|
95
96
|
|
96
|
-
shex.satisfies?(
|
97
|
+
shex.satisfies?(queryable, map, **options)
|
97
98
|
end
|
98
99
|
|
99
100
|
##
|
@@ -115,7 +116,7 @@ module ShEx
|
|
115
116
|
# @param [String, #to_s] message
|
116
117
|
# @param [Hash{Symbol => Object}] options
|
117
118
|
# @option options [Integer] :code (422)
|
118
|
-
def initialize(message, options
|
119
|
+
def initialize(message, **options)
|
119
120
|
@code = options.fetch(:status_code, 422)
|
120
121
|
super(message.to_s)
|
121
122
|
end
|
@@ -129,14 +130,14 @@ module ShEx
|
|
129
130
|
class NotSatisfied < Error
|
130
131
|
##
|
131
132
|
# The expression which was not satified
|
132
|
-
# @return [ShEx::
|
133
|
+
# @return [ShEx::Algebra::ShapeExpression]
|
133
134
|
attr_reader :expression
|
134
135
|
|
135
136
|
##
|
136
137
|
# Initializes a new parser error instance.
|
137
138
|
#
|
138
|
-
# @param [String, #to_s]
|
139
|
-
# @param [
|
139
|
+
# @param [String, #to_s] message
|
140
|
+
# @param [ShEx::Algebra::ShapeExpression] expression
|
140
141
|
def initialize(message, expression: self)
|
141
142
|
@expression = expression
|
142
143
|
super(message.to_s)
|
@@ -157,8 +158,8 @@ module ShEx
|
|
157
158
|
##
|
158
159
|
# Initializes a new parser error instance.
|
159
160
|
#
|
160
|
-
# @param [String, #to_s]
|
161
|
-
# @param [
|
161
|
+
# @param [String, #to_s] message
|
162
|
+
# @param [ShEx::Algebra::TripleExpression] expression
|
162
163
|
def initialize(message, expression: self)
|
163
164
|
@expression = expression
|
164
165
|
super(message.to_s)
|
data/lib/shex/algebra.rb
CHANGED
@@ -5,27 +5,34 @@ require 'sxp'
|
|
5
5
|
module ShEx
|
6
6
|
# Based on the SPARQL Algebra, operators for executing a patch
|
7
7
|
#
|
8
|
-
# @author [Gregg Kellogg](
|
8
|
+
# @author [Gregg Kellogg](https://greggkellogg.net/)
|
9
9
|
module Algebra
|
10
|
-
autoload :And,
|
11
|
-
autoload :Annotation,
|
12
|
-
autoload :EachOf,
|
13
|
-
autoload :External,
|
14
|
-
autoload :
|
15
|
-
autoload :
|
16
|
-
autoload :
|
17
|
-
autoload :
|
18
|
-
autoload :
|
19
|
-
autoload :
|
20
|
-
autoload :
|
21
|
-
autoload :
|
22
|
-
autoload :
|
23
|
-
autoload :
|
24
|
-
autoload :
|
25
|
-
autoload :
|
10
|
+
autoload :And, 'shex/algebra/and'
|
11
|
+
autoload :Annotation, 'shex/algebra/annotation'
|
12
|
+
autoload :EachOf, 'shex/algebra/each_of'
|
13
|
+
autoload :External, 'shex/algebra/external'
|
14
|
+
autoload :IriStem, 'shex/algebra/stem'
|
15
|
+
autoload :IriStemRange, 'shex/algebra/stem_range'
|
16
|
+
autoload :Language, 'shex/algebra/language'
|
17
|
+
autoload :LanguageStem, 'shex/algebra/stem'
|
18
|
+
autoload :LanguageStemRange,'shex/algebra/stem_range'
|
19
|
+
autoload :LiteralStem, 'shex/algebra/stem'
|
20
|
+
autoload :LiteralStemRange, 'shex/algebra/stem_range'
|
21
|
+
autoload :NodeConstraint, 'shex/algebra/node_constraint'
|
22
|
+
autoload :Not, 'shex/algebra/not'
|
23
|
+
autoload :OneOf, 'shex/algebra/one_of'
|
24
|
+
autoload :Operator, 'shex/algebra/operator'
|
25
|
+
autoload :Or, 'shex/algebra/or'
|
26
|
+
autoload :Schema, 'shex/algebra/schema'
|
27
|
+
autoload :SemAct, 'shex/algebra/semact'
|
28
|
+
autoload :Shape, 'shex/algebra/shape'
|
29
|
+
autoload :ShapeExpression, 'shex/algebra/shape_expression'
|
30
|
+
autoload :Start, 'shex/algebra/start'
|
31
|
+
autoload :Stem, 'shex/algebra/stem'
|
32
|
+
autoload :StemRange, 'shex/algebra/stem_range'
|
26
33
|
autoload :TripleConstraint, 'shex/algebra/triple_constraint'
|
27
34
|
autoload :TripleExpression, 'shex/algebra/triple_expression'
|
28
|
-
autoload :Value,
|
35
|
+
autoload :Value, 'shex/algebra/value'
|
29
36
|
|
30
37
|
|
31
38
|
##
|
@@ -43,28 +50,33 @@ module ShEx
|
|
43
50
|
# @option options [RDF::URI] :base
|
44
51
|
# @option options [Hash{String => RDF::URI}] :prefixes
|
45
52
|
# @return [Operator]
|
46
|
-
def self.from_shexj(operator, options
|
53
|
+
def self.from_shexj(operator, **options)
|
47
54
|
raise ArgumentError unless operator.is_a?(Hash)
|
48
55
|
klass = case operator['type']
|
49
|
-
when 'Annotation'
|
50
|
-
when 'EachOf'
|
51
|
-
when '
|
52
|
-
when '
|
53
|
-
when '
|
54
|
-
when '
|
55
|
-
when '
|
56
|
-
when '
|
57
|
-
when '
|
58
|
-
when '
|
59
|
-
when '
|
60
|
-
when '
|
61
|
-
when '
|
62
|
-
when '
|
63
|
-
when '
|
64
|
-
|
56
|
+
when 'Annotation' then Annotation
|
57
|
+
when 'EachOf' then EachOf
|
58
|
+
when 'IriStem' then IriStem
|
59
|
+
when 'IriStemRange' then IriStemRange
|
60
|
+
when 'Language' then Language
|
61
|
+
when 'LanguageStem' then LanguageStem
|
62
|
+
when 'LanguageStemRange' then LanguageStemRange
|
63
|
+
when 'LiteralStem' then LiteralStem
|
64
|
+
when 'LiteralStemRange' then LiteralStemRange
|
65
|
+
when 'NodeConstraint' then NodeConstraint
|
66
|
+
when 'OneOf' then OneOf
|
67
|
+
when 'Schema' then Schema
|
68
|
+
when 'SemAct' then SemAct
|
69
|
+
when 'Shape' then Shape
|
70
|
+
when 'ShapeAnd' then And
|
71
|
+
when 'ShapeExternal' then External
|
72
|
+
when 'ShapeNot' then Not
|
73
|
+
when 'ShapeOr' then Or
|
74
|
+
when 'TripleConstraint' then TripleConstraint
|
75
|
+
when 'Wildcard' then StemRange
|
76
|
+
else raise ArgumentError, "unknown type #{operator['type'].inspect}"
|
65
77
|
end
|
66
78
|
|
67
|
-
klass.from_shexj(operator, options)
|
79
|
+
klass.from_shexj(operator, **options)
|
68
80
|
end
|
69
81
|
end
|
70
82
|
end
|