sparql 3.0.2 → 3.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +189 -74
  3. data/UNLICENSE +1 -1
  4. data/VERSION +1 -1
  5. data/bin/sparql +44 -24
  6. data/lib/rack/sparql.rb +1 -1
  7. data/lib/rack/sparql/conneg.rb +3 -3
  8. data/lib/sinatra/sparql.rb +5 -5
  9. data/lib/sparql.rb +17 -16
  10. data/lib/sparql/algebra.rb +15 -23
  11. data/lib/sparql/algebra/aggregate.rb +4 -4
  12. data/lib/sparql/algebra/evaluatable.rb +2 -2
  13. data/lib/sparql/algebra/expression.rb +70 -44
  14. data/lib/sparql/algebra/extensions.rb +181 -34
  15. data/lib/sparql/algebra/operator.rb +44 -23
  16. data/lib/sparql/algebra/operator/abs.rb +2 -2
  17. data/lib/sparql/algebra/operator/add.rb +3 -3
  18. data/lib/sparql/algebra/operator/alt.rb +4 -4
  19. data/lib/sparql/algebra/operator/and.rb +7 -7
  20. data/lib/sparql/algebra/operator/asc.rb +3 -3
  21. data/lib/sparql/algebra/operator/ask.rb +4 -14
  22. data/lib/sparql/algebra/operator/avg.rb +13 -4
  23. data/lib/sparql/algebra/operator/base.rb +10 -10
  24. data/lib/sparql/algebra/operator/bgp.rb +2 -2
  25. data/lib/sparql/algebra/operator/bnode.rb +5 -5
  26. data/lib/sparql/algebra/operator/bound.rb +3 -3
  27. data/lib/sparql/algebra/operator/ceil.rb +2 -2
  28. data/lib/sparql/algebra/operator/clear.rb +3 -3
  29. data/lib/sparql/algebra/operator/coalesce.rb +3 -13
  30. data/lib/sparql/algebra/operator/compare.rb +8 -8
  31. data/lib/sparql/algebra/operator/concat.rb +4 -4
  32. data/lib/sparql/algebra/operator/construct.rb +4 -14
  33. data/lib/sparql/algebra/operator/contains.rb +2 -2
  34. data/lib/sparql/algebra/operator/copy.rb +3 -3
  35. data/lib/sparql/algebra/operator/count.rb +3 -3
  36. data/lib/sparql/algebra/operator/create.rb +3 -3
  37. data/lib/sparql/algebra/operator/dataset.rb +6 -17
  38. data/lib/sparql/algebra/operator/datatype.rb +1 -1
  39. data/lib/sparql/algebra/operator/day.rb +1 -1
  40. data/lib/sparql/algebra/operator/delete.rb +9 -7
  41. data/lib/sparql/algebra/operator/delete_data.rb +3 -3
  42. data/lib/sparql/algebra/operator/delete_where.rb +6 -6
  43. data/lib/sparql/algebra/operator/desc.rb +1 -1
  44. data/lib/sparql/algebra/operator/describe.rb +3 -13
  45. data/lib/sparql/algebra/operator/distinct.rb +4 -14
  46. data/lib/sparql/algebra/operator/divide.rb +1 -1
  47. data/lib/sparql/algebra/operator/drop.rb +3 -3
  48. data/lib/sparql/algebra/operator/encode_for_uri.rb +3 -3
  49. data/lib/sparql/algebra/operator/equal.rb +2 -2
  50. data/lib/sparql/algebra/operator/exists.rb +5 -5
  51. data/lib/sparql/algebra/operator/exprlist.rb +3 -13
  52. data/lib/sparql/algebra/operator/extend.rb +19 -18
  53. data/lib/sparql/algebra/operator/filter.rb +6 -16
  54. data/lib/sparql/algebra/operator/floor.rb +2 -2
  55. data/lib/sparql/algebra/operator/graph.rb +6 -17
  56. data/lib/sparql/algebra/operator/greater_than.rb +5 -5
  57. data/lib/sparql/algebra/operator/greater_than_or_equal.rb +5 -5
  58. data/lib/sparql/algebra/operator/group.rb +25 -25
  59. data/lib/sparql/algebra/operator/group_concat.rb +6 -6
  60. data/lib/sparql/algebra/operator/hours.rb +1 -1
  61. data/lib/sparql/algebra/operator/if.rb +5 -15
  62. data/lib/sparql/algebra/operator/in.rb +4 -14
  63. data/lib/sparql/algebra/operator/insert.rb +7 -5
  64. data/lib/sparql/algebra/operator/insert_data.rb +3 -3
  65. data/lib/sparql/algebra/operator/iri.rb +1 -1
  66. data/lib/sparql/algebra/operator/is_blank.rb +1 -1
  67. data/lib/sparql/algebra/operator/is_iri.rb +1 -1
  68. data/lib/sparql/algebra/operator/is_literal.rb +1 -1
  69. data/lib/sparql/algebra/operator/is_numeric.rb +1 -1
  70. data/lib/sparql/algebra/operator/join.rb +12 -10
  71. data/lib/sparql/algebra/operator/lang.rb +1 -1
  72. data/lib/sparql/algebra/operator/lang_matches.rb +3 -3
  73. data/lib/sparql/algebra/operator/lcase.rb +2 -2
  74. data/lib/sparql/algebra/operator/left_join.rb +19 -12
  75. data/lib/sparql/algebra/operator/less_than.rb +5 -5
  76. data/lib/sparql/algebra/operator/less_than_or_equal.rb +5 -5
  77. data/lib/sparql/algebra/operator/load.rb +3 -3
  78. data/lib/sparql/algebra/operator/max.rb +13 -4
  79. data/lib/sparql/algebra/operator/md5.rb +1 -1
  80. data/lib/sparql/algebra/operator/min.rb +13 -4
  81. data/lib/sparql/algebra/operator/minus.rb +12 -11
  82. data/lib/sparql/algebra/operator/minutes.rb +1 -1
  83. data/lib/sparql/algebra/operator/modify.rb +4 -4
  84. data/lib/sparql/algebra/operator/month.rb +1 -1
  85. data/lib/sparql/algebra/operator/move.rb +3 -3
  86. data/lib/sparql/algebra/operator/multiply.rb +1 -1
  87. data/lib/sparql/algebra/operator/negate.rb +1 -1
  88. data/lib/sparql/algebra/operator/not.rb +1 -1
  89. data/lib/sparql/algebra/operator/not_equal.rb +2 -2
  90. data/lib/sparql/algebra/operator/notexists.rb +4 -4
  91. data/lib/sparql/algebra/operator/notin.rb +4 -14
  92. data/lib/sparql/algebra/operator/notoneof.rb +5 -6
  93. data/lib/sparql/algebra/operator/now.rb +1 -1
  94. data/lib/sparql/algebra/operator/or.rb +7 -7
  95. data/lib/sparql/algebra/operator/order.rb +6 -16
  96. data/lib/sparql/algebra/operator/path.rb +6 -5
  97. data/lib/sparql/algebra/operator/path_opt.rb +16 -16
  98. data/lib/sparql/algebra/operator/path_plus.rb +8 -8
  99. data/lib/sparql/algebra/operator/path_star.rb +4 -4
  100. data/lib/sparql/algebra/operator/plus.rb +3 -3
  101. data/lib/sparql/algebra/operator/prefix.rb +10 -10
  102. data/lib/sparql/algebra/operator/project.rb +4 -14
  103. data/lib/sparql/algebra/operator/rand.rb +1 -1
  104. data/lib/sparql/algebra/operator/reduced.rb +4 -14
  105. data/lib/sparql/algebra/operator/regex.rb +6 -6
  106. data/lib/sparql/algebra/operator/replace.rb +4 -4
  107. data/lib/sparql/algebra/operator/reverse.rb +4 -4
  108. data/lib/sparql/algebra/operator/round.rb +2 -2
  109. data/lib/sparql/algebra/operator/same_term.rb +8 -5
  110. data/lib/sparql/algebra/operator/sample.rb +11 -4
  111. data/lib/sparql/algebra/operator/seconds.rb +1 -1
  112. data/lib/sparql/algebra/operator/seq.rb +5 -6
  113. data/lib/sparql/algebra/operator/sequence.rb +4 -4
  114. data/lib/sparql/algebra/operator/sha1.rb +1 -1
  115. data/lib/sparql/algebra/operator/sha256.rb +1 -1
  116. data/lib/sparql/algebra/operator/sha384.rb +1 -1
  117. data/lib/sparql/algebra/operator/sha512.rb +1 -1
  118. data/lib/sparql/algebra/operator/slice.rb +4 -14
  119. data/lib/sparql/algebra/operator/str.rb +1 -1
  120. data/lib/sparql/algebra/operator/strafter.rb +2 -2
  121. data/lib/sparql/algebra/operator/strbefore.rb +2 -2
  122. data/lib/sparql/algebra/operator/strdt.rb +2 -2
  123. data/lib/sparql/algebra/operator/strends.rb +2 -2
  124. data/lib/sparql/algebra/operator/strlang.rb +2 -2
  125. data/lib/sparql/algebra/operator/strlen.rb +2 -2
  126. data/lib/sparql/algebra/operator/strstarts.rb +2 -2
  127. data/lib/sparql/algebra/operator/struuid.rb +1 -1
  128. data/lib/sparql/algebra/operator/substr.rb +4 -4
  129. data/lib/sparql/algebra/operator/subtract.rb +1 -1
  130. data/lib/sparql/algebra/operator/sum.rb +6 -4
  131. data/lib/sparql/algebra/operator/table.rb +3 -3
  132. data/lib/sparql/algebra/operator/timezone.rb +1 -1
  133. data/lib/sparql/algebra/operator/tz.rb +1 -1
  134. data/lib/sparql/algebra/operator/ucase.rb +2 -2
  135. data/lib/sparql/algebra/operator/union.rb +9 -8
  136. data/lib/sparql/algebra/operator/update.rb +4 -4
  137. data/lib/sparql/algebra/operator/using.rb +4 -4
  138. data/lib/sparql/algebra/operator/uuid.rb +1 -1
  139. data/lib/sparql/algebra/operator/with.rb +7 -7
  140. data/lib/sparql/algebra/operator/year.rb +1 -1
  141. data/lib/sparql/algebra/query.rb +2 -2
  142. data/lib/sparql/algebra/update.rb +2 -2
  143. data/lib/sparql/algebra/version.rb +1 -1
  144. data/lib/sparql/extensions.rb +11 -17
  145. data/lib/sparql/grammar.rb +113 -13
  146. data/lib/sparql/grammar/meta.rb +2340 -907
  147. data/lib/sparql/grammar/parser11.rb +57 -52
  148. data/lib/sparql/grammar/terminals11.rb +2 -0
  149. data/lib/sparql/results.rb +73 -46
  150. data/lib/sparql/version.rb +1 -1
  151. metadata +46 -63
