sparql 1.99.1 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/VERSION +1 -1
  4. data/lib/sparql.rb +1 -1
  5. data/lib/sparql/algebra.rb +1 -1
  6. data/lib/sparql/algebra/aggregate.rb +1 -4
  7. data/lib/sparql/algebra/extensions.rb +1 -1
  8. data/lib/sparql/algebra/operator.rb +1 -1
  9. data/lib/sparql/algebra/operator/abs.rb +2 -2
  10. data/lib/sparql/algebra/operator/alt.rb +5 -1
  11. data/lib/sparql/algebra/operator/and.rb +4 -7
  12. data/lib/sparql/algebra/operator/asc.rb +1 -1
  13. data/lib/sparql/algebra/operator/ask.rb +4 -2
  14. data/lib/sparql/algebra/operator/base.rb +2 -2
  15. data/lib/sparql/algebra/operator/bgp.rb +1 -1
  16. data/lib/sparql/algebra/operator/bnode.rb +2 -0
  17. data/lib/sparql/algebra/operator/bound.rb +2 -3
  18. data/lib/sparql/algebra/operator/ceil.rb +1 -1
  19. data/lib/sparql/algebra/operator/coalesce.rb +1 -4
  20. data/lib/sparql/algebra/operator/compare.rb +3 -3
  21. data/lib/sparql/algebra/operator/concat.rb +3 -1
  22. data/lib/sparql/algebra/operator/construct.rb +5 -6
  23. data/lib/sparql/algebra/operator/contains.rb +1 -1
  24. data/lib/sparql/algebra/operator/copy.rb +1 -1
  25. data/lib/sparql/algebra/operator/dataset.rb +2 -2
  26. data/lib/sparql/algebra/operator/datatype.rb +1 -1
  27. data/lib/sparql/algebra/operator/day.rb +1 -1
  28. data/lib/sparql/algebra/operator/desc.rb +1 -1
  29. data/lib/sparql/algebra/operator/describe.rb +2 -2
  30. data/lib/sparql/algebra/operator/distinct.rb +2 -2
  31. data/lib/sparql/algebra/operator/encode_for_uri.rb +1 -1
  32. data/lib/sparql/algebra/operator/equal.rb +7 -3
  33. data/lib/sparql/algebra/operator/exists.rb +3 -2
  34. data/lib/sparql/algebra/operator/exprlist.rb +1 -1
  35. data/lib/sparql/algebra/operator/extend.rb +2 -2
  36. data/lib/sparql/algebra/operator/filter.rb +3 -3
  37. data/lib/sparql/algebra/operator/floor.rb +3 -1
  38. data/lib/sparql/algebra/operator/graph.rb +2 -2
  39. data/lib/sparql/algebra/operator/greater_than.rb +1 -1
  40. data/lib/sparql/algebra/operator/greater_than_or_equal.rb +1 -1
  41. data/lib/sparql/algebra/operator/group.rb +1 -1
  42. data/lib/sparql/algebra/operator/group_concat.rb +5 -4
  43. data/lib/sparql/algebra/operator/hours.rb +1 -1
  44. data/lib/sparql/algebra/operator/if.rb +1 -1
  45. data/lib/sparql/algebra/operator/in.rb +3 -5
  46. data/lib/sparql/algebra/operator/iri.rb +5 -5
  47. data/lib/sparql/algebra/operator/is_blank.rb +1 -1
  48. data/lib/sparql/algebra/operator/is_iri.rb +1 -1
  49. data/lib/sparql/algebra/operator/is_literal.rb +1 -1
  50. data/lib/sparql/algebra/operator/join.rb +2 -2
  51. data/lib/sparql/algebra/operator/lang.rb +1 -1
  52. data/lib/sparql/algebra/operator/lang_matches.rb +1 -1
  53. data/lib/sparql/algebra/operator/left_join.rb +2 -2
  54. data/lib/sparql/algebra/operator/less_than.rb +1 -1
  55. data/lib/sparql/algebra/operator/less_than_or_equal.rb +1 -1
  56. data/lib/sparql/algebra/operator/md5.rb +2 -0
  57. data/lib/sparql/algebra/operator/minus.rb +1 -1
  58. data/lib/sparql/algebra/operator/minutes.rb +2 -0
  59. data/lib/sparql/algebra/operator/month.rb +2 -0
  60. data/lib/sparql/algebra/operator/not_equal.rb +2 -2
  61. data/lib/sparql/algebra/operator/notexists.rb +2 -0
  62. data/lib/sparql/algebra/operator/notoneof.rb +1 -1
  63. data/lib/sparql/algebra/operator/now.rb +2 -0
  64. data/lib/sparql/algebra/operator/or.rb +3 -3
  65. data/lib/sparql/algebra/operator/order.rb +2 -2
  66. data/lib/sparql/algebra/operator/path.rb +1 -1
  67. data/lib/sparql/algebra/operator/path_opt.rb +1 -1
  68. data/lib/sparql/algebra/operator/path_plus.rb +1 -1
  69. data/lib/sparql/algebra/operator/path_star.rb +1 -1
  70. data/lib/sparql/algebra/operator/prefix.rb +2 -2
  71. data/lib/sparql/algebra/operator/project.rb +2 -2
  72. data/lib/sparql/algebra/operator/rand.rb +2 -0
  73. data/lib/sparql/algebra/operator/reduced.rb +2 -2
  74. data/lib/sparql/algebra/operator/regex.rb +1 -1
  75. data/lib/sparql/algebra/operator/replace.rb +1 -1
  76. data/lib/sparql/algebra/operator/reverse.rb +1 -1
  77. data/lib/sparql/algebra/operator/round.rb +2 -0
  78. data/lib/sparql/algebra/operator/same_term.rb +1 -1
  79. data/lib/sparql/algebra/operator/seconds.rb +2 -0
  80. data/lib/sparql/algebra/operator/seq.rb +1 -1
  81. data/lib/sparql/algebra/operator/sequence.rb +1 -1
  82. data/lib/sparql/algebra/operator/sha1.rb +2 -0
  83. data/lib/sparql/algebra/operator/sha256.rb +2 -0
  84. data/lib/sparql/algebra/operator/sha384.rb +2 -0
  85. data/lib/sparql/algebra/operator/sha512.rb +2 -0
  86. data/lib/sparql/algebra/operator/slice.rb +2 -2
  87. data/lib/sparql/algebra/operator/str.rb +1 -1
  88. data/lib/sparql/algebra/operator/table.rb +1 -1
  89. data/lib/sparql/algebra/operator/timezone.rb +2 -0
  90. data/lib/sparql/algebra/operator/tz.rb +2 -0
  91. data/lib/sparql/algebra/operator/union.rb +2 -2
  92. data/lib/sparql/algebra/operator/year.rb +2 -0
  93. data/lib/sparql/algebra/query.rb +1 -1
  94. data/lib/sparql/grammar.rb +1 -1
  95. data/lib/sparql/grammar/parser11.rb +14 -15
  96. data/lib/sparql/version.rb +1 -1
  97. metadata +80 -46
