shex 0.5.1 → 0.6.2

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
- SHA1:
3
- metadata.gz: 51c304bc780f271fc54404ac8becb3553504e17f
4
- data.tar.gz: 15d2a5d06d9830be1071ec8fa8a98b64806e2459
2
+ SHA256:
3
+ metadata.gz: 0d91d9cf7282456c7a61fba4c17609eda22851232c5bfe7be75518c0bb1ea354
4
+ data.tar.gz: b465b287f74cd1efaa8788ad80a9a0e4ee78e89d6a8ea061445de526f8b78edf
5
5
  SHA512:
6
- metadata.gz: 41c3c2aff0ba9f453d72c1a7a940de48f4826d0657f6e6cafeb4c5154e98ff45ce7c1ea6b26bc8a3d8a86f65d49449a42415217b4238724b4c08a33ddfb4c778
7
- data.tar.gz: 3efdbda75cf115e4babeec86838d49790a89673109f0c19ae2d00527b1bb048a3dbc51fd1114445cd9669efecd91ece885c32571e2fe13351686630b30e58566
6
+ metadata.gz: 695c099ae0fb5899086f50296293610c3f6f1a82a361ed5da953fd1495cc38a538a26048fcdf8b329a6313e7e81abd1e102883523ad12c3b5e360cdcee0686df
7
+ data.tar.gz: 7dd2fe93e6cf93b1afca58d09d79ea318d71314759e0b790b524fe58fdee7bd5954d2950ea67cee69b1953b25bc612d54a9a6bcb0b7ef74c0061555f61f68700
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,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
- <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)
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](http://unlicense.org/) software.
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](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](https://en.wikipedia.org/wiki/S-expression).
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
- "http://rubygems.org/gems/shex" => "TestShape"
46
+ "https://rubygems.org/gems/shex" => "TestShape"
48
47
  }
49
- schema.satisfies?("http://rubygems.org/gems/shex", graph, map)
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 = {"http://rubygems.org/gems/shex" => "TestShape"}
142
- schema.satisfies?("http://rubygems.org/gems/shex", graph, map)
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,11 +175,11 @@ 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 http://rubygems.org/gems/shex
178
+ --focus https://rubygems.org/gems/shex
180
179
 
181
180
  ## Documentation
182
181
 
183
- <http://rubydoc.info/github/ruby-rdf/shex>
182
+ <https://rubydoc.info/github/ruby-rdf/shex>
184
183
 
185
184
 
186
185
  ## Implementation Notes
@@ -192,12 +191,13 @@ The result of parsing either ShExC or ShExJ is the creation of a set of executab
192
191
 
193
192
  ## Dependencies
194
193
 