@@ -7,7 +7,7 @@ module SPARQL; module Algebra
7
7
  # (- ?x)
8
8
  # (negate ?x)
9
9
  #
10
- # @see http://www.w3.org/TR/xpath-functions/#func-numeric-unary-minus
10
+ # @see https://www.w3.org/TR/xpath-functions/#func-numeric-unary-minus
11
11
  class Negate < Operator::Unary
12
12
  include Evaluatable
13
13
 
@@ -7,7 +7,7 @@ module SPARQL; module Algebra
7
7
  # (! ?x)
8
8
  # (not ?x)
9
9
  #
10
- # @see http://www.w3.org/TR/xpath-functions/#func-not
10
+ # @see https://www.w3.org/TR/xpath-functions/#func-not
11
11
  class Not < Operator::Unary
12
12
  include Evaluatable
13
13
 
@@ -3,8 +3,8 @@ module SPARQL; module Algebra
3
3
  ##
4
4
  # The SPARQL relational `!=` (not equal) comparison operator.
5
5
  #
6
- # @see http://www.w3.org/TR/sparql11-query/#OperatorMapping
7
- # @see http://www.w3.org/TR/sparql11-query/#func-RDFterm-equal
6
+ # @see https://www.w3.org/TR/sparql11-query/#OperatorMapping
7
+ # @see https://www.w3.org/TR/sparql11-query/#func-RDFterm-equal
8
8
  class NotEqual < Equal