@@ -3,6 +3,8 @@ module SPARQL; module Algebra
3
3
  ##
4
4
  # The SPARQL logical `exists` operator.
5
5
  #
6
+ # There is a filter operator EXISTS that takes a graph pattern. EXISTS returns `true`/`false` depending on whether the pattern matches the dataset given the bindings in the current group graph pattern, the dataset and the active graph at this point in the query evaluation. No additional binding of variables occurs. The `NOT EXISTS` form translates into `fn:not(EXISTS{...})`.
7
+ #
6
8
  # @example
7
9
  # (prefix ((ex: <http://www.example.org/>))
8
10
  # (filter (exists
@@ -30,7 +30,7 @@ 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/rdf-sparql-query/#sparqlAlgebra
33
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
34
34
  def execute(queryable, options = {}, &block)
35
35
  debug(options) {"NotOneOf #{operands.to_sse}"}
36
36
  subject, object = options[:subject], options[:object]
@@ -5,6 +5,8 @@ module SPARQL; module Algebra
5
5
  ##
6
6
  # The SPARQL logical `now` operator.
7
7
  #
8
+ # Returns an XSD dateTime value for the current query execution. All calls to this function in any one query execution must return the same value. The exact moment returned is not specified.
9
+ #
8
10
  # @example
9
11
  # (prefix ((xsd: <http://www.w3.org/2001/XMLSchema#>))
