sparql 3.1.4 → 3.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ddc77cee587255c81cfcb3cd9d05759a3c98398821e23a25c3111f71e9b44c9
4
- data.tar.gz: 48290eb8ba7ab1539c73c2fc3477b4004b8a15c5f09624ef24de5e3fe692ab03
3
+ metadata.gz: 27f805f342a0db67d53df5b59f045adbf206e846cf4100b3918e9fb7933413d0
4
+ data.tar.gz: 3afbfd95de7fb479e8d06c20a758d636ff23e699db48ed25e5906497bc2e254b
5
5
  SHA512:
6
- metadata.gz: 71b0e62c9d8d418e508befea92ca5723a24a0ccce9fcebf43f40ce7ee4a8299c81fdad5ae4302465defd04708abd04ef10c863ef1538f25c71c5a24ea45e826a
7
- data.tar.gz: 6c1b568ed72dcdda4f68f613bcbf3de38512b8cde4b1c6b2a20d51370fb5bd4efce7dee766e3cfde64222853c52937890d5fcbeb48d4448a2694f0dce0729d0c
6
+ metadata.gz: 12ce7f125ff98950f7fdd9e63e42645fc9bd23e79146971526e78413f254d979a1e202ac90cca1f83b8721ca43f7c6e8e88bf6029a5138bc8337ad2c2a85de72
7
+ data.tar.gz: 1b8bb78258345466d763a3fdfbc19b40cc759a6c2a7b8189cccd6e7cecbbbcbb2cdb1fc04869063bcdbc33ecd532292b3d4e25bc426256c63f1e804044aa8cbb
data/README.md CHANGED
@@ -4,7 +4,7 @@ This is a [Ruby][] implementation of [SPARQL][] for [RDF.rb][].
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/sparql.png)](https://badge.fury.io/rb/sparql)
6
6
  [![Build Status](https://github.com/ruby-rdf/sparql/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/sparql/actions?query=workflow%3ACI)
7
- [![Coverage Status](https://coveralls.io/repos/ruby-rdf/sparql/badge.svg)](https://coveralls.io/r/ruby-rdf/sparql)
7
+ [![Coverage Status](https://coveralls.io/repos/ruby-rdf/sparql/badge.svg?branch=develop)](https://coveralls.io/r/ruby-rdf/sparql?branch=develop)
8
8
  [![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf)
9
9
 
10
10
  ## Features
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.4
1
+ 3.1.5
@@ -53,7 +53,7 @@ module SPARQL; module Algebra
53
53
  def self.open(filename, **options, &block)
54
54
  RDF::Util::File.open_file(filename, **options) do |file|
55
55
  options[:base_uri] ||= filename
56
- Expression.parse(file, options, &block)
56
+ Expression.parse(file, **options, &block)
57
57
  end
58
58
  end
59
59
 
@@ -114,8 +114,11 @@ module SPARQL; module Algebra
114
114
 
115
115
  debug(options) {"#{operator.inspect}(#{operands.map(&:inspect).join(',')})"}
116
116
  options.delete_if {|k, v| [:debug, :logger, :depth, :prefixes, :base_uri, :update, :validate].include?(k) }
117
- operands << options unless options.empty?
118
- operator.new(*operands)
117
+ begin
118
+ operator.new(*operands, **options)
119
+ rescue ArgumentError => e
120
+ error(options) {"Operator=#{operator.inspect}: #{e}"}
121
+ end
119
122
  end
120
123
 
121
124
  ##
@@ -332,7 +335,7 @@ module SPARQL; module Algebra
332
335
  # @param [Hash{Symbol => Object}] options ({})
333
336
  # options passed from query
334
337
  # @return [Expression] `self`
335
- def evaluate(bindings, options = {})
338
+ def evaluate(bindings, **options)
336
339
  self
337
340
  end
338
341
 
@@ -320,7 +320,7 @@ module RDF::Queryable
320
320
  # @yieldreturn [void] ignored
321
321
  # @return [Enumerator]
322
322
  # @see RDF::Queryable#query_pattern
323
- def query(pattern, options = {}, &block)
323
+ def query(pattern, **options, &block)
324
324
  raise TypeError, "#{self} is not queryable" if respond_to?(:queryable?) && !queryable?
325
325
 
326
326
  if pattern.is_a?(SPARQL::Algebra::Operator) && pattern.respond_to?(:execute)
@@ -336,8 +336,8 @@ module SPARQL; module Algebra
336
336
  # @option options [Boolean] :memoize (false)
337
337
  # whether to memoize results for particular operands
338
338
  # @raise [TypeError] if any operand is invalid
339
- def initialize(*operands)
340
- @options = operands.last.is_a?(Hash) ? operands.pop.dup : {}
339
+ def initialize(*operands, **options)
340
+ @options = options.dup
341
341
  @operands = operands.map! do |operand|
342
342
  case operand
343
343
  when Array
@@ -358,7 +358,7 @@ module SPARQL; module Algebra
358
358
  ##
359
359
  # Deep duplicate operands
360
360
  def deep_dup
361
- self.class.new(*operands.map(&:deep_dup), @options)
361
+ self.class.new(*operands.map(&:deep_dup), **@options)
362
362
  end
363
363
 
364
364
  ##
@@ -745,7 +745,7 @@ module SPARQL; module Algebra
745
745
  ##
746
746
  # @param [Hash{Symbol => Object}] options
747
747
  # any additional options (see {Operator#initialize})
748
- def initialize(options = {})
748
+ def initialize(**options)
749
749
  super
750
750
  end
751
751
  end # Nullary
@@ -764,7 +764,7 @@ module SPARQL; module Algebra
764
764
  # the operand
765
765
  # @param [Hash{Symbol => Object}] options
766
766
  # any additional options (see {Operator#initialize})
767
- def initialize(arg, options = {})
767
+ def initialize(arg, **options)
768
768
  super
769
769
  end
770
770
  end # Unary
@@ -785,7 +785,7 @@ module SPARQL; module Algebra
785
785
  # the second operand
786
786
  # @param [Hash{Symbol => Object}] options
787
787
  # any additional options (see {Operator#initialize})
788
- def initialize(arg1, arg2, options = {})
788
+ def initialize(arg1, arg2, **options)
789
789
  super
790
790
  end
791
791
  end # Binary
@@ -808,7 +808,7 @@ module SPARQL; module Algebra
808
808
  # the third operand
809
809
  # @param [Hash{Symbol => Object}] options
810
810
  # any additional options (see {Operator#initialize})
811
- def initialize(arg1, arg2, arg3, options = {})
811
+ def initialize(arg1, arg2, arg3, **options)
812
812
  super
813
813
  end
814
814
  end # Ternary
@@ -833,7 +833,7 @@ module SPARQL; module Algebra
833
833
  # the forth operand
834
834
  # @param [Hash{Symbol => Object}] options
835
835
  # any additional options (see {Operator#initialize})
836
- def initialize(arg1, arg2, arg3, arg4, options = {})
836
+ def initialize(arg1, arg2, arg3, arg4, **options)
837
837
  super
838
838
  end
839
839
  end # Ternary
@@ -16,6 +16,13 @@ module SPARQL; module Algebra
16
16
 
17
17
  NAME = :avg
18
18
 
19
+ def initialize(*operands, **options)
20
+ raise ArgumentError,
21
+ "avg operator accepts at most one argument with an optional :distinct" if
22
+ (operands - %i{distinct}).length != 1
23
+ super
24
+ end
25
+
19
26
  ##
20
27
  # The Avg set function calculates the average value for an expression over a group. It is defined in terms of Sum and Count.
21
28
  #
@@ -22,7 +22,7 @@ module SPARQL; module Algebra
22
22
  # @yieldparam [RDF::Query::Solution] solution
23
23
  # @yieldreturn [void] ignored
24
24
  # @return [RDF::Query]
25
- def self.new(*patterns, &block)
25
+ def self.new(*patterns, **options, &block)
26
26
  RDF::Query.new(*patterns, graph_name: false, &block)
27
27
  end
28
28
  end # BGP
@@ -36,7 +36,7 @@ module SPARQL; module Algebra
36
36
  # @param [Array<RDF::Query::Pattern>] patterns
37
37
  # Quads
38
38
  # @return [RDF::Query]
39
- def self.new(name, patterns, options = {}, &block)
39
+ def self.new(name, patterns, **options, &block)
40
40
  case patterns
41
41
  when RDF::Query
42
42
  # Record that the argument as a (bgp) for re-serialization back to SSE
@@ -37,6 +37,10 @@ module SPARQL; module Algebra
37
37
  def execute(queryable, **options, &block)
38
38
  filter = operand(2)
39
39
 
40
+ raise ArgumentError,
41
+ "leftjoin operator accepts at most two arguments with an optional filter" if
42
+ operands.length < 2 || operands.length > 3
43
+
40
44
  debug(options) {"LeftJoin"}
41
45
  left = queryable.query(operand(0), depth: options[:depth].to_i + 1, **options)
42
46
  debug(options) {"=>(leftjoin left) #{left.inspect}"}
@@ -16,6 +16,13 @@ module SPARQL; module Algebra
16
16
 
17
17
  NAME = :max
18
18
 
19
+ def initialize(*operands, **options)
20
+ raise ArgumentError,
21
+ "max operator accepts at most one argument with an optional :distinct" if
22
+ (operands - %i{distinct}).length != 1
23
+ super
24
+ end
25
+
19
26
  ##
20
27
  # Max is a SPARQL set function that return the maximum value from a group respectively.
21
28
  #
@@ -16,6 +16,13 @@ module SPARQL; module Algebra
16
16
 
17
17
  NAME = :min
18
18
 
19
+ def initialize(*operands, **options)
20
+ raise ArgumentError,
21
+ "min operator accepts at most one argument with an optional :distinct" if
22
+ (operands - %i{distinct}).length != 1
23
+ super
24
+ end
25
+
19
26
  ##
20
27
  # Min is a SPARQL set function that return the minimum value from a group respectively.
21
28
  #
@@ -12,11 +12,18 @@ module SPARQL; module Algebra
12
12
  # (bgp (triple ?s :dec ?o)))))))
13
13
  #
14
14
  # @see https://www.w3.org/TR/sparql11-query/#defn_aggSample
15
- class Sample < Operator::Unary
15
+ class Sample < Operator
16
16
  include Aggregate
17
17
 
18
18
  NAME = :sample
19
19
 
20
+ def initialize(*operands, **options)
21
+ raise ArgumentError,
22
+ "sample operator accepts at most one argument with an optional :distinct" if
23
+ (operands - %i{distinct}).length != 1
24
+ super
25
+ end
26
+
20
27
  ##
21
28
  # Sample is a set function which returns an arbitrary value from the multiset passed to it.
22
29
  #
@@ -25,11 +25,7 @@ module RDF::Queryable
25
25
  #
26
26
  # Used to implement the SPARQL `DESCRIBE` operator.
27
27
  #
28
- # @overload concise_bounded_description(*terms, &block)
29
- # @param [Array<RDF::Term>] terms
30
- # List of terms to include in the results.
31
- #
32
- # @overload concise_bounded_description(*terms, options, &block)
28
+ # @overload concise_bounded_description(*terms, **options, &block)
33
29
  # @param [Array<RDF::Term>] terms
34
30
  # List of terms to include in the results.
35
31
  # @param [Hash{Symbol => Object}] options
@@ -44,16 +40,14 @@ module RDF::Queryable
44
40
  # @return [RDF::Graph]
45
41
  #
46
42
  # @see https://www.w3.org/Submission/CBD/
47
- def concise_bounded_description(*terms, &block)
48
- options = terms.last.is_a?(Hash) ? terms.pop.dup : {}
49
-
43
+ def concise_bounded_description(*terms, **options, &block)
50
44
  graph = options[:graph] || RDF::Graph.new
51
45
 
52
46
  if options[:non_subjects]
53
47
  query_terms = terms.dup
54
48
 
55
49
  # Find terms not in self as a subject and recurse with their subjects
56
- terms.reject {|term| self.first(subject: term)}.each do |term|
50
+ terms.reject {|term| self.first({subject: term})}.each do |term|
57
51
  self.query({predicate: term}) do |statement|
58
52
  query_terms << statement.subject
59
53
  end
@@ -67,7 +61,7 @@ module RDF::Queryable
67
61
  end
68
62
 
69
63
  # Don't consider term if already in graph
70
- terms.reject {|term| graph.first(subject: term)}.each do |term|
64
+ terms.reject {|term| graph.first({subject: term})}.each do |term|
71
65
  # Find statements from queryiable with term as a subject
72
66
  self.query({subject: term}) do |statement|
73
67
  yield(statement) if block_given?
@@ -84,13 +78,13 @@ module RDF::Queryable
84
78
  }, **{}).execute(self).each do |solution|
85
79
  # Recurse to include this subject
86
80
  recurse_opts = options.merge(non_subjects: false, graph: graph)
87
- self.concise_bounded_description(solution[:s], recurse_opts, &block)
81
+ self.concise_bounded_description(solution[:s], **recurse_opts, &block)
88
82
  end
89
83
 
90
84
  # Recurse if object is a BNode and it is not already in subjects
91
85
  if statement.object.node?
92
86
  recurse_opts = options.merge(non_subjects: false, graph: graph)
93
- self.concise_bounded_description(statement.object, recurse_opts, &block)
87
+ self.concise_bounded_description(statement.object, **recurse_opts, &block)
94
88
  end
95
89
  end
96
90
  end
@@ -292,7 +292,7 @@ module SPARQL
292
292
  # @raise [RDF::FormatError] if no reader found for the specified format
293
293
  def self.open(filename, **options, &block)
294
294
  RDF::Util::File.open_file(filename, **options) do |file|
295
- self.parse(file, options, &block)
295
+ self.parse(file, **options, &block)
296
296
  end
297
297
  end
298
298
 
@@ -326,7 +326,7 @@ module SPARQL
326
326
  # @return [Lexer]
327
327
  # @raise [Lexer::Error] on invalid input
328
328
  def self.tokenize(query, **options, &block)
329
- Lexer.tokenize(query, options, &block)
329
+ Lexer.tokenize(query, **options, &block)
330
330
  end
331
331
  end # Grammar
332
332
  end # SPARQL
@@ -878,10 +878,10 @@ module SPARQL::Grammar
878
878
  # [80] Object ::= GraphNode | EmbTP
879
879
  production(:Object) do |input, data, callback|
880
880
  object = data[:GraphNode] || data[:EmbTP]
881
+ add_prod_datum(:pattern, data[:pattern])
881
882
  if object
882
883
  if prod_data[:Verb]
883
884
  add_pattern(:Object, subject: prod_data[:Subject], predicate: prod_data[:Verb], object: object)
884
- add_prod_datum(:pattern, data[:pattern])
885
885
  elsif prod_data[:VerbPath]
886
886
  add_prod_datum(:path,
887
887
  SPARQL::Algebra::Expression(:path,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparql
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.4
4
+ version: 3.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-12-25 00:00:00.000000000 Z
12
+ date: 2021-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdf
@@ -94,6 +94,9 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.1'
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 3.1.2
97
100
  type: :runtime
98
101
  prerelease: false
99
102
  version_requirements: !ruby/object:Gem::Requirement
@@ -101,6 +104,9 @@ dependencies:
101
104
  - - "~>"
102
105
  - !ruby/object:Gem::Version
103
106
  version: '3.1'
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 3.1.2
104
110
  - !ruby/object:Gem::Dependency
105
111
  name: rdf-xsd
106
112
  requirement: !ruby/object:Gem::Requirement
@@ -227,10 +233,8 @@ dependencies:
227
233
  - - "~>"
228
234
  - !ruby/object:Gem::Version
229
235
  version: '0.9'
230
- description: |2-
231
-
232
- Implements SPARQL grammar parsing to SPARQL Algebra, SPARQL Algebra processing
233
- and includes SPARQL Client for accessing remote repositories.
236
+ description: SPARQL Implements SPARQL 1.1 Query, Update and result formats for the
237
+ Ruby RDF.rb library suite.
234
238
  email: public-rdf-ruby@w3.org
235
239
  executables:
236
240
  - sparql
@@ -409,7 +413,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
409
413
  - !ruby/object:Gem::Version
410
414
  version: '0'
411
415
  requirements: []
412
- rubygems_version: 3.1.4
416
+ rubygems_version: 3.0.8
413
417
  signing_key:
414
418
  specification_version: 4
415
419
  summary: SPARQL Query and Update library for Ruby.