9
9
  NAME = :'!='
10
10
 
@@ -12,8 +12,8 @@ module SPARQL; module Algebra
12
12
  # (bgp (triple ?s ?p ex:o1))))
13
13
  # (bgp (triple ?s ?p ex:o))))
14
14
  #
15
- # @see http://www.w3.org/TR/sparql11-query/#func-abs
16
- # @see http://www.w3.org/TR/xpath-functions/#func-abs
15
+ # @see https://www.w3.org/TR/sparql11-query/#func-abs
16
+ # @see https://www.w3.org/TR/xpath-functions/#func-abs
17
17
  class NotExists < Operator::Unary
18
18
  include Evaluatable
19
19
 
@@ -29,10 +29,10 @@ module SPARQL; module Algebra
29
29
  # @option options[RDF::Queryable] queryable
30
30
  # queryable to execute, using bindings as an initial solution.
31
31
  # @return [RDF::Literal::Boolean] `true` or `false`
32
- def evaluate(bindings, options = {})
32
+ def evaluate(bindings, **options)
33
33
  solutions = RDF::Query::Solutions(bindings)
34
34
  queryable = options[:queryable]
35
- operand(0).execute(queryable, options.merge(solutions: solutions)).empty?
35
+ operand(0).execute(queryable, solutions: solutions, **options).empty?
36
36
  end