195
- * [Ruby](http://ruby-lang.org/) (>= 2.2.2)
196
- * [RDF.rb](http://rubygems.org/gems/rdf) (~> 2.2)
194
+ * [Ruby](https://ruby-lang.org/) (>= 2.4)
195
+ * [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1)
196
+ * [SPARQL gem](https://rubygems.org/gems/sparql) (~> 3.1)
197
197
 
198
198
  ## Installation
199
199
 
200
- The recommended installation method is via [RubyGems](http://rubygems.org/).
200
+ The recommended installation method is via [RubyGems](https://rubygems.org/).
201
201
  To install the latest official release of RDF.rb, do:
202
202
 
203
203
  % [sudo] gem install shex
@@ -211,21 +211,21 @@ To get a local working copy of the development repository, do:
211
211
  Alternatively, download the latest development version as a tarball as
212
212
  follows:
213
213
 
214
- % wget http://github.com/ruby-rdf/shex/tarball/master
214
+ % wget https://github.com/ruby-rdf/shex/tarball/master
215
215
 
216
216
  ## Resources
217
217
 
218
- * <http://rubydoc.info/github/ruby-rdf/shex>
219
- * <http://github.com/ruby-rdf/shex>
220
- * <http://rubygems.org/gems/shex>
218
+ * <https://rubydoc.info/github/ruby-rdf/shex>
219
+ * <https://github.com/ruby-rdf/shex>
220
+ * <https://rubygems.org/gems/shex>
221
221
 
222
222
  ## Mailing List
223
223
 
224
- * <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
224
+ * <https://lists.w3.org/Archives/Public/public-rdf-ruby/>
225
225
 
226
226
  ## Author
227
227
 
228
- * [Gregg Kellogg](http://github.com/gkellogg) - <http://greggkellogg.net/>
228
+ * [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>
229
229
 
230
230
  ## Contributing
231
231
 
@@ -244,14 +244,19 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
244
244
  enough, be assured we will eventually add you in there.
245
245
  * Do note that in order for us to merge any non-trivial changes (as a rule
246
246
  of thumb, additions larger than about 15 lines of code), we need an
247
- explicit [public domain dedication][PDD] on record from you.
247
+ explicit [public domain dedication][PDD] on record from you,
248
+ which you will be asked to agree to on the first commit to a repo within the organization.
249
+ Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.
248
250
 
249
251
  ## License
250
252
 
251
253
  This is free and unencumbered public domain software. For more information,
252
- see <http://unlicense.org/> or the accompanying {file:LICENSE} file.
253
-
254
- [ShExSpec]: http://shex.io/shex-semantics/
255
- [RDF]: http://www.w3.org/RDF/
256
- [RDF.rb]: http://rubydoc.info/github/ruby-rdf/rdf
257
- [EBNF]: http://rubygems.org/gems/ebnf
254
+ see <https://unlicense.org/> or the accompanying {file:LICENSE} file.
255
+
256
+ [ShExSpec]: http://shex.io/shex-semantics-20170713/
257
+ [RDF]: https://www.w3.org/RDF/
258
+ [RDF.rb]: https://rubydoc.info/github/ruby-rdf/rdf
259
+ [EBNF]: https://rubygems.org/gems/ebnf
260
+ [YARD]: https://yardoc.org/
261
+ [YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
262
+ [PDD]: https://unlicense.org/#unlicensing-contributions
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.6.2
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> .
data/lib/shex.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  # A ShEx runtime for RDF.rb.
3
3
  #
4
- # @see http://shex.io/shex-semantics/#shexc
4
+ # @see https://shex.io/shex-semantics/#shexc
5
5
  module ShEx
6
6
  require 'shex/format'
7
7
  autoload :Algebra, 'shex/algebra'
@@ -33,13 +33,13 @@ module ShEx
33
33
  # @raise (see ShEx::Parser#parse)
34
34
  def self.parse(expression, format: 'shexc', **options)
35
35
  case format.to_s
36
- when 'shexc' then Parser.new(expression, options).parse
36
+ when 'shexc' then Parser.new(expression, **options).parse
37
37
  when 'shexj'
38
38
  expression = expression.read if expression.respond_to?(:read)
39
- Algebra.from_shexj(JSON.parse(expression), options)
39
+ Algebra.from_shexj(JSON.parse(expression), **options)
40
40
  when 'sxp'
41
41
  expression = expression.read if expression.respond_to?(:read)
42
- Algebra.from_sxp(expression, options)
42
+ Algebra.from_sxp(expression, **options)
43
43
  else raise "Unknown expression format: #{format.inspect}"
44
44
  end
45
45
  end
@@ -56,8 +56,8 @@ module ShEx
56
56
  # @return (see ShEx::Parser#parse)
57
57
  # @raise (see ShEx::Parser#parse)
58
58
  def self.open(filename, format: 'shexc', **options, &block)
59
- RDF::Util::File.open_file(filename, options) do |file|
60
- self.parse(file, options.merge(format: format))
59
+ RDF::Util::File.open_file(filename, **options) do |file|
60
+ self.parse(file, format: format, **options)
61
61
  end
62
62
  end
63
63
 
@@ -66,17 +66,17 @@ module ShEx
66
66
  #
67
67
  # @example executing a ShExC schema
68
68
  # graph = RDF::Graph.load("etc/doap.ttl")
69
- # ShEx.execute('etc/doap.shex', graph, "http://rubygems.org/gems/shex", "")
69
+ # ShEx.execute('etc/doap.shex', graph, "https://rubygems.org/gems/shex", "")
70
70
  #
71
71
  # @param [IO, StringIO, String, #to_s] expression (ShExC or ShExJ)
72
72
  # @param (see ShEx::Algebra::Schema#execute)
73
73
  # @return (see ShEx::Algebra::Schema#execute)
74
74
  # @raise (see ShEx::Algebra::Schema#execute)
75
75
  def self.execute(expression, queryable, map, format: 'shexc', **options)
76
- shex = self.parse(expression, options.merge(format: format))
76
+ shex = self.parse(expression, format: format, **options)
77
77
  queryable = queryable || RDF::Graph.new
78
78
 
79
- shex.execute(queryable, map, options)
79
+ shex.execute(queryable, map, **options)
80
80
  end
81
81
 
82
82
  ##
@@ -84,17 +84,17 @@ module ShEx
84
84
  #
85
85
  # @example executing a ShExC schema
86
86
  # graph = RDF::Graph.load("etc/doap.ttl")
87
- # ShEx.execute('etc/doap.shex', graph, "http://rubygems.org/gems/shex", "")
87
+ # ShEx.execute('etc/doap.shex', graph, "https://rubygems.org/gems/shex", "")
88
88
  #
89
89
  # @param [IO, StringIO, String, #to_s] expression (ShExC or ShExJ)
90
90
  # @param (see ShEx::Algebra::Schema#satisfies?)
91
91
  # @return (see ShEx::Algebra::Schema#satisfies?)
92
92
  # @raise (see ShEx::Algebra::Schema#satisfies?)
93
93
  def self.satisfies?(expression, queryable, map, format: 'shexc', **options)
94
- shex = self.parse(expression, options.merge(format: format))
94
+ shex = self.parse(expression, format: format, **options)
95
95
  queryable = queryable || RDF::Graph.new
96
96
 
97
- shex.satisfies?(queryable, map, options)
97
+ shex.satisfies?(queryable, map, **options)
98
98
  end
99
99
 
100
100
  ##
@@ -116,7 +116,7 @@ module ShEx
116
116
  # @param [String, #to_s] message
117
117
  # @param [Hash{Symbol => Object}] options
118
118
  # @option options [Integer] :code (422)
119
- def initialize(message, options = {})
119
+ def initialize(message, **options)
120
120
  @code = options.fetch(:status_code, 422)
121
121
  super(message.to_s)
122
122
  end
data/lib/shex/algebra.rb CHANGED
@@ -5,7 +5,7 @@ require 'sxp'
5
5
  module ShEx
6
6
  # Based on the SPARQL Algebra, operators for executing a patch
7
7
  #
8
- # @author [Gregg Kellogg](http://greggkellogg.net/)
8
+ # @author [Gregg Kellogg](https://greggkellogg.net/)
9
9
  module Algebra
10
10
  autoload :And, 'shex/algebra/and'
11
11
  autoload :Annotation, 'shex/algebra/annotation'
@@ -50,7 +50,7 @@ module ShEx
50
50
  # @option options [RDF::URI] :base
51
51
  # @option options [Hash{String => RDF::URI}] :prefixes
52
52
  # @return [Operator]
53
- def self.from_shexj(operator, options = {})
53
+ def self.from_shexj(operator, **options)
54
54
  raise ArgumentError unless operator.is_a?(Hash)
55
55
  klass = case operator['type']
56
56
  when 'Annotation' then Annotation
@@ -76,7 +76,7 @@ module ShEx
76
76
  else raise ArgumentError, "unknown type #{operator['type'].inspect}"
77
77
  end
78
78
 
79
- klass.from_shexj(operator, options)
79
+ klass.from_shexj(operator, **options)
80
80
  end
81
81
  end
82
82
  end
@@ -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')
@@ -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
@@ -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
@@ -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 http://rubygems.org/gems/sxp
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
- protected
665
- def dup
666
- operands = @operands.map {|o| o.dup rescue o}
667
- self.class.new(*operands, id: @id)
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
@@ -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'] == 'ShapeOr'
24
24
  raise ArgumentError, "missing shapeExprs in #{operator.inspect}" unless operator.is_a?(Hash) && operator.has_key?('shapeExprs')
25
25
  super
@@ -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'] == "Schema"
24
24
  super
25
25
  end
@@ -39,7 +39,7 @@ module ShEx::Algebra
39
39
  # @param [RDF::Queryable] graph
40
40
  # @param [Hash{RDF::Term => <RDF::Resource>}, Array<Array(RDF::Term, RDF::Resource)>] map
41
41
  # A set of (`term`, `resource`) pairs where `term` is a node within `graph`, and `resource` identifies a shape
42
- # @param [Array<RDF::Term>] *focus
42
+ # @param [Array<RDF::Term>] focus ([])
43
43
  # One or more nodes within `graph` for which to run the start expression.
44
44
  # @param [Array<Schema, String>] shapeExterns ([])
45
45
  # One or more schemas, or paths to ShEx schema resources used for finding external shapes.
@@ -51,7 +51,7 @@ module ShEx::Algebra
51
51
  @graph, @shapes_entered, results = graph, {}, {}
52
52
  @external_schemas = shapeExterns
53
53
  @extensions = {}
54
- focus = Array(focus).map {|f| value(f, options)}
54
+ focus = Array(focus).map {|f| value(f, **options)}
55
55
 
56
56
  logger = options[:logger] || @options[:logger]
57
57
  each_descendant do |op|
@@ -250,7 +250,7 @@ module ShEx::Algebra
250
250
  attr_accessor :expression
251
251
 
252
252
  # Holds the result of processing a shape
253
- # @param [RDF::Resource] label
253
+ # @param [RDF::Resource] shape
254
254
  # @return [ShapeResult]
255
255
  def initialize(shape)
256
256
  @shape = shape
@@ -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'] == "SemAct"
12
12
  raise ArgumentError, "missing name in #{operator.inspect}" unless operator.has_key?('name')
13
13
  code = operator.delete('code')
@@ -18,13 +18,14 @@ module ShEx::Algebra
18
18
  ##
19
19
  # Called on entry
20
20
  #
21
- # @param [String] code
22
- # @param [Array<RDF::Statement>] arcs_in available statements to be matched having `focus` as an object
23
- # @param [Array<RDF::Statement>] arcs_out available statements to be matched having `focus` as a subject
24
- # @param [Integer] depth for logging
25
- # @param [Hash{Symbol => Object}] options
26
- # Other, operand-specific options
27
- # @return [Boolean] Returning `false` results in {ShEx::NotSatisfied} exception
21
+ # @overload enter(code, arcs_in, arcs_out, logging)
22
+ # @param [String] code
23
+ # @param [Array<RDF::Statement>] arcs_in available statements to be matched having `focus` as an object
24
+ # @param [Array<RDF::Statement>] arcs_out available statements to be matched having `focus` as a subject
25
+ # @param [Integer] depth for logging
26
+ # @param [Hash{Symbol => Object}] options
27
+ # Other, operand-specific options
28
+ # @return [Boolean] Returning `false` results in {ShEx::NotSatisfied} exception
28
29
  def enter(**options)
29
30
  if implementation = schema.extensions[operands.first.to_s]
30
31
  implementation.enter(code: operands[0], expression: parent, **options)
@@ -67,7 +68,6 @@ module ShEx::Algebra
67
68
  # @param [String] code
68
69
  # @param [Array<RDF::Statement>] matched statements matched by this expression
69
70
  # @param [Array<RDF::Statement>] unmatched statements considered, but not matched by this expression
70
- # @param [ShEx::Algebra::TripleExpression] expression containing this semantic act
71
71
  # @param [Integer] depth for logging
72
72
  # @param [Hash{Symbol => Object}] options
73
73
  # Other, operand-specific options
@@ -23,7 +23,7 @@ module ShEx::Algebra
23
23
  # Creates an operator instance from a parsed ShExJ representation
24
24
  # @param (see Operator#from_shexj)
25
25
  # @return [Operator]
26
- def self.from_shexj(operator, options = {})
26
+ def self.from_shexj(operator, **options)
27
27
  raise ArgumentError unless operator.is_a?(Hash) && operator['type'] == "Shape"
28
28
  super
29
29
  end
@@ -36,8 +36,8 @@ module ShEx::Algebra
36
36
  # neigh(G, n) is the neighbourhood of the node n in the graph G.
37
37
  #
38
38
  # neigh(G, n) = arcsOut(G, n) ∪ arcsIn(G, n)
39
- arcs_in = schema.graph.query(object: focus).to_a.sort_by(&:to_sxp)
40
- arcs_out = schema.graph.query(subject: focus).to_a.sort_by(&:to_sxp)
39
+ arcs_in = schema.graph.query({object: focus}).to_a.sort_by(&:to_sxp)
40
+ arcs_out = schema.graph.query({subject: focus}).to_a.sort_by(&:to_sxp)
41
41
  neigh = (arcs_in + arcs_out).uniq
42
42
 
43
43
  # `matched` is the subset of statements which match `expression`.
@@ -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) && %w(IriStem LiteralStem LanguageStem).include?(operator['type'])
12
12
  raise ArgumentError, "missing stem in #{operator.inspect}" unless operator.has_key?('stem')
13
13
  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) && %w(IriStemRange LiteralStemRange LanguageStemRange).include?(operator['type'])
12
12
  raise ArgumentError, "missing stem in #{operator.inspect}" unless operator.has_key?('stem')
13
13
 
@@ -21,11 +21,11 @@ module ShEx::Algebra
21
21
  # Remove "Range" from type
22
22
  case operator['type']
23
23
  when 'IriStemRange'
24
- IriStem.from_shexj(operator.merge('type' => 'IriStem'), options)
24
+ IriStem.from_shexj(operator.merge('type' => 'IriStem'), **options)
25
25
  when 'LiteralStemRange'
26
- LiteralStem.from_shexj(operator.merge('type' => 'LiteralStem'), options)
26
+ LiteralStem.from_shexj(operator.merge('type' => 'LiteralStem'), **options)
27
27
  when 'LanguageStemRange'
28
- LanguageStem.from_shexj(operator.merge('type' => 'LanguageStem'), options)
28
+ LanguageStem.from_shexj(operator.merge('type' => 'LanguageStem'), **options)
29
29
  end
30
30
  end
31
31
  end
@@ -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'] == 'TripleConstraint'
13
13
  raise ArgumentError unless operator.has_key?('predicate')
14
14
  super
@@ -6,21 +6,23 @@
6
6
  # @see http://shex.io/extensions/Test/
7
7
  require 'shex'
8
8
 
9
- class ShEx::Test < ShEx::Extension("http://shex.io/extensions/Test/")
10
- # (see ShEx::Extension#visit)
11
- def visit(code: nil, matched: nil, depth: 0, **options)
12
- str = if md = /^ *(fail|print) *\( *(?:(\"(?:[^\\"]|\\")*\")|([spo])) *\) *$/.match(code.to_s)
13
- md[2] || case md[3]
14
- when 's' then matched.subject
15
- when 'p' then matched.predicate
16
- when 'o' then matched.object
17
- else matched.to_sxp
18
- end.to_s
19
- else
20
- matched ? matched.to_sxp : 'no statement'
21
- end
9
+ module ShEx
10
+ Test = Class.new(ShEx::Extension("http://shex.io/extensions/Test/")) do
11
+ # (see ShEx::Extension#visit)
12
+ def visit(code: nil, matched: nil, depth: 0, **options)
13
+ str = if md = /^ *(fail|print) *\( *(?:(\"(?:[^\\"]|\\")*\")|([spo])) *\) *$/.match(code.to_s)
14
+ md[2] || case md[3]
15
+ when 's' then matched.subject
16
+ when 'p' then matched.predicate
17
+ when 'o' then matched.object
18
+ else matched.to_sxp
19
+ end.to_s
20
+ else
21
+ matched ? matched.to_sxp : 'no statement'
22
+ end
22
23
 
23
- $stdout.puts str
24
- return !md || md[1] == 'print'
24
+ $stdout.puts str
25
+ return !md || md[1] == 'print'
26
+ end
25
27
  end
26
- end
28
+ end
data/lib/shex/format.rb CHANGED
@@ -4,14 +4,12 @@ module ShEx
4
4
  ##
5
5
  # ShEx format specification. Note that this format does not define any readers or writers.
6
6
  #
7
- # @example Obtaining an LD Patch format class
8
- # RDF::Format.for(:shex) #=> LD::Patch::Format
7
+ # @example Obtaining an ShEx format class
8
+ # RDF::Format.for(:shex) #=> ShEx::Format
9
9
  # RDF::Format.for("etc/foaf.shex")
10
10
  # RDF::Format.for(file_name: "etc/foaf.shex")
11
11
  # RDF::Format.for(file_extension: "shex")
12
12
  # RDF::Format.for(content_type: "application/shex")
13
- #
14
- # @see http://www.w3.org/TR/ldpatch/
15
13
  class Format < RDF::Format
16
14
  content_type 'application/shex', extension: :shex
17
15
  content_encoding 'utf-8'
@@ -25,7 +23,7 @@ module ShEx
25
23
  description: "Validate repository given shape",
26
24
  help: "shex [--shape Resource] [--focus Resource] [--schema-input STRING] [--schema STRING] file",
27
25
  parse: true,
28
- lambda: -> (argv, options) do
26
+ lambda: -> (argv, **options) do
29
27
  options[:schema_input] ||= case options[:schema]
30
28
  when IO, StringIO then options[:schema]
31
29
  else RDF::Util::File.open_file(options[:schema]) {|f| f.read}
@@ -44,7 +42,7 @@ module ShEx
44
42
  shape = options.delete(:shape)
45
43
  map = shape ? {focus => shape} : {}
46
44
  begin
47
- res = shex.execute(RDF::CLI.repository, map, options.merge(focus: focus))
45
+ res = shex.execute(RDF::CLI.repository, map, focus: focus, **options)
48
46
  options[:messages][:shex] = {
49
47
  result: ["Satisfied shape."],
50
48
  detail: [SXP::Generator.string(res.to_sxp_bin)]
data/lib/shex/parser.rb CHANGED
@@ -8,7 +8,7 @@ module ShEx
8
8
  # A parser for the ShEx grammar.
9
9
  #
10
10
  # @see https://www.w3.org/2005/01/yacker/uploads/ShEx3?lang=perl&markup=html#productions
11
- # @see http://en.wikipedia.org/wiki/LR_parser
11
+ # @see https://en.wikipedia.org/wiki/LR_parser
12
12
  class Parser
13
13
  include ShEx::Meta
14
14
  include ShEx::Terminals
@@ -37,7 +37,7 @@ module ShEx
37
37
  # The internal representation of the result using hierarchy of RDF objects and ShEx::Operator
38
38
  # objects.
39
39
  # @return [Array]
40
- # @see http://sparql.rubyforge.org/algebra
40
+ # @see https://www.rubydoc.info/github/ruby-rdf/sparql/SPARQL/Algebra
41
41
  attr_accessor :result
42
42
 
43
43
  # Terminals passed to lexer. Order matters!
@@ -178,7 +178,7 @@ module ShEx
178
178
  expressions << Algebra::Start.new(data[:start]) if data[:start]
179
179
  expressions << data[:shapes].unshift(:shapes) if data[:shapes]
180
180
 
181
- input[:schema] = Algebra::Schema.new(*expressions, options)
181
+ input[:schema] = Algebra::Schema.new(*expressions, **options)
182
182
  self
183
183
  end
184
184
 
@@ -256,7 +256,7 @@ module ShEx
256
256
  def shape_or(input, data)
257
257
  input.merge!(data.dup.keep_if {|k, v| [:closed, :extraPropertySet, :codeDecl].include?(k)})
258
258
  expression = if Array(data[:shapeExpression]).length > 1
259
- Algebra::Or.new(*data[:shapeExpression], {})
259
+ Algebra::Or.new(*data[:shapeExpression])
260
260
  else
261
261
  Array(data[:shapeExpression]).first
262
262
  end
@@ -282,7 +282,7 @@ module ShEx
282
282
  end
283
283
 
284
284
  expression = if expressions.length > 1
285
- Algebra::And.new(*expressions, {})
285
+ Algebra::And.new(*expressions)
286
286
  else
287
287
  expressions.first
288
288
  end
@@ -341,7 +341,7 @@ module ShEx
341
341
  expression = case expression.length
342
342
  when 0 then nil
343
343
  when 1 then expression.first
344
- else Algebra::And.new(*expression, {})
344
+ else Algebra::And.new(*expression)
345
345
  end
346
346
 
347
347
  (input[:shapeExpression] ||= []) << expression if expression
@@ -389,7 +389,7 @@ module ShEx
389
389
  attrs += Array(data[:numericFacet])
390
390
  attrs += Array(data[:stringFacet])
391
391
 
392
- input[:nodeConstraint] = Algebra::NodeConstraint.new(*attrs.compact, {})
392
+ input[:nodeConstraint] = Algebra::NodeConstraint.new(*attrs.compact)
393
393
  end
394
394
 
395
395
  # [25] nonLitNodeConstraint ::= nonLiteralKind stringFacet*
@@ -401,7 +401,7 @@ module ShEx
401
401
  attrs += Array(data[:nonLiteralKind])
402
402
  attrs += Array(data[:stringFacet])
403
403
 
404
- input[:nodeConstraint] = Algebra::NodeConstraint.new(*attrs.compact, {})
404
+ input[:nodeConstraint] = Algebra::NodeConstraint.new(*attrs.compact)
405
405
  end
406
406
 
407
407
  # [26] nonLiteralKind ::= "IRI" | "BNODE" | "NONLITERAL"
@@ -469,7 +469,7 @@ module ShEx
469
469
  attrs += Array(data[:annotation])
470
470
  attrs += Array(data[:codeDecl])
471
471
 
472
- input[:shape] = Algebra::Shape.new(*attrs, {})
472
+ input[:shape] = Algebra::Shape.new(*attrs)
473
473
  end
474
474
  private :shape_definition
475
475
 
@@ -482,7 +482,7 @@ module ShEx
482
482
  # [37] oneOfTripleExpr ::= groupTripleExpr ('|' groupTripleExpr)*
483
483
  production(:oneOfTripleExpr) do |input, data, callback|
484
484
  expression = if Array(data[:tripleExpression]).length > 1
485
- Algebra::OneOf.new(*data[:tripleExpression], {})
485
+ Algebra::OneOf.new(*data[:tripleExpression])
486
486
  else
487
487
  Array(data[:tripleExpression]).first
488
488
  end
@@ -492,7 +492,7 @@ module ShEx
492
492
  # [40] groupTripleExpr ::= unaryTripleExpr (';' unaryTripleExpr?)*
493
493
  production(:groupTripleExpr) do |input, data, callback|
494
494
  expression = if Array(data[:tripleExpression]).length > 1
495
- Algebra::EachOf.new(*data[:tripleExpression], {})
495
+ Algebra::EachOf.new(*data[:tripleExpression])
496
496
  else
497
497
  Array(data[:tripleExpression]).first
498
498
  end
@@ -545,7 +545,7 @@ module ShEx
545
545
  attrs += Array(data[:codeDecl])
546
546
  attrs += Array(data[:annotation])
547
547
 
548
- input[:tripleExpression] = Algebra::TripleConstraint.new(*attrs, {}) unless attrs.empty?
548
+ input[:tripleExpression] = Algebra::TripleConstraint.new(*attrs) unless attrs.empty?
549
549
  end
550
550
 
551
551
  # [46] cardinality ::= '*' | '+' | '?' | REPEAT_RANGE
@@ -666,7 +666,7 @@ module ShEx
666
666
 
667
667
  # [60] codeDecl ::= '%' iri (CODE | "%")
668
668
  production(:codeDecl) do |input, data, callback|
669
- (input[:codeDecl] ||= []) << Algebra::SemAct.new(*[data[:iri], data[:code]].compact, {})
669
+ (input[:codeDecl] ||= []) << Algebra::SemAct.new(*[data[:iri], data[:code]].compact)
670
670
  end
671
671
 
672
672
  # [13t] literal ::= rdfLiteral | numericLiteral | booleanLiteral
@@ -730,7 +730,7 @@ module ShEx
730
730
  # @raise [ShEx::NotSatisfied] if not satisfied
731
731
  # @raise [ShEx::ParseError] when a syntax error is detected
732
732
  # @raise [ShEx::StructureError, ArgumentError] on structural problems with schema
733
- def initialize(input = nil, options = {}, &block)
733
+ def initialize(input = nil, **options, &block)
734
734
  @input = case input
735
735
  when IO, StringIO then input.read
736
736
  else input.to_s.dup
@@ -775,13 +775,16 @@ module ShEx
775
775
  # @return [ShEx::Algebra::Schema] The executable parsed expression.
776
776
  # @raise [ShEx::ParseError] when a syntax error is detected
777
777
  # @raise [ShEx::StructureError, ArgumentError] on structural problems with schema
778
- # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
779
- # @see http://axel.deri.ie/sparqltutorial/ESWC2007_SPARQL_Tutorial_unit2b.pdf
778
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
779
+ # @see https://axel.deri.ie/sparqltutorial/ESWC2007_SPARQL_Tutorial_unit2b.pdf
780
780
  def parse(prod = START)
781
- ll1_parse(@input, prod.to_sym, @options.merge(branch: BRANCH,
782
- first: FIRST,
783
- follow: FOLLOW,
784
- whitespace: WS)
781
+ ll1_parse(@input,
782
+ prod.to_sym,
783
+ branch: BRANCH,
784
+ first: FIRST,
785
+ follow: FOLLOW,
786
+ whitespace: WS,
787
+ **@options
785
788
  ) do |context, *data|
786
789
  case context
787
790
  when :trace
@@ -929,7 +932,7 @@ module ShEx
929
932
  end
930
933
 
931
934
  # Create a literal
932
- def literal(value, options = {})
935
+ def literal(value, **options)
933
936
  options = options.dup
934
937
  # Internal representation is to not use xsd:string, although it could arguably go the other way.
935
938
  options.delete(:datatype) if options[:datatype] == RDF::XSD.string
@@ -938,7 +941,7 @@ module ShEx
938
941
  "options: #{options.inspect}, " +
939
942
  "validate: #{validate?.inspect}, "
940
943
  end
941
- RDF::Literal.new(value, options.merge(validate: validate?))
944
+ RDF::Literal.new(value, **options.merge(validate: validate?))
942
945
  end
943
946
  end # class Parser
944
947
  end # module ShEx
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-27 00:00:00.000000000 Z
11
+ date: 2021-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -16,154 +16,154 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.2'
19
+ version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.2'
26
+ version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json-ld
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.1'
33
+ version: '3.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.1'
40
+ version: '3.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json-ld-preloaded
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.1'
47
+ version: '3.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.1'
54
+ version: '3.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: ebnf
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.1'
61
+ version: '2.1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.1'
68
+ version: '2.1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sxp
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.0'
75
+ version: '1.1'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.0'
82
+ version: '1.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rdf-xsd
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '2.2'
89
+ version: '3.1'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '2.2'
96
+ version: '3.1'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: sparql
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '2.2'
103
+ version: '3.1'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '2.2'
110
+ version: '3.1'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rdf-spec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '2.2'
117
+ version: '3.1'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '2.2'
124
+ version: '3.1'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rdf-turtle
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '2.2'
131
+ version: '3.1'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '2.2'
138
+ version: '3.1'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rspec
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '3.6'
145
+ version: '3.10'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '3.6'
152
+ version: '3.10'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rspec-its
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '1.2'
159
+ version: '1.3'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '1.2'
166
+ version: '1.3'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: yard
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -220,12 +220,12 @@ files:
220
220
  - lib/shex/shex_context.rb
221
221
  - lib/shex/terminals.rb
222
222
  - lib/shex/version.rb
223
- homepage: http://ruby-rdf.github.com/shex
223
+ homepage: https://ruby-rdf.github.com/shex
224
224
  licenses:
225
225
  - Unlicense
226
226
  metadata:
227
227
  yard.run: yri
228
- post_install_message:
228
+ post_install_message:
229
229
  rdoc_options: []
230
230
  require_paths:
231
231
  - lib
@@ -233,16 +233,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - ">="
235
235
  - !ruby/object:Gem::Version
236
- version: 2.2.2
236
+ version: '2.4'
237
237
  required_rubygems_version: !ruby/object:Gem::Requirement
238
238
  requirements:
239
239
  - - ">="
240
240
  - !ruby/object:Gem::Version
241
241
  version: '0'
242
242
  requirements: []
243
- rubyforge_project: rdf
244
- rubygems_version: 2.6.12
245
- signing_key:
243
+ rubygems_version: 3.2.15
244
+ signing_key:
246
245
  specification_version: 4
247
246
  summary: Implementation of Shape Expressions (ShEx) for RDF.rb
248
247
  test_files: []