shex 0.5.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/AUTHORS +1 -1
- data/LICENSE +1 -1
- data/README.md +40 -35
- data/VERSION +1 -1
- data/etc/doap.ttl +17 -19
- 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/node_constraint.rb +1 -1
- data/lib/shex/algebra/not.rb +1 -1
- data/lib/shex/algebra/one_of.rb +1 -1
- data/lib/shex/algebra/operator.rb +32 -33
- data/lib/shex/algebra/or.rb +1 -1
- data/lib/shex/algebra/schema.rb +4 -4
- data/lib/shex/algebra/semact.rb +9 -9
- data/lib/shex/algebra/shape.rb +3 -3
- data/lib/shex/algebra/stem.rb +1 -1
- data/lib/shex/algebra/stem_range.rb +4 -4
- data/lib/shex/algebra/triple_constraint.rb +1 -1
- data/lib/shex/algebra.rb +3 -3
- data/lib/shex/extensions/test.rb +18 -16
- data/lib/shex/format.rb +4 -6
- data/lib/shex/meta.rb +338 -9859
- data/lib/shex/parser.rb +572 -468
- data/lib/shex.rb +14 -13
- metadata +75 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f2a6bb3da7f7e92a1a168e6390cbd1d41406df0baf7b5d76f358843b6e3fb071
|
4
|
+
data.tar.gz: 34a49a33ec8d8208cef666e913d9dd33fe02355caf7cff8ce2b54c2c9e65a4c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da5cefbf0b4831c741b3bad56091077b60ea178acaac3e4c5fc0a554a87f97c26dc1086fdbd9a6e84427e3db8d1df188b849106dc85b29de789e6caff34d6544
|
7
|
+
data.tar.gz: 65d6123a33922a51061865181bdcf98a76b150442f641652e88f93b0c3939e47229f7bf66ca65d1a4380935f0453f5c78601299113b9dfcdd509605c6f28687c
|
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,23 @@
|
|
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
|
-
[![
|
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)
|
9
|
+
[![DOI](https://zenodo.org/badge/74419330.svg)](https://zenodo.org/badge/latestdoi/74419330)
|
11
10
|
|
12
11
|
## Features
|
13
12
|
|
14
13
|
* 100% pure Ruby with minimal dependencies and no bloat.
|
15
14
|
* Fully compatible with [ShEx][ShExSpec] specifications.
|
16
|
-
* 100% free and unencumbered [public domain](
|
15
|
+
* 100% free and unencumbered [public domain](https://unlicense.org/) software.
|
17
16
|
|
18
17
|
## Description
|
19
18
|
|
20
|
-
The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine.
|
19
|
+
The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine version 2.0.
|
21
20
|
|
22
|
-
* `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][].
|
23
22
|
* `ShEx::Algebra` executes operators against Any `RDF::Graph`, including compliant [RDF.rb][].
|
24
23
|
* [Implementation Report](file.earl.html)
|
25
24
|
|
@@ -44,9 +43,9 @@ The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine.
|
|
44
43
|
graph = RDF::Graph.load("etc/doap.ttl")
|
45
44
|
schema = ShEx.parse(shexc)
|
46
45
|
map = {
|
47
|
-
"
|
46
|
+
"https://rubygems.org/gems/shex" => "TestShape"
|
48
47
|
}
|
49
|
-
schema.satisfies?("
|
48
|
+
schema.satisfies?("https://rubygems.org/gems/shex", graph, map)
|
50
49
|
# => true
|
51
50
|
### Validating a node using ShExJ
|
52
51
|
|
@@ -138,8 +137,8 @@ The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine.
|
|
138
137
|
})
|
139
138
|
graph = RDF::Graph.load("etc/doap.ttl")
|
140
139
|
schema = ShEx.parse(shexj, format: :shexj)
|
141
|
-
map = {"
|
142
|
-
schema.satisfies?("
|
140
|
+
map = {"https://rubygems.org/gems/shex" => "TestShape"}
|
141
|
+
schema.satisfies?("https://rubygems.org/gems/shex", graph, map)
|
143
142
|
# => true
|
144
143
|
|
145
144
|
## Extensions
|
@@ -176,28 +175,27 @@ Example usage:
|
|
176
175
|
|
177
176
|
rdf shex https://raw.githubusercontent.com/ruby-rdf/shex/develop/etc/doap.ttl \
|
178
177
|
--schema https://raw.githubusercontent.com/ruby-rdf/shex/develop/etc/doap.shex \
|
179
|
-
--focus
|
178
|
+
--focus https://rubygems.org/gems/shex
|
180
179
|
|
181
180
|
## Documentation
|
182
181
|
|
183
|
-
<
|
182
|
+
<https://rubydoc.info/github/ruby-rdf/shex>
|
184
183
|
|
185
184
|
|
186
185
|
## Implementation Notes
|
187
|
-
The ShExC parser uses the [EBNF][] gem to generate
|
188
|
-
|
189
|
-
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}.
|
186
|
+
The ShExC parser uses the [EBNF][] gem to generate a [PEG][] parser.
|
190
187
|
|
191
|
-
The
|
188
|
+
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.
|
192
189
|
|
193
190
|
## Dependencies
|
194
191
|
|
195
|
-
* [Ruby](
|
196
|
-
* [RDF.rb](
|
192
|
+
* [Ruby](https://ruby-lang.org/) (>= 2.4)
|
193
|
+
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1)
|
194
|
+
* [SPARQL gem](https://rubygems.org/gems/sparql) (~> 3.1)
|
197
195
|
|
198
196
|
## Installation
|
199
197
|
|
200
|
-
The recommended installation method is via [RubyGems](
|
198
|
+
The recommended installation method is via [RubyGems](https://rubygems.org/).
|
201
199
|
To install the latest official release of RDF.rb, do:
|
202
200
|
|
203
201
|
% [sudo] gem install shex
|
@@ -211,21 +209,21 @@ To get a local working copy of the development repository, do:
|
|
211
209
|
Alternatively, download the latest development version as a tarball as
|
212
210
|
follows:
|
213
211
|
|
214
|
-
% wget
|
212
|
+
% wget https://github.com/ruby-rdf/shex/tarball/master
|
215
213
|
|
216
214
|
## Resources
|
217
215
|
|
218
|
-
* <
|
219
|
-
* <
|
220
|
-
* <
|
216
|
+
* <https://rubydoc.info/github/ruby-rdf/shex>
|
217
|
+
* <https://github.com/ruby-rdf/shex>
|
218
|
+
* <https://rubygems.org/gems/shex>
|
221
219
|
|
222
220
|
## Mailing List
|
223
221
|
|
224
|
-
* <
|
222
|
+
* <https://lists.w3.org/Archives/Public/public-rdf-ruby/>
|
225
223
|
|
226
224
|
## Author
|
227
225
|
|
228
|
-
* [Gregg Kellogg](
|
226
|
+
* [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>
|
229
227
|
|
230
228
|
## Contributing
|
231
229
|
|
@@ -244,14 +242,21 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
|
|
244
242
|
enough, be assured we will eventually add you in there.
|
245
243
|
* Do note that in order for us to merge any non-trivial changes (as a rule
|
246
244
|
of thumb, additions larger than about 15 lines of code), we need an
|
247
|
-
explicit [public domain dedication][PDD] on record from you
|
245
|
+
explicit [public domain dedication][PDD] on record from you,
|
246
|
+
which you will be asked to agree to on the first commit to a repo within the organization.
|
247
|
+
Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.
|
248
248
|
|
249
249
|
## License
|
250
250
|
|
251
251
|
This is free and unencumbered public domain software. For more information,
|
252
|
-
see <
|
253
|
-
|
254
|
-
[ShExSpec]: http://shex.io/shex-semantics/
|
255
|
-
[RDF]:
|
256
|
-
[RDF.rb]:
|
257
|
-
[EBNF]:
|
252
|
+
see <https://unlicense.org/> or the accompanying {file:LICENSE} file.
|
253
|
+
|
254
|
+
[ShExSpec]: http://shex.io/shex-semantics-20170713/
|
255
|
+
[RDF]: https://www.w3.org/RDF/
|
256
|
+
[RDF.rb]: https://rubydoc.info/github/ruby-rdf/rdf
|
257
|
+
[EBNF]: https://rubygems.org/gems/ebnf
|
258
|
+
[YARD]: https://yardoc.org/
|
259
|
+
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
260
|
+
[PDD]: https://unlicense.org/#unlicensing-contributions
|
261
|
+
[PEG]: https://en.wikipedia.org/wiki/Parsing_expression_grammar "Parsing Expression Grammar"
|
262
|
+
[S-Expression]: https://en.wikipedia.org/wiki/S-expression
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.3
|
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
@@ -19,7 +19,7 @@ module ShEx::Algebra
|
|
19
19
|
# Creates an operator instance from a parsed ShExJ representation
|
20
20
|
# @param (see Operator#from_shexj)
|
21
21
|
# @return [Operator]
|
22
|
-
def self.from_shexj(operator, options
|
22
|
+
def self.from_shexj(operator, **options)
|
23
23
|
raise ArgumentError unless operator.is_a?(Hash) && operator['type'] == 'ShapeAnd'
|
24
24
|
raise ArgumentError, "missing shapeExprs in #{operator.inspect}" unless operator.has_key?('shapeExprs')
|
25
25
|
super
|
@@ -7,7 +7,7 @@ module ShEx::Algebra
|
|
7
7
|
# Creates an operator instance from a parsed ShExJ representation
|
8
8
|
# @param (see Operator#from_shexj)
|
9
9
|
# @return [Operator]
|
10
|
-
def self.from_shexj(operator, options
|
10
|
+
def self.from_shexj(operator, **options)
|
11
11
|
raise ArgumentError unless operator.is_a?(Hash) && operator['type'] == "Annotation"
|
12
12
|
raise ArgumentError, "missing predicate in #{operator.inspect}" unless operator.has_key?('predicate')
|
13
13
|
raise ArgumentError, "missing object in #{operator.inspect}" unless operator.has_key?('object')
|
data/lib/shex/algebra/each_of.rb
CHANGED
@@ -8,7 +8,7 @@ module ShEx::Algebra
|
|
8
8
|
# Creates an operator instance from a parsed ShExJ representation
|
9
9
|
# @param (see Operator#from_shexj)
|
10
10
|
# @return [Operator]
|
11
|
-
def self.from_shexj(operator, options
|
11
|
+
def self.from_shexj(operator, **options)
|
12
12
|
raise ArgumentError unless operator.is_a?(Hash) && operator['type'] == 'EachOf'
|
13
13
|
raise ArgumentError, "missing expressions in #{operator.inspect}" unless operator.has_key?('expressions')
|
14
14
|
super
|
@@ -9,7 +9,7 @@ module ShEx::Algebra
|
|
9
9
|
# Creates an operator instance from a parsed ShExJ representation
|
10
10
|
# @param (see Operator#from_shexj)
|
11
11
|
# @return [Operator]
|
12
|
-
def self.from_shexj(operator, options
|
12
|
+
def self.from_shexj(operator, **options)
|
13
13
|
raise ArgumentError unless operator.is_a?(Hash) && operator['type'] == 'NodeConstraint'
|
14
14
|
super
|
15
15
|
end
|
data/lib/shex/algebra/not.rb
CHANGED
@@ -8,7 +8,7 @@ module ShEx::Algebra
|
|
8
8
|
# Creates an operator instance from a parsed ShExJ representation
|
9
9
|
# @param (see Operator#from_shexj)
|
10
10
|
# @return [Operator]
|
11
|
-
def self.from_shexj(operator, options
|
11
|
+
def self.from_shexj(operator, **options)
|
12
12
|
raise ArgumentError unless operator.is_a?(Hash) && operator['type'] == 'ShapeNot'
|
13
13
|
raise ArgumentError, "missing shapeExpr in #{operator.inspect}" unless operator.has_key?('shapeExpr')
|
14
14
|
super
|
data/lib/shex/algebra/one_of.rb
CHANGED
@@ -8,7 +8,7 @@ module ShEx::Algebra
|
|
8
8
|
# Creates an operator instance from a parsed ShExJ representation
|
9
9
|
# @param (see Operator#from_shexj)
|
10
10
|
# @return [Operator]
|
11
|
-
def self.from_shexj(operator, options
|
11
|
+
def self.from_shexj(operator, **options)
|
12
12
|
raise ArgumentError unless operator.is_a?(Hash) && operator['type'] == 'OneOf'
|
13
13
|
raise ArgumentError, "missing expressions in #{operator.inspect}" unless operator.has_key?('expressions')
|
14
14
|
super
|
@@ -26,7 +26,7 @@ module ShEx::Algebra
|
|
26
26
|
# @overload initialize(*operands)
|
27
27
|
# @param [Array<RDF::Term>] operands
|
28
28
|
#
|
29
|
-
# @overload initialize(*operands, options)
|
29
|
+
# @overload initialize(*operands, **options)
|
30
30
|
# @param [Array<RDF::Term>] operands
|
31
31
|
# @param [Hash{Symbol => Object}] options
|
32
32
|
# any additional options
|
@@ -244,7 +244,7 @@ module ShEx::Algebra
|
|
244
244
|
# @return [String]
|
245
245
|
def to_sxp
|
246
246
|
begin
|
247
|
-
require 'sxp' # @see
|
247
|
+
require 'sxp' # @see https://rubygems.org/gems/sxp
|
248
248
|
rescue LoadError
|
249
249
|
abort "SPARQL::Algebra::Operator#to_sxp requires the SXP gem (hint: `gem install sxp')."
|
250
250
|
end
|
@@ -260,7 +260,7 @@ module ShEx::Algebra
|
|
260
260
|
# @option options [RDF::URI] :base
|
261
261
|
# @option options [Hash{String => RDF::URI}] :prefixes
|
262
262
|
# @return [Operator]
|
263
|
-
def self.from_shexj(operator, options
|
263
|
+
def self.from_shexj(operator, **options)
|
264
264
|
options[:context] ||= JSON::LD::Context.parse(ShEx::CONTEXT)
|
265
265
|
operands = []
|
266
266
|
id = nil
|
@@ -268,21 +268,21 @@ module ShEx::Algebra
|
|
268
268
|
operator.each do |k, v|
|
269
269
|
case k
|
270
270
|
when /length|clusive|digits/ then operands << [k.to_sym, RDF::Literal(v)]
|
271
|
-
when 'id' then id = iri(v, options)
|
271
|
+
when 'id' then id = iri(v, **options)
|
272
272
|
when 'flags' then ; # consumed in pattern below
|
273
273
|
when 'min', 'max' then operands << [k.to_sym, (v == -1 ? '*' : v)]
|
274
274
|
when 'inverse', 'closed' then operands << k.to_sym
|
275
275
|
when 'nodeKind' then operands << v.to_sym
|
276
|
-
when 'object' then operands << value(v, options)
|
276
|
+
when 'object' then operands << value(v, **options)
|
277
277
|
when 'languageTag' then operands << v
|
278
278
|
when 'pattern'
|
279
279
|
# Include flags as well
|
280
280
|
operands << [:pattern, RDF::Literal(v), operator['flags']].compact
|
281
281
|
when 'start'
|
282
282
|
if v.is_a?(String)
|
283
|
-
operands << Start.new(iri(v, options))
|
283
|
+
operands << Start.new(iri(v, **options))
|
284
284
|
else
|
285
|
-
operands << Start.new(ShEx::Algebra.from_shexj(v, options))
|
285
|
+
operands << Start.new(ShEx::Algebra.from_shexj(v, **options))
|
286
286
|
end
|
287
287
|
when '@context' then
|
288
288
|
options[:context] = JSON::LD::Context.parse(v)
|
@@ -290,52 +290,52 @@ module ShEx::Algebra
|
|
290
290
|
when 'shapes'
|
291
291
|
operands << case v
|
292
292
|
when Array
|
293
|
-
[:shapes] + v.map {|vv| ShEx::Algebra.from_shexj(vv, options)}
|
293
|
+
[:shapes] + v.map {|vv| ShEx::Algebra.from_shexj(vv, **options)}
|
294
294
|
else
|
295
295
|
raise "Expected value of shapes #{v.inspect}"
|
296
296
|
end
|
297
297
|
when 'stem', 'name'
|
298
298
|
# Value may be :wildcard for stem
|
299
299
|
if [IriStem, IriStemRange, SemAct].include?(self)
|
300
|
-
operands << (v.is_a?(Symbol) ? v : value(v, options))
|
300
|
+
operands << (v.is_a?(Symbol) ? v : value(v, **options))
|
301
301
|
else
|
302
302
|
operands << v
|
303
303
|
end
|
304
|
-
when 'predicate' then operands << [:predicate, iri(v, options)]
|
304
|
+
when 'predicate' then operands << [:predicate, iri(v, **options)]
|
305
305
|
when 'extra', 'datatype'
|
306
306
|
v = [v] unless v.is_a?(Array)
|
307
|
-
operands << (v.map {|op| iri(op, options)}).unshift(k.to_sym)
|
307
|
+
operands << (v.map {|op| iri(op, **options)}).unshift(k.to_sym)
|
308
308
|
when 'exclusions'
|
309
309
|
v = [v] unless v.is_a?(Array)
|
310
310
|
operands << v.map do |op|
|
311
311
|
if op.is_a?(Hash) && op.has_key?('type')
|
312
|
-
ShEx::Algebra.from_shexj(op, options)
|
312
|
+
ShEx::Algebra.from_shexj(op, **options)
|
313
313
|
elsif [IriStem, IriStemRange].include?(self)
|
314
|
-
value(op, options)
|
314
|
+
value(op, **options)
|
315
315
|
else
|
316
316
|
RDF::Literal(op)
|
317
317
|
end
|
318
318
|
end.unshift(:exclusions)
|
319
319
|
when 'semActs', 'startActs', 'annotations'
|
320
320
|
v = [v] unless v.is_a?(Array)
|
321
|
-
operands += v.map {|op| ShEx::Algebra.from_shexj(op, options)}
|
321
|
+
operands += v.map {|op| ShEx::Algebra.from_shexj(op, **options)}
|
322
322
|
when 'expression', 'expressions', 'shapeExpr', 'shapeExprs', 'valueExpr'
|
323
323
|
v = [v] unless v.is_a?(Array)
|
324
324
|
operands += v.map do |op|
|
325
325
|
# It's a URI reference to a Shape
|
326
|
-
op.is_a?(String) ? iri(op, options) : ShEx::Algebra.from_shexj(op, options)
|
326
|
+
op.is_a?(String) ? iri(op, **options) : ShEx::Algebra.from_shexj(op, **options)
|
327
327
|
end
|
328
328
|
when 'code'
|
329
329
|
operands << v
|
330
330
|
when 'values'
|
331
331
|
v = [v] unless v.is_a?(Array)
|
332
332
|
operands += v.map do |op|
|
333
|
-
Value.new(value(op, options))
|
333
|
+
Value.new(value(op, **options))
|
334
334
|
end
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
338
|
-
new(*operands, options.merge(id: id))
|
338
|
+
new(*operands, **options.merge(id: id))
|
339
339
|
end
|
340
340
|
|
341
341
|
def json_type
|
@@ -476,14 +476,14 @@ module ShEx::Algebra
|
|
476
476
|
# @option options [JSON::LD::Context] :context
|
477
477
|
# @return [RDF::Value]
|
478
478
|
def iri(value, options = @options)
|
479
|
-
self.class.iri(value, options)
|
479
|
+
self.class.iri(value, **options)
|
480
480
|
end
|
481
481
|
|
482
482
|
# Create URIs
|
483
483
|
# @param (see #iri)
|
484
484
|
# @option (see #iri)
|
485
485
|
# @return (see #iri)
|
486
|
-
def self.iri(value, options)
|
486
|
+
def self.iri(value, **options)
|
487
487
|
# If we have a base URI, use that when constructing a new URI
|
488
488
|
base_uri = options[:base_uri]
|
489
489
|
|
@@ -492,7 +492,7 @@ module ShEx::Algebra
|
|
492
492
|
# A JSON-LD node reference
|
493
493
|
v = options[:context].expand_value(value)
|
494
494
|
raise "Expected #{value.inspect} to be a JSON-LD Node Reference" unless JSON::LD::Utils.node_reference?(v)
|
495
|
-
self.iri(v['@id'], options)
|
495
|
+
self.iri(v['@id'], **options)
|
496
496
|
when RDF::URI
|
497
497
|
if base_uri && value.relative?
|
498
498
|
base_uri.join(value)
|
@@ -530,26 +530,26 @@ module ShEx::Algebra
|
|
530
530
|
# @option options [Hash{String => RDF::URI}] :prefixes
|
531
531
|
# @return [RDF::Value]
|
532
532
|
def value(value, options = @options)
|
533
|
-
self.class.value(value, options)
|
533
|
+
self.class.value(value, **options)
|
534
534
|
end
|
535
535
|
|
536
536
|
# Create Values, with "clever" matching to see if it might be a value, IRI or BNode.
|
537
537
|
# @param (see #value)
|
538
538
|
# @option (see #value)
|
539
539
|
# @return (see #value)
|
540
|
-
def self.value(value, options)
|
540
|
+
def self.value(value, **options)
|
541
541
|
# If we have a base URI, use that when constructing a new URI
|
542
542
|
case value
|
543
543
|
when Hash
|
544
544
|
# Either a value object or a node reference
|
545
545
|
if value['uri'] || value['@id']
|
546
|
-
iri(value['uri'] || value['@id'], options)
|
546
|
+
iri(value['uri'] || value['@id'], **options)
|
547
547
|
elsif value['value'] || value['@value']
|
548
548
|
RDF::Literal(value['value'] || value['@value'], datatype: value['type'] || value['@type'], language: value['language'] || value['@language'])
|
549
549
|
else
|
550
|
-
ShEx::Algebra.from_shexj(value, options)
|
550
|
+
ShEx::Algebra.from_shexj(value, **options)
|
551
551
|
end
|
552
|
-
else iri(value, options)
|
552
|
+
else iri(value, **options)
|
553
553
|
end
|
554
554
|
end
|
555
555
|
|
@@ -593,7 +593,6 @@ module ShEx::Algebra
|
|
593
593
|
|
594
594
|
##
|
595
595
|
# Enumerate via depth-first recursive descent over operands, yielding each operator
|
596
|
-
# @param [Integer] depth incrementeded for each depth of operator, and provided to block if Arity is 2
|
597
596
|
# @yield operator
|
598
597
|
# @yieldparam [Object] operator
|
599
598
|
# @return [Enumerator]
|
@@ -661,12 +660,12 @@ module ShEx::Algebra
|
|
661
660
|
self
|
662
661
|
end
|
663
662
|
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
end
|
663
|
+
def dup
|
664
|
+
operands = @operands.map {|o| o.dup rescue o}
|
665
|
+
self.class.new(*operands, id: @id)
|
666
|
+
end
|
669
667
|
|
668
|
+
protected
|
670
669
|
##
|
671
670
|
# A unary operator.
|
672
671
|
#
|
@@ -681,7 +680,7 @@ module ShEx::Algebra
|
|
681
680
|
# the first operand
|
682
681
|
# @param [Hash{Symbol => Object}] options
|
683
682
|
# any additional options (see {Operator#initialize})
|
684
|
-
def initialize(arg1, options
|
683
|
+
def initialize(arg1, **options)
|
685
684
|
raise ArgumentError, "wrong number of arguments (given 2, expected 1)" unless options.is_a?(Hash)
|
686
685
|
super
|
687
686
|
end
|
@@ -703,7 +702,7 @@ module ShEx::Algebra
|
|
703
702
|
# the second operand
|
704
703
|
# @param [Hash{Symbol => Object}] options
|
705
704
|
# any additional options (see {Operator#initialize})
|
706
|
-
def initialize(arg1, arg2, options
|
705
|
+
def initialize(arg1, arg2, **options)
|
707
706
|
raise ArgumentError, "wrong number of arguments (given 3, expected 2)" unless options.is_a?(Hash)
|
708
707
|
super
|
709
708
|
end
|