10
12
  # (ask (filter (= (datatype ?n) xsd:dateTime)
@@ -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/rdf-sparql-query/#func-logical-or
11
- # @see http://www.w3.org/TR/rdf-sparql-query/#evaluation
10
+ # @see http://www.w3.org/TR/sparql11-query/#func-logical-or
11
+ # @see http://www.w3.org/TR/sparql11-query/#evaluation
12
12
  class Or < Operator::Binary
13
13
  include Evaluatable
14
14
 
@@ -53,7 +53,7 @@ module SPARQL; module Algebra
53
53
  right = nil
54
54
  end
55
55
 
56
- # From http://www.w3.org/TR/rdf-sparql-query/#evaluation
56
+ # From http://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/rdf-sparql-query/#modOrderBy
12
+ # @see http://www.w3.org/TR/sparql11-query/#modOrderBy
13
13
  class Order < Operator::Binary
14
14
  include Query
15
15
 
@@ -30,7 +30,7 @@ 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/rdf-sparql-query/#sparqlAlgebra
33
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
34
34
  def execute(queryable, options = {}, &block)
35
35
 
36
36
  debug(options) {"Order"}
@@ -25,7 +25,7 @@ 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/rdf-sparql-query/#sparqlAlgebra
28
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
29
29
  def execute(queryable, options = {}, &block)
30
30
  debug(options) {"Path #{operands.to_sse}"}
31
31
  subject, path_op, object = operands
@@ -29,7 +29,7 @@ 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/rdf-sparql-query/#sparqlAlgebra
32
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
33
33
  def execute(queryable, options = {}, &block)
34
34
  subject, object = options[:subject], options[:object]
35
35
  debug(options) {"Path? #{[subject, operands, object].to_sse}"}
@@ -25,7 +25,7 @@ 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/rdf-sparql-query/#sparqlAlgebra
28
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
29
29
  def execute(queryable, options = {}, &block)
30
30
  subject, object = options[:subject], options[:object]
31
31
  debug(options) {"Path+ #{[subject, operands, object].to_sse}"}
@@ -28,7 +28,7 @@ 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/rdf-sparql-query/#sparqlAlgebra
31
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
32
32
  def execute(queryable, options = {}, &block)
33
33
  subject, object = options[:subject], options[:object]
34
34
  debug(options) {"Path* #{[subject, operands, object].to_sse}"}
@@ -8,7 +8,7 @@ module SPARQL; module Algebra
8
8
  # (graph ?g
9
9
  # (bgp (triple ?s ?p ?o))))
10
10
  #
11
- # @see http://www.w3.org/TR/rdf-sparql-query/#QSynIRI
11
+ # @see http://www.w3.org/TR/sparql11-query/#QSynIRI
12
12
  class Prefix < Binary
13
13
  include Query
14
14
 
@@ -29,7 +29,7 @@ module SPARQL; module Algebra
29
29
  # @yieldreturn [void] ignored
30
30
  # @return [RDF::Query::Solutions]
31
31
  # the resulting solution sequence
32
- # @see http://www.w3.org/TR/rdf-sparql-query/#sparqlAlgebra
32
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
33
33
  def execute(queryable, options = {}, &block)
34
34
  debug(options) {"Prefix"}
35
35
  @solutions = queryable.query(operands.last, options.merge(depth: options[:depth].to_i + 1), &block)
@@ -9,7 +9,7 @@ module SPARQL; module Algebra
9
9
  # (filter (= ?v 2)
10
10
  # (bgp (triple ?s <http://example/p> ?v)))))
11
11
  #
12
- # @see http://www.w3.org/TR/rdf-sparql-query/#modProjection
12
+ # @see http://www.w3.org/TR/sparql11-query/#modProjection
13
13
  class Project < Operator::Binary
14
14
  include Query
15
15
 
@@ -29,7 +29,7 @@ module SPARQL; module Algebra
29
29
  # @yieldreturn [void] ignored
30
30
  # @return [RDF::Query::Solutions]
31
31
  # the resulting solution sequence
32
- # @see http://www.w3.org/TR/rdf-sparql-query/#sparqlAlgebra
32
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
33
33
  def execute(queryable, options = {}, &block)
34
34
  @solutions = queryable.query(operands.last, options.merge(depth: options[:depth].to_i + 1))