37
37
  end # NotExists
38
38
  end # Operator
@@ -8,7 +8,7 @@ module SPARQL; module Algebra
8
8
  # @example
9
9
  # (ask (filter (notin ?o 1 2) (bgp)))
10
10
  #
11
- # @see http://www.w3.org/TR/sparql11-query/#func-notin
11
+ # @see https://www.w3.org/TR/sparql11-query/#func-notin
12
12
  class NotIn < Operator
13
13
  include Evaluatable
14
14
 
@@ -42,12 +42,12 @@ module SPARQL; module Algebra
42
42
  # options passed from query
43
43
  # @return [RDF::Literal::Boolean] `true` or `false`
44
44
  # @raise [TypeError] if term is not found and any operand raises an error
45
- def evaluate(bindings, options = {})
46
- lhs = operands.first.evaluate(bindings, options.merge(depth: options[:depth].to_i + 1))
45
+ def evaluate(bindings, **options)
46
+ lhs = operands.first.evaluate(bindings, depth: options[:depth].to_i + 1, **options)
47
47
  error_found = false
48
48
  found = operands[1..-1].any? do |op|
49
49
  begin
50
- lhs == op.evaluate(bindings, options.merge(depth: options[:depth].to_i + 1))
50
+ lhs == op.evaluate(bindings, depth: options[:depth].to_i + 1, **options)
51
51
  rescue TypeError
52
52
  error_found = true
53
53
  end
@@ -58,16 +58,6 @@ module SPARQL; module Algebra
58
58
  else RDF::Literal::TRUE
59
59
  end
60
60
  end
61
-
62
- ##
63
- # Returns an optimized version of this query.
64
- #
65
- # Return optimized query
66
- #
67
- # @return [Union, RDF::Query] `self`
68
- def optimize
69
- operands = operands.map(&:optimize)
70
- end
71
61
  end # Exprlist
72
62
  end # Operator
73
63
  end; end # SPARQL::Algebra
@@ -6,7 +6,7 @@ module SPARQL; module Algebra
6
6
  # @example
7
7
  # (notoneof ex:p1 ex:p2)
8
8
  #
9
- # @see http://www.w3.org/TR/sparql11-query/#eval_negatedPropertySet
9
+ # @see https://www.w3.org/TR/sparql11-query/#eval_negatedPropertySet
10
10
  class NotOneOf < Operator
11
11
  include Query
12
12
 
@@ -30,18 +30,17 @@ module SPARQL; module Algebra
30
30
  # each matching solution
31
31
  # @yieldparam [RDF::Query::Solution] solution
32
32
  # @yieldreturn [void] ignored
33
- # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
34
- def execute(queryable, options = {}, &block)
33
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
34
+ def execute(queryable, **options, &block)
35
35
  debug(options) {"NotOneOf #{operands.to_sse}"}
36
36
  subject, object = options[:subject], options[:object]
37
37
 
38
- v = RDF::Query::Variable.new
39
- v.distinguished = false
38
+ v = RDF::Query::Variable.new(distinguished: false)
40
39
  bgp = RDF::Query.new do |q|
41
40
  q.pattern [subject, v, object]
42
41
  end
43
42
  query = Filter.new(NotIn.new(v, *operands), bgp)
44
- queryable.query(query, options.merge(depth: options[:depth].to_i + 1)) do |solution|
43
+ queryable.query(query, depth: options[:depth].to_i + 1, **options) do |solution|
45
44
  solution.bindings.delete(v.to_sym)
46
45
  debug(options) {"(solution)-> #{solution.to_h.to_sse}"}
47
46
  block.call(solution)
@@ -13,7 +13,7 @@ module SPARQL; module Algebra
13
13
  # (extend ((?n (now)))
14
14
  # (bgp)))))
15
15
  #
16
- # @see http://www.w3.org/TR/sparql11-query/#func-now
16
+ # @see https://www.w3.org/TR/sparql11-query/#func-now
17
17
  class Now < Operator::Nullary
18
18
  include Evaluatable
19
19
 
@@ -7,8 +7,8 @@ module SPARQL; module Algebra
7
7
  # (|| ?x ?y)
8
8
  # (or ?x ?y)
9
9
  #
10
- # @see http://www.w3.org/TR/sparql11-query/#func-logical-or
11
- # @see http://www.w3.org/TR/sparql11-query/#evaluation
10
+ # @see https://www.w3.org/TR/sparql11-query/#func-logical-or
11
+ # @see https://www.w3.org/TR/sparql11-query/#evaluation
12
12
  class Or < Operator::Binary
13
13
  include Evaluatable
14
14
 
@@ -24,7 +24,7 @@ module SPARQL; module Algebra
24
24
  # @param [Hash{Symbol => Object}] options
25
25
  # any additional options (see {Operator#initialize})
26
26
  # @raise [TypeError] if any operand is invalid
27
- def initialize(left, right, options = {})
27
+ def initialize(left, right, **options)
28
28
  super
29
29
  end
30
30
 
@@ -40,20 +40,20 @@ module SPARQL; module Algebra
40
40
  # options passed from query
41
41
  # @return [RDF::Literal::Boolean] `true` or `false`
42
42
  # @raise [TypeError] if the operands could not be coerced to a boolean literal
43
- def evaluate(bindings, options = {})
43
+ def evaluate(bindings, **options)
44
44
  begin
45
- left = boolean(operand(0).evaluate(bindings, options.merge(depth: options[:depth].to_i + 1))).true?
45
+ left = boolean(operand(0).evaluate(bindings, depth: options[:depth].to_i + 1, **options)).true?
46
46
  rescue TypeError
47
47
  left = nil
48
48
  end
49
49
 
50
50
  begin
51
- right = boolean(operand(1).evaluate(bindings, options.merge(depth: options[:depth].to_i + 1))).true?
51
+ right = boolean(operand(1).evaluate(bindings, depth: options[:depth].to_i + 1, **options)).true?
52
52
  rescue TypeError
53
53
  right = nil
54
54
  end
55
55
 
56
- # From http://www.w3.org/TR/sparql11-query/#evaluation
56
+ # From https://www.w3.org/TR/sparql11-query/#evaluation
57
57
  # A logical-or that encounters an error on only one branch will return TRUE if the other branch is TRUE
58
58
  # and an error if the other branch is FALSE.
59
59
  case
@@ -9,7 +9,7 @@ module SPARQL; module Algebra
9
9
  # (order ((asc ?name))
10
10
  # (bgp (triple ?x foaf:name ?name)))))
11
11
  #
12
- # @see http://www.w3.org/TR/sparql11-query/#modOrderBy
12
+ # @see https://www.w3.org/TR/sparql11-query/#modOrderBy
13
13
  class Order < Operator::Binary
14
14
  include Query
15
15
 
@@ -30,16 +30,16 @@ module SPARQL; module Algebra
30
30
  # @yieldreturn [void] ignored
31
31
  # @return [RDF::Query::Solutions]
32
32
  # the resulting solution sequence
33
- # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
34
- def execute(queryable, options = {}, &block)
33
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
34
+ def execute(queryable, **options, &block)
35
35
 
36
36
  debug(options) {"Order"}
37
- @solutions = queryable.query(operands.last, options.merge(depth: options[:depth].to_i + 1)).order do |a, b|
37
+ @solutions = queryable.query(operands.last, depth: options[:depth].to_i + 1, **options).order do |a, b|
38
38
  operand(0).inject(0) do |memo, op|
39
39
  debug(options) {"(order) #{op.inspect}"}
40
40
  memo = begin
41
- a_eval = op.evaluate(a, options.merge(queryable: queryable, depth: options[:depth].to_i + 1)) rescue nil
42
- b_eval = op.evaluate(b, options.merge(queryable: queryable, depth: options[:depth].to_i + 1)) rescue nil
41
+ a_eval = op.evaluate(a, queryable: queryable, depth: options[:depth].to_i + 1, **options) rescue nil
42
+ b_eval = op.evaluate(b, queryable: queryable, depth: options[:depth].to_i + 1, **options) rescue nil
43
43
  comp = Operator::Compare.evaluate(a_eval, b_eval).to_i
44
44
  comp = -comp if op.is_a?(Operator::Desc)
45
45
  comp
@@ -50,16 +50,6 @@ module SPARQL; module Algebra
50
50
  @solutions.each(&block) if block_given?
51
51
  @solutions
52
52
  end
53
-
54
- ##
55
- # Returns an optimized version of this query.
56
- #
57
- # Return optimized query
58
- #
59
- # @return [Union, RDF::Query] `self`
60
- def optimize
61
- operands = operands.map(&:optimize)
62
- end
63
53
  end # Order
64
54
  end # Operator
65
55
  end; end # SPARQL::Algebra
@@ -6,7 +6,7 @@ module SPARQL; module Algebra
6
6
  # @example
7
7
  # (path :a (path+ :p) ?z)
8
8
  #
9
- # @see http://www.w3.org/TR/sparql11-query/#sparqlTranslatePathExpressions
9
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlTranslatePathExpressions
10
10
  class Path < Operator::Ternary
11
11
  include Query
12
12
 
@@ -25,17 +25,18 @@ module SPARQL; module Algebra
25
25
  # @yieldreturn [void] ignored
26
26
  # @return [RDF::Query::Solutions]
27
27
  # the resulting solution sequence
28
- # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
29
- def execute(queryable, options = {}, &block)
28
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
29
+ def execute(queryable, **options, &block)
30
30
  debug(options) {"Path #{operands.to_sse}"}
31
31
  subject, path_op, object = operands
32
32
 
33
33
  @solutions = RDF::Query::Solutions.new
34
- path_op.execute(queryable, options.merge(
34
+ path_op.execute(queryable,
35
35
  subject: subject,
36
36
  object: object,
37
37
  graph_name: options.fetch(:graph_name, false),
38
- depth: options[:depth].to_i + 1)
38
+ depth: options[:depth].to_i + 1,
39
+ **options
39
40
  ) do |solution|
40
41
  @solutions << solution
41
42
  end
@@ -6,7 +6,7 @@ module SPARQL; module Algebra
6
6
  # @example
7
7
  # (path? :p)
8
8
  #
9
- # @see http://www.w3.org/TR/sparql11-query/#defn_evalPP_ZeroOrOnePath
9
+ # @see https://www.w3.org/TR/sparql11-query/#defn_evalPP_ZeroOrOnePath
10
10
  class PathOpt < Operator::Unary
11
11
  include Query
12
12
 
@@ -29,8 +29,8 @@ module SPARQL; module Algebra
29
29
  # each matching solution
30
30
  # @yieldparam [RDF::Query::Solution] solution
31
31
  # @yieldreturn [void] ignored
32
- # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
33
- def execute(queryable, options = {}, &block)
32
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
33
+ def execute(queryable, **options, &block)
34
34
  subject, object = options[:subject], options[:object]
35
35
  debug(options) {"Path? #{[subject, operands, object].to_sse}"}
36
36
 
@@ -41,48 +41,48 @@ module SPARQL; module Algebra
41
41
  # Nodes is the set of all subjects and objects in queryable
42
42
  # FIXME: should this be Queryable#enum_nodes?
43
43
  # All subjects which are `object`
44
- query = RDF::Query.new {|q| q.pattern(subject: subject)}
45
- queryable.query(query, options) do |solution|
44
+ query = RDF::Query.new {|q| q.pattern({subject: subject})}
45
+ queryable.query(query, **options) do |solution|
46
46
  solution.merge!(object.to_sym => solution[subject])
47
47
  debug(options) {"(solution-s0)-> #{solution.to_h.to_sse}"}
48
48
  solutions << solution
49
49
  end if query.valid?
50
50
 
51
51
  # All objects which are `object`
52
- query = RDF::Query.new {|q| q.pattern(object: object)}
53
- queryable.query(query, options) do |solution|
52
+ query = RDF::Query.new {|q| q.pattern({object: object})}
53
+ queryable.query(query, **options) do |solution|
54
54
  solution.merge!(subject.to_sym => solution[object])
55
55
  debug(options) {"(solution-o0)-> #{solution.to_h.to_sse}"}
56
56
  solutions << solution
57
57
  end if query.valid?
58
58
  when subject.variable?
59
59
  # All subjects which are `object`
60
- query = RDF::Query.new {|q| q.pattern(subject: object)}
61
- queryable.query(query, options) do |solution|
60
+ query = RDF::Query.new {|q| q.pattern({subject: object})}
61
+ queryable.query(query, **options) do |solution|
62
62
  solution.merge!(subject.to_sym => object)
63
63
  debug(options) {"(solution-s0)-> #{solution.to_h.to_sse}"}
64
64
  solutions << solution
65
65
  end if query.valid?
66
66
 
67
67
  # All objects which are `object`
68
- query = RDF::Query.new {|q| q.pattern(object: object)}
69
- queryable.query(query, options) do |solution|
68
+ query = RDF::Query.new {|q| q.pattern({object: object})}
69
+ queryable.query(query, **options) do |solution|
70
70
  solution.merge!(subject.to_sym => object)
71
71
  debug(options) {"(solution-o0)-> #{solution.to_h.to_sse}"}
72
72
  solutions << solution
73
73
  end if query.valid?
74
74
  when object.variable?
75
75
  # All subjects which are `subject`
76
- query = RDF::Query.new {|q| q.pattern(subject: subject)}
77
- queryable.query(query, options) do |solution|
76
+ query = RDF::Query.new {|q| q.pattern({subject: subject})}
77
+ queryable.query(query, **options) do |solution|
78
78
  solution.merge!(object.to_sym => subject)
79
79
  debug(options) {"(solution-s0)-> #{solution.to_h.to_sse}"}
80
80
  solutions << solution
81
81
  end if query.valid?
82
82
 
83
83
  # All objects which are `subject
84
- query = RDF::Query.new {|q| q.pattern(object: subject)}
85
- queryable.query(query, options) do |solution|
84
+ query = RDF::Query.new {|q| q.pattern({object: subject})}
85
+ queryable.query(query, **options) do |solution|
86
86
  solution.merge!(object.to_sym => subject)
87
87
  debug(options) {"(solution-o0)-> #{solution.to_h.to_sse}"}
88
88
  solutions << solution
@@ -103,7 +103,7 @@ module SPARQL; module Algebra
103
103
 
104
104
  # Recurse into query
105
105
  solutions +=
106
- queryable.query(query, options.merge(depth: options[:depth].to_i + 1))
106
+ queryable.query(query, depth: options[:depth].to_i + 1, **options)
107
107
  solutions.each(&block) if block_given?
108
108
  solutions
109
109
  end
@@ -6,7 +6,7 @@ module SPARQL; module Algebra
6
6
  # @example
7
7
  # (path+ :p)
8
8
  #
9
- # @see http://www.w3.org/TR/sparql11-query/#defn_evalPP_OneOrMorePath
9
+ # @see https://www.w3.org/TR/sparql11-query/#defn_evalPP_OneOrMorePath
10
10
  class PathPlus < Operator::Unary
11
11
  include Query
12
12
 
@@ -25,8 +25,8 @@ module SPARQL; module Algebra
25
25
  # each matching solution
26
26
  # @yieldparam [RDF::Query::Solution] solution
27
27
  # @yieldreturn [void] ignored
28
- # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
29
- def execute(queryable, options = {}, &block)
28
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
29
+ def execute(queryable, **options, &block)
30
30
  subject, object = options[:subject], options[:object]
31
31
  debug(options) {"Path+ #{[subject, operands, object].to_sse}"}
32
32
 
@@ -53,7 +53,7 @@ module SPARQL; module Algebra
53
53
  # Keep track of solutions
54
54
  # Recurse into query
55
55
  immediate_solutions = []
56
- queryable.query(query, options.merge(depth: options[:depth].to_i + 1)) do |solution|
56
+ queryable.query(query, depth: options[:depth].to_i + 1, **options) do |solution|
57
57
  immediate_solutions << solution
58
58
  end
59
59
 
@@ -66,23 +66,23 @@ module SPARQL; module Algebra
66
66
  case
67
67
  when subject.variable? && object.variable?
68
68
  # Query starting with bound object as subject, but replace result with subject
69
- rs = queryable.query(self, options.merge(
69
+ rs = queryable.query(self, **options.merge(
70
70
  subject: solution[object],
71
71
  accumulator: (cumulative_solutions + immediate_solutions),
72
72
  depth: options[:depth].to_i + 1)).map {|s| s.merge(subject.to_sym => solution[subject])}
73
73
  # Query starting with bound subject as object, but replace result with subject
74
- ro = queryable.query(self, options.merge(
74
+ ro = queryable.query(self, **options.merge(
75
75
  object: solution[subject],
76
76
  accumulator: (cumulative_solutions + immediate_solutions),
77
77
  depth: options[:depth].to_i + 1)).map {|s| s.merge(object.to_sym => solution[object])}
78
78
  recursive_solutions += (rs + ro).uniq
79
79
  when subject.variable?
80
- recursive_solutions += queryable.query(self, options.merge(
80
+ recursive_solutions += queryable.query(self, **options.merge(
81
81
  object: solution[subject],
82
82
  accumulator: (cumulative_solutions + immediate_solutions),
83
83
  depth: options[:depth].to_i + 1)).uniq
84
84
  when object.variable?
85
- recursive_solutions += queryable.query(self, options.merge(
85
+ recursive_solutions += queryable.query(self, **options.merge(
86
86
  subject: solution[object],
87
87
  accumulator: (cumulative_solutions + immediate_solutions),
88
88
  depth: options[:depth].to_i + 1)).uniq
@@ -6,7 +6,7 @@ module SPARQL; module Algebra
6
6
  # @example
7
7
  # (path* :p)
8
8
  #
9
- # @see http://www.w3.org/TR/sparql11-query/#defn_evalPP_ZeroOrMorePath
9
+ # @see https://www.w3.org/TR/sparql11-query/#defn_evalPP_ZeroOrMorePath
10
10
  class PathStar < Operator::Unary
11
11
  include Query
12
12
 
@@ -28,14 +28,14 @@ module SPARQL; module Algebra
28
28
  # each matching solution
29
29
  # @yieldparam [RDF::Query::Solution] solution
30
30
  # @yieldreturn [void] ignored
31
- # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
32
- def execute(queryable, options = {}, &block)
31
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
32
+ def execute(queryable, **options, &block)
33
33
  subject, object = options[:subject], options[:object]
34
34
  debug(options) {"Path* #{[subject, operands, object].to_sse}"}
35
35
 
36
36
  # (:x :p* :y) => (:x (:p+)? :y)
37
37
  query = PathOpt.new(PathPlus.new(*operands))
38
- query.execute(queryable, options.merge(depth: options[:depth].to_i + 1), &block)
38
+ query.execute(queryable, depth: options[:depth].to_i + 1, **options, &block)
39
39
  end
40
40
  end # PathStar
41
41
  end # Operator
@@ -7,9 +7,9 @@ module SPARQL; module Algebra
7
7
  # (+ ?x ?y)
8
8
  # (plus ?x ?y)
9
9
  #
10
- # @see http://www.w3.org/TR/xpath-functions/#func-numeric-unary-plus
11
- # @see http://www.w3.org/TR/xpath-functions/#func-numeric-add
12
- class Plus < Operator::Unary
10
+ # @see https://www.w3.org/TR/xpath-functions/#func-numeric-unary-plus
11
+ # @see https://www.w3.org/TR/xpath-functions/#func-numeric-add
12
+ class Plus < Operator
13
13
  include Evaluatable
14
14
 
15
15
  NAME = [:+, :plus]