35
35
  @solutions = @solutions.project(*(operands.first))
@@ -3,6 +3,8 @@ module SPARQL; module Algebra
3
3
  ##
4
4
  # The SPARQL logical `rand` operator.
5
5
  #
6
+ # Returns a pseudo-random number between 0 (inclusive) and 1.0e0 (exclusive). Different numbers can be produced every time this function is invoked. Numbers should be produced with approximately equal probability.
7
+ #
6
8
  # @example
7
9
  # (rand)
8
10
  #
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (project (?v)
11
11
  # (bgp (triple ?x ?p ?v)))))
12
12
  #
13
- # @see http://www.w3.org/TR/rdf-sparql-query/#sparqlAlgebra
13
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
14
14
  class Reduced < Operator::Unary
15
15
  include Query
16
16
 
@@ -30,7 +30,7 @@ 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/rdf-sparql-query/#sparqlAlgebra
33
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
34
34
  def execute(queryable, options = {}, &block)
35
35
  @solutions = operands.last.
36
36
  execute(queryable, options.merge(depth: options[:depth].to_i + 1)).reduced
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (filter (regex ?val "GHI")
11
11
  # (bgp (triple ex:foo rdf:value ?val)))))
12
12
  #
13
- # @see http://www.w3.org/TR/rdf-sparql-query/#funcex-regex
13
+ # @see http://www.w3.org/TR/sparql11-query/#funcex-regex
14
14
  # @see http://www.w3.org/TR/xpath-functions/#func-matches
15
15
  class Regex < Operator::Ternary
16
16
  include Evaluatable
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (extend ((?new (replace ?str "[^a-z0-9]" "-")))
11
11
  # (bgp (triple ?s :str ?str)))))
12
12
  #
13
- # @see http://www.w3.org/TR/rdf-sparql-query/#funcex-replace
13
+ # @see http://www.w3.org/TR/sparql11-query/#funcex-replace
14
14
  # @see http://www.w3.org/TR/xpath-functions/#func-replace
15
15
  class Replace < Operator::Quaternary
16
16
  include Evaluatable
@@ -29,7 +29,7 @@ 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/rdf-sparql-query/#sparqlAlgebra
32
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
33
33
  def execute(queryable, options = {}, &block)
34
34
  debug(options) {"Reverse #{operands.to_sse}"}
35
35
  subject, object = options[:subject], options[:object]
@@ -3,6 +3,8 @@ module SPARQL; module Algebra
3
3
  ##
4
4
  # The SPARQL logical `round` operator.
5
5
  #
6
+ # Returns the number with no fractional part that is closest to the argument. If there are two such numbers, then the one that is closest to positive infinity is returned. An error is raised if `arg` is not a numeric value.
7
+ #
6
8
  # @example
7
9
  # (round ?x)
8
10
  #
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (filter (sameTerm ?v)
11
11
  # (bgp (triple ?x :p ?v)))))
12
12
  #
13
- # @see http://www.w3.org/TR/rdf-sparql-query/#func-sameTerm
13
+ # @see http://www.w3.org/TR/sparql11-query/#func-sameTerm
14
14
  class SameTerm < Operator::Binary
15
15
  include Evaluatable
16
16
 
@@ -3,6 +3,8 @@ module SPARQL; module Algebra
3
3
  ##
4
4
  # The SPARQL logical `seconds` operator.
5
5
  #
6
+ # Returns the seconds part of the lexical form of `arg`.
7
+ #
6
8
  # @example
7
9
  # (prefix ((: <http://example.org/>))
8
10
  # (project (?s ?x)
@@ -28,7 +28,7 @@ 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/rdf-sparql-query/#sparqlAlgebra
31
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
32
32
  def execute(queryable, options = {}, &block)
33
33
  subject, object = options[:subject], options[:object]
34
34
  debug(options) {"Seq #{[subject, operands, object].to_sse}"}
@@ -34,7 +34,7 @@ module SPARQL; module Algebra
34
34
  # each matching solution
35
35
  # @yieldparam [RDF::Query::Solution] solution
36
36
  # @yieldreturn [void] ignored
37
- # @see http://www.w3.org/TR/rdf-sparql-query/#sparqlAlgebra
37
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
38
38
  def execute(queryable, options = {})
39
39
  debug(options) {"Sequence #{operands.to_sse}"}
40
40
 
@@ -5,6 +5,8 @@ module SPARQL; module Algebra
5
5
  ##
6
6
  # The SPARQL logical `sha1` operator.
7
7
  #
8
+ # Returns the SHA1 checksum, as a hex digit string, calculated on the UTF-8 representation of the simple literal or lexical form of the `xsd:string`. Hex digits `SHOULD` be in lower case.
9
+ #
8
10
  # @example
9
11
  # (prefix ((: <http://example.org/>))
10
12
  # (project (?hash)
@@ -5,6 +5,8 @@ module SPARQL; module Algebra
5
5
  ##
6
6
  # The SPARQL logical `sha256` operator.
7
7
  #
8
+ # Returns the SHA256 checksum, as a hex digit string, calculated on the UTF-8 representation of the simple literal or lexical form of the `xsd:string`. Hex digits `SHOULD` be in lower case.
9
+ #
8
10
  # @example
9
11
  # (prefix ((: <http://example.org/>))
10
12
  # (project (?hash)
@@ -5,6 +5,8 @@ module SPARQL; module Algebra
5
5
  ##
6
6
  # The SPARQL logical `sha1` operator.
7
7
  #
8
+ # Returns the SHA384 checksum, as a hex digit string, calculated on the UTF-8 representation of the simple literal or lexical form of the `xsd:string`. Hex digits `SHOULD` be in lower case.
9
+ #
8
10
  # @example
9
11
  # (prefix ((: <http://example.org/>))
10
12
  # (project (?hash)
@@ -5,6 +5,8 @@ module SPARQL; module Algebra
5
5
  ##
6
6
  # The SPARQL logical `sha512` operator.
7
7
  #
8
+ # Returns the SHA512 checksum, as a hex digit string, calculated on the UTF-8 representation of the simple literal or lexical form of the `xsd:string`. Hex digits `SHOULD` be in lower case.
9
+ #
8
10
  # @example
9
11
  # (prefix ((: <http://example.org/>))
10
12
  # (project (?hash)
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (order (?v)
11
11
  # (bgp (triple ??0 :num ?v))))))
12
12
  #
13
- # @see http://www.w3.org/TR/rdf-sparql-query/#sparqlAlgebra
13
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
14
14
  class Slice < Operator::Ternary
15
15
  include Query
16
16
 
@@ -42,7 +42,7 @@ module SPARQL; module Algebra
42
42
  # @yieldreturn [void] ignored
43
43
  # @return [RDF::Query::Solutions]
44
44
  # the resulting solution sequence
45
- # @see http://www.w3.org/TR/rdf-sparql-query/#sparqlAlgebra
45
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
46
46
  def execute(queryable, options = {}, &block)
47
47
  offset = operands[0] == :_ ? 0 : operands[0].to_i
48
48
  limit = operands[1] == :_ ? -1 : operands[1].to_i
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (filter (= (str ?v) "1")
11
11
  # (bgp (triple ?x :p ?v)))))
12
12
  #
13
- # @see http://www.w3.org/TR/rdf-sparql-query/#func-str
13
+ # @see http://www.w3.org/TR/sparql11-query/#func-str
14
14
  class Str < Operator::Unary
15
15
  include Evaluatable
16
16
 
@@ -30,7 +30,7 @@ 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/rdf-sparql-query/#sparqlAlgebra
33
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
34
34
  def execute(queryable, options = {}, &block)
35
35
  @solutions = RDF::Query::Solutions()
36
36
  operands[1..-1].each do |row|
@@ -3,6 +3,8 @@ module SPARQL; module Algebra
3
3
  ##
4
4
  # The SPARQL logical `timezone` operator.
5
5
  #
6
+ # Returns the timezone part of `arg` as an xsd:dayTimeDuration. Raises an error if there is no timezone.
7
+ #
6
8
  # @example
7
9
  # (prefix ((: <http://example.org/>))
8
10
  # (project (?s ?x)
@@ -3,6 +3,8 @@ module SPARQL; module Algebra
3
3
  ##
4
4
  # The SPARQL logical `tz` operator.
5
5
  #
6
+ # Returns the timezone part of `arg` as a simple literal. Returns the empty string if there is no timezone.
7
+ #
6
8
  # @example
7
9
  # (prefix ((: <http://example.org/>))
8
10
  # (project (?s ?x)
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (graph ?g
11
11
  # (bgp (triple ?s ?p ?o)))))
12
12
  #
13
- # @see http://www.w3.org/TR/rdf-sparql-query/#sparqlAlgebra
13
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
14
14
  class Union < Operator::Binary
15
15
  include Query
16
16
 
@@ -30,7 +30,7 @@ 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/rdf-sparql-query/#sparqlAlgebra
33
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
34
34
  def execute(queryable, options = {}, &block)
35
35
  debug(options) {"Union"}
36
36
  @solutions = RDF::Query::Solutions(operands.inject([]) do |memo, op|
@@ -3,6 +3,8 @@ module SPARQL; module Algebra
3
3
  ##
4
4
  # The SPARQL logical `year` operator.
5
5
  #
6
+ # Returns the year part of `arg` as an integer.
7
+ #
6
8
  # @example
7
9
  # (prefix ((: <http://example.org/>))
8
10
  # (project (?s ?x)
@@ -49,7 +49,7 @@ module SPARQL; module Algebra
49
49
  # Note, results may be used with {SPARQL.serialize_results} to obtain appropriate output encoding.
50
50
  # @raise [NotImplementedError]
51
51
  # If an attempt is made to perform an unsupported operation
52
- # @see http://www.w3.org/TR/rdf-sparql-query/#sparqlAlgebra
52
+ # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
53
53
  def execute(queryable, options = {}, &block)
54
54
  raise NotImplementedError, "#{self.class}#execute(#{queryable})"
55
55
  end
@@ -154,7 +154,7 @@ module SPARQL
154
154
  # --output lib/sparql/grammar/meta.rb \
155
155
  # etc/sparql11.bnf
156
156
  #
157
- # @see http://www.w3.org/TR/rdf-sparql-query/#grammar
157
+ # @see http://www.w3.org/TR/sparql11-query/#grammar
158
158
  # @see http://rubygems.org/gems/ebnf
159
159
  module Grammar
160
160
  autoload :Parser, 'sparql/grammar/parser11'
@@ -6,7 +6,7 @@ module SPARQL::Grammar
6
6
  ##
7
7
  # A parser for the SPARQL 1.1 grammar.
8
8
  #
9
- # @see http://www.w3.org/TR/rdf-sparql-query/#grammar
9
+ # @see http://www.w3.org/TR/sparql11-query/#grammar
10
10
  # @see http://en.wikipedia.org/wiki/LR_parser
11
11
  class Parser
12
12
  include SPARQL::Grammar::Meta
@@ -490,8 +490,8 @@ module SPARQL::Grammar
490
490
  self.gen_bnodes
491
491
  end
492
492
  production(:DeleteData) do |input, data, callback|
493
- raise Error, "DeleteData contains BNode operands: #{data[:pattern].to_sse}" if data[:pattern].first.node?
494
- input[:update_op] = SPARQL::Algebra::Expression(:deleteData, data[:pattern])
493
+ raise Error, "DeleteData contains BNode operands: #{data[:pattern].to_sse}" if Array(data[:pattern]).any?(&:node?)
494
+ input[:update_op] = SPARQL::Algebra::Expression(:deleteData, Array(data[:pattern]))
495
495
  end
496
496
 
497
497
  # [40] DeleteWhere ::= "DELETE WHERE" QuadPattern
@@ -500,9 +500,9 @@ module SPARQL::Grammar
500
500
  self.gen_bnodes
501
501
  end
502
502
  production(:DeleteWhere) do |input, data, callback|
503
- raise Error, "DeleteWhere contains BNode operands: #{data[:pattern].to_sse}" if data[:pattern].first.node?
503
+ raise Error, "DeleteWhere contains BNode operands: #{data[:pattern].to_sse}" if Array(data[:pattern]).any?(&:node?)
504
504
  self.gen_bnodes(false)
505
- input[:update_op] = SPARQL::Algebra::Expression(:deleteWhere, data[:pattern])
505
+ input[:update_op] = SPARQL::Algebra::Expression(:deleteWhere, Array(data[:pattern]))
506
506
  end
507
507
 
508
508
  # [41] Modify ::= ("WITH" iri)? ( DeleteClause InsertClause? | InsertClause) UsingClause* "WHERE" GroupGraphPattern
@@ -523,9 +523,9 @@ module SPARQL::Grammar
523
523
  self.gen_bnodes
524
524
  end
525
525
  production(:DeleteClause) do |input, data, callback|
526
- raise Error, "DeleteClause contains BNode operands: #{data[:pattern].to_sse}" if data[:pattern].first.node?
526
+ raise Error, "DeleteClause contains BNode operands: #{Array(data[:pattern]).to_sse}" if Array(data[:pattern]).any?(&:node?)
527
527
  self.gen_bnodes(false)
528
- input[:delete] = SPARQL::Algebra::Expression(:delete, data[:pattern])
528
+ input[:delete] = SPARQL::Algebra::Expression(:delete, Array(data[:pattern]))
529
529
  end
530
530
 
531
531
  # [43] InsertClause ::= "INSERT" QuadPattern
@@ -535,7 +535,7 @@ module SPARQL::Grammar
535
535
  end
536
536
  production(:InsertClause) do |input, data, callback|
537
537
  self.gen_bnodes(false)
538
- input[:insert] = SPARQL::Algebra::Expression(:insert, data[:pattern])
538
+ input[:insert] = SPARQL::Algebra::Expression(:insert, Array(data[:pattern]))
539
539
  end
540
540
 
541
541
  # [44] UsingClause ::= "USING" ( iri | "NAMED" iri)
@@ -568,20 +568,19 @@ module SPARQL::Grammar
568
568
  end
569
569
  production(:QuadData) do |input, data, callback|
570
570
  # Transform using statements instead of patterns, and verify there are no variables
571
- raise Error, "QuadData empty" unless data[:pattern]
572
- raise Error, "QuadData contains variable operands: #{data[:pattern].to_sse}" if data[:pattern].first.variable?
571
+ raise Error, "QuadData contains variable operands: #{Array(data[:pattern]).to_sse}" if Array(data[:pattern]).any?(&:variable?)
573
572
  self.gen_bnodes(false)
574
- input[:pattern] = data[:pattern]
573
+ input[:pattern] = Array(data[:pattern])
575
574
  end
576
575
 
577
576
  # [51] QuadsNotTriples ::= "GRAPH" VarOrIri "{" TriplesTemplate? "}"
578
577
  production(:QuadsNotTriples) do |input, data, callback|
579
- add_prod_datum(:pattern, [SPARQL::Algebra::Expression.for(:graph, data[:VarOrIri].last, data[:pattern])])
578
+ add_prod_datum(:pattern, [SPARQL::Algebra::Expression.for(:graph, data[:VarOrIri].last, Array(data[:pattern]))])
580
579
  end
581
580
 
582
581
  # [52] TriplesTemplate ::= TriplesSameSubject ("." TriplesTemplate? )?
583
582
  production(:TriplesTemplate) do |input, data, callback|
584
- add_prod_datum(:pattern, data[:pattern])
583
+ add_prod_datum(:pattern, Array(data[:pattern]))
585
584
  end
586
585
 
587
586
  # [54] GroupGraphPatternSub ::= TriplesBlock? (GraphPatternNotTriples "."? TriplesBlock? )*
@@ -603,7 +602,7 @@ module SPARQL::Grammar
603
602
  # [55] TriplesBlock ::= TriplesSameSubjectPath
604
603
  # ( '.' TriplesBlock? )?
605
604
  production(:TriplesBlock) do |input, data, callback|
606
- if data[:pattern]
605
+ if !Array(data[:pattern]).empty?
607
606
  query = SPARQL::Algebra::Operator::BGP.new
608
607
  Array(data[:pattern]).each {|p| query << p}
609
608
 
@@ -804,7 +803,7 @@ module SPARQL::Grammar
804
803
  production(:ConstructTemplate) do |input, data, callback|
805
804
  # Generate BNodes instead of non-distinguished variables
806
805
  self.gen_bnodes(false)
807
- add_prod_datum(:ConstructTemplate, data[:pattern])
806
+ add_prod_datum(:ConstructTemplate, Array(data[:pattern]))
808
807
  add_prod_datum(:ConstructTemplate, data[:ConstructTemplate])
809
808
  end
810
809