sparql 3.1.6 → 3.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/sparql/algebra/aggregate.rb +1 -1
- data/lib/sparql/algebra/evaluatable.rb +4 -4
- data/lib/sparql/algebra/operator.rb +2 -2
- data/lib/sparql/algebra/operator/abs.rb +1 -1
- data/lib/sparql/algebra/operator/avg.rb +1 -1
- data/lib/sparql/algebra/operator/bnode.rb +1 -1
- data/lib/sparql/algebra/operator/ceil.rb +1 -1
- data/lib/sparql/algebra/operator/compare.rb +39 -40
- data/lib/sparql/algebra/operator/contains.rb +1 -1
- data/lib/sparql/algebra/operator/count.rb +1 -1
- data/lib/sparql/algebra/operator/datatype.rb +1 -1
- data/lib/sparql/algebra/operator/day.rb +1 -1
- data/lib/sparql/algebra/operator/divide.rb +1 -1
- data/lib/sparql/algebra/operator/encode_for_uri.rb +1 -1
- data/lib/sparql/algebra/operator/equal.rb +1 -1
- data/lib/sparql/algebra/operator/floor.rb +1 -1
- data/lib/sparql/algebra/operator/greater_than.rb +3 -2
- data/lib/sparql/algebra/operator/greater_than_or_equal.rb +2 -2
- data/lib/sparql/algebra/operator/group_concat.rb +1 -1
- data/lib/sparql/algebra/operator/hours.rb +1 -1
- data/lib/sparql/algebra/operator/iri.rb +1 -1
- data/lib/sparql/algebra/operator/is_blank.rb +1 -1
- data/lib/sparql/algebra/operator/is_iri.rb +1 -1
- data/lib/sparql/algebra/operator/is_literal.rb +1 -1
- data/lib/sparql/algebra/operator/is_numeric.rb +1 -1
- data/lib/sparql/algebra/operator/is_triple.rb +1 -1
- data/lib/sparql/algebra/operator/lang.rb +1 -1
- data/lib/sparql/algebra/operator/lang_matches.rb +1 -1
- data/lib/sparql/algebra/operator/lcase.rb +1 -1
- data/lib/sparql/algebra/operator/less_than.rb +3 -2
- data/lib/sparql/algebra/operator/less_than_or_equal.rb +2 -2
- data/lib/sparql/algebra/operator/max.rb +1 -1
- data/lib/sparql/algebra/operator/md5.rb +1 -1
- data/lib/sparql/algebra/operator/min.rb +1 -1
- data/lib/sparql/algebra/operator/minutes.rb +1 -1
- data/lib/sparql/algebra/operator/month.rb +1 -1
- data/lib/sparql/algebra/operator/multiply.rb +1 -1
- data/lib/sparql/algebra/operator/negate.rb +1 -1
- data/lib/sparql/algebra/operator/not.rb +1 -1
- data/lib/sparql/algebra/operator/not_equal.rb +3 -1
- data/lib/sparql/algebra/operator/now.rb +1 -1
- data/lib/sparql/algebra/operator/object.rb +1 -1
- data/lib/sparql/algebra/operator/order.rb +7 -1
- data/lib/sparql/algebra/operator/plus.rb +1 -1
- data/lib/sparql/algebra/operator/predicate.rb +1 -1
- data/lib/sparql/algebra/operator/rand.rb +1 -1
- data/lib/sparql/algebra/operator/regex.rb +1 -1
- data/lib/sparql/algebra/operator/replace.rb +1 -1
- data/lib/sparql/algebra/operator/round.rb +1 -1
- data/lib/sparql/algebra/operator/same_term.rb +1 -1
- data/lib/sparql/algebra/operator/sample.rb +1 -1
- data/lib/sparql/algebra/operator/seconds.rb +1 -1
- data/lib/sparql/algebra/operator/sha1.rb +1 -1
- data/lib/sparql/algebra/operator/sha256.rb +1 -1
- data/lib/sparql/algebra/operator/sha384.rb +1 -1
- data/lib/sparql/algebra/operator/sha512.rb +1 -1
- data/lib/sparql/algebra/operator/str.rb +1 -1
- data/lib/sparql/algebra/operator/strafter.rb +1 -1
- data/lib/sparql/algebra/operator/strbefore.rb +1 -1
- data/lib/sparql/algebra/operator/strdt.rb +1 -1
- data/lib/sparql/algebra/operator/strends.rb +1 -1
- data/lib/sparql/algebra/operator/strlang.rb +1 -1
- data/lib/sparql/algebra/operator/strlen.rb +1 -1
- data/lib/sparql/algebra/operator/strstarts.rb +1 -1
- data/lib/sparql/algebra/operator/struuid.rb +1 -1
- data/lib/sparql/algebra/operator/subject.rb +1 -1
- data/lib/sparql/algebra/operator/substr.rb +1 -1
- data/lib/sparql/algebra/operator/subtract.rb +1 -1
- data/lib/sparql/algebra/operator/sum.rb +1 -1
- data/lib/sparql/algebra/operator/timezone.rb +1 -1
- data/lib/sparql/algebra/operator/triple.rb +1 -1
- data/lib/sparql/algebra/operator/tz.rb +1 -1
- data/lib/sparql/algebra/operator/ucase.rb +1 -1
- data/lib/sparql/algebra/operator/uuid.rb +1 -1
- data/lib/sparql/algebra/operator/year.rb +1 -1
- data/lib/sparql/grammar/meta.rb +334 -138
- data/lib/sparql/grammar/parser11.rb +16 -1
- metadata +5 -5
@@ -24,8 +24,8 @@ module SPARQL; module Algebra
|
|
24
24
|
# a literal
|
25
25
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
26
26
|
# @raise [TypeError] if either operand is not a literal
|
27
|
-
def apply(left, right)
|
28
|
-
super
|
27
|
+
def apply(left, right, **options)
|
28
|
+
RDF::Literal(super <= RDF::Literal(0))
|
29
29
|
end
|
30
30
|
end # LessThanOrEqual
|
31
31
|
end # Operator
|
@@ -31,7 +31,7 @@ module SPARQL; module Algebra
|
|
31
31
|
# @param [Enumerable<Array<RDF::Term>>] enum
|
32
32
|
# enum of evaluated operand
|
33
33
|
# @return [RDF::Literal] The maximum value of the terms
|
34
|
-
def apply(enum)
|
34
|
+
def apply(enum, **options)
|
35
35
|
# FIXME: we don't actually do anything with distinct
|
36
36
|
operands.shift if distinct = (operands.first == :distinct)
|
37
37
|
if enum.empty?
|
@@ -26,7 +26,7 @@ module SPARQL; module Algebra
|
|
26
26
|
# the operand
|
27
27
|
# @return [RDF::Literal]
|
28
28
|
# @raise [TypeError] if the operand is not a simple literal
|
29
|
-
def apply(operand)
|
29
|
+
def apply(operand, **options)
|
30
30
|
raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}" unless operand.literal?
|
31
31
|
raise TypeError, "expected simple literal or xsd:string, but got #{operand.inspect}" unless (operand.datatype || RDF::XSD.string) == RDF::XSD.string
|
32
32
|
RDF::Literal(Digest::MD5.new.hexdigest(operand.to_s))
|
@@ -31,7 +31,7 @@ module SPARQL; module Algebra
|
|
31
31
|
# @param [Enumerable<Array<RDF::Term>>] enum
|
32
32
|
# enum of evaluated operand
|
33
33
|
# @return [RDF::Literal] The maximum value of the terms
|
34
|
-
def apply(enum)
|
34
|
+
def apply(enum, **options)
|
35
35
|
# FIXME: we don't actually do anything with distinct
|
36
36
|
operands.shift if distinct = (operands.first == :distinct)
|
37
37
|
if enum.empty?
|
@@ -24,7 +24,7 @@ module SPARQL; module Algebra
|
|
24
24
|
# the operand
|
25
25
|
# @return [RDF::Literal]
|
26
26
|
# @raise [TypeError] if the operand is not a simple literal
|
27
|
-
def apply(operand)
|
27
|
+
def apply(operand, **options)
|
28
28
|
raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime)
|
29
29
|
RDF::Literal(operand.object.minute)
|
30
30
|
end
|
@@ -24,7 +24,7 @@ module SPARQL; module Algebra
|
|
24
24
|
# the operand
|
25
25
|
# @return [RDF::Literal]
|
26
26
|
# @raise [TypeError] if the operand is not a simple literal
|
27
|
-
def apply(operand)
|
27
|
+
def apply(operand, **options)
|
28
28
|
raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime)
|
29
29
|
RDF::Literal(operand.object.month)
|
30
30
|
end
|
@@ -22,7 +22,7 @@ module SPARQL; module Algebra
|
|
22
22
|
# a numeric literal
|
23
23
|
# @return [RDF::Literal::Numeric]
|
24
24
|
# @raise [TypeError] if either operand is not a numeric literal
|
25
|
-
def apply(left, right)
|
25
|
+
def apply(left, right, **options)
|
26
26
|
case
|
27
27
|
when left.is_a?(RDF::Literal::Numeric) && right.is_a?(RDF::Literal::Numeric)
|
28
28
|
left * right
|
@@ -20,7 +20,7 @@ module SPARQL; module Algebra
|
|
20
20
|
# a numeric literal
|
21
21
|
# @return [RDF::Literal::Numeric]
|
22
22
|
# @raise [TypeError] if the operand is not a numeric literal
|
23
|
-
def apply(term)
|
23
|
+
def apply(term, **options)
|
24
24
|
case term
|
25
25
|
when RDF::Literal::Numeric then -term
|
26
26
|
else raise TypeError, "expected an RDF::Literal::Numeric, but got #{term.inspect}"
|
@@ -23,7 +23,7 @@ module SPARQL; module Algebra
|
|
23
23
|
# the operand
|
24
24
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
25
25
|
# @raise [TypeError] if the operand could not be coerced to a boolean literal
|
26
|
-
def apply(operand)
|
26
|
+
def apply(operand, **options)
|
27
27
|
case bool = boolean(operand)
|
28
28
|
when RDF::Literal::Boolean
|
29
29
|
RDF::Literal(bool.false?)
|
@@ -12,13 +12,15 @@ module SPARQL; module Algebra
|
|
12
12
|
# Returns `true` if the operands are not equal; returns `false`
|
13
13
|
# otherwise.
|
14
14
|
#
|
15
|
+
# Comparing unknown datatypes might have different lexical forms but be the same value.
|
16
|
+
#
|
15
17
|
# @param [RDF::Term] term1
|
16
18
|
# an RDF term
|
17
19
|
# @param [RDF::Term] term2
|
18
20
|
# an RDF term
|
19
21
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
20
22
|
# @raise [TypeError] if either operand is not an RDF term
|
21
|
-
def apply(term1, term2)
|
23
|
+
def apply(term1, term2, **options)
|
22
24
|
RDF::Literal(super.false?)
|
23
25
|
end
|
24
26
|
end # NotEqual
|
@@ -23,7 +23,7 @@ module SPARQL; module Algebra
|
|
23
23
|
# 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.
|
24
24
|
#
|
25
25
|
# @return [RDF::Literal::Double] random value
|
26
|
-
def apply
|
26
|
+
def apply(**options)
|
27
27
|
RDF::Literal(DateTime.now)
|
28
28
|
end
|
29
29
|
end # Now
|
@@ -18,7 +18,7 @@ module SPARQL; module Algebra
|
|
18
18
|
# the operand
|
19
19
|
# @return [RDF::Literal]
|
20
20
|
# @raise [TypeError] if the operand is not a statement
|
21
|
-
def apply(operand)
|
21
|
+
def apply(operand, **options)
|
22
22
|
raise TypeError, "expected an RDF::Statement, but got #{operand.inspect}" unless operand.is_a?(RDF::Statement)
|
23
23
|
operand.object
|
24
24
|
end
|
@@ -40,7 +40,13 @@ module SPARQL; module Algebra
|
|
40
40
|
memo = begin
|
41
41
|
a_eval = op.evaluate(a, queryable: queryable, depth: options[:depth].to_i + 1, **options) rescue nil
|
42
42
|
b_eval = op.evaluate(b, queryable: queryable, depth: options[:depth].to_i + 1, **options) rescue nil
|
43
|
-
comp =
|
43
|
+
comp = begin
|
44
|
+
Operator::Compare.evaluate(a_eval, b_eval, order_by: true).to_s.to_i
|
45
|
+
rescue TypeError
|
46
|
+
# Type sError is effectively zero
|
47
|
+
debug(options) {"(order) rescue(#{$!}): #{a_eval.inspect}, #{b_eval.inspect}"}
|
48
|
+
RDF::Literal(0)
|
49
|
+
end
|
44
50
|
comp = -comp if op.is_a?(Operator::Desc)
|
45
51
|
comp
|
46
52
|
end if memo == 0
|
@@ -23,7 +23,7 @@ module SPARQL; module Algebra
|
|
23
23
|
# a numeric literal
|
24
24
|
# @return [RDF::Literal::Numeric]
|
25
25
|
# @raise [TypeError] if either operand is not a numeric literal
|
26
|
-
def apply(left, right = nil)
|
26
|
+
def apply(left, right = nil, **options)
|
27
27
|
case
|
28
28
|
when left.is_a?(RDF::Literal::Numeric) && right.is_a?(RDF::Literal::Numeric)
|
29
29
|
left + right
|
@@ -18,7 +18,7 @@ module SPARQL; module Algebra
|
|
18
18
|
# the operand
|
19
19
|
# @return [RDF::Literal]
|
20
20
|
# @raise [TypeError] if the operand is not a statement
|
21
|
-
def apply(operand)
|
21
|
+
def apply(operand, **options)
|
22
22
|
raise TypeError, "expected an RDF::Statement, but got #{operand.inspect}" unless operand.is_a?(RDF::Statement)
|
23
23
|
operand.predicate
|
24
24
|
end
|
@@ -18,7 +18,7 @@ module SPARQL; module Algebra
|
|
18
18
|
# 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.
|
19
19
|
#
|
20
20
|
# @return [RDF::Literal::Double] random value
|
21
|
-
def apply
|
21
|
+
def apply(**options)
|
22
22
|
RDF::Literal::Double.new(Random.rand)
|
23
23
|
end
|
24
24
|
end # Rand
|
@@ -42,7 +42,7 @@ module SPARQL; module Algebra
|
|
42
42
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
43
43
|
# @raise [TypeError] if any operand is unbound
|
44
44
|
# @raise [TypeError] if any operand is not a simple literal
|
45
|
-
def apply(text, pattern, flags = RDF::Literal(''))
|
45
|
+
def apply(text, pattern, flags = RDF::Literal(''), **options)
|
46
46
|
# @see https://www.w3.org/TR/xpath-functions/#regex-syntax
|
47
47
|
raise TypeError, "expected a plain RDF::Literal, but got #{text.inspect}" unless text.is_a?(RDF::Literal) && text.plain?
|
48
48
|
text = text.to_s
|
@@ -42,7 +42,7 @@ module SPARQL; module Algebra
|
|
42
42
|
# @return [RDF::Literal]
|
43
43
|
# @raise [TypeError] if any operand is unbound
|
44
44
|
# @raise [TypeError] if any operand is not a plain literal
|
45
|
-
def apply(text, pattern, replacement, flags = RDF::Literal(''))
|
45
|
+
def apply(text, pattern, replacement, flags = RDF::Literal(''), **options)
|
46
46
|
raise TypeError, "expected a plain RDF::Literal, but got #{text.inspect}" unless text.literal? && text.plain?
|
47
47
|
# TODO: validate text syntax
|
48
48
|
|
@@ -22,7 +22,7 @@ module SPARQL; module Algebra
|
|
22
22
|
# the operand
|
23
23
|
# @return [RDF::Literal] literal of same type
|
24
24
|
# @raise [TypeError] if the operand is not a numeric value
|
25
|
-
def apply(operand)
|
25
|
+
def apply(operand, **options)
|
26
26
|
case operand
|
27
27
|
when RDF::Literal::Numeric then operand.round
|
28
28
|
else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}"
|
@@ -26,7 +26,7 @@ module SPARQL; module Algebra
|
|
26
26
|
# an RDF term
|
27
27
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
28
28
|
# @raise [TypeError] if either operand is unbound
|
29
|
-
def apply(term1, term2)
|
29
|
+
def apply(term1, term2, **options)
|
30
30
|
RDF::Literal(term1.eql?(term2))
|
31
31
|
end
|
32
32
|
|
@@ -31,7 +31,7 @@ module SPARQL; module Algebra
|
|
31
31
|
# enum of evaluated operand
|
32
32
|
# @return [RDF::Term] An arbitrary term
|
33
33
|
# @raise [TypeError] If enum is empty
|
34
|
-
def apply(enum)
|
34
|
+
def apply(enum, **options)
|
35
35
|
enum.detect(lambda {raise TypeError, "Sampling an empty multiset"}) {|e| e.first}.first
|
36
36
|
end
|
37
37
|
end # LCase
|
@@ -24,7 +24,7 @@ module SPARQL; module Algebra
|
|
24
24
|
# the operand
|
25
25
|
# @return [RDF::Literal]
|
26
26
|
# @raise [TypeError] if the operand is not a simple literal
|
27
|
-
def apply(operand)
|
27
|
+
def apply(operand, **options)
|
28
28
|
raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime)
|
29
29
|
RDF::Literal(operand.object.second)
|
30
30
|
end
|
@@ -26,7 +26,7 @@ module SPARQL; module Algebra
|
|
26
26
|
# the operand
|
27
27
|
# @return [RDF::Literal]
|
28
28
|
# @raise [TypeError] if the operand is not a simple literal
|
29
|
-
def apply(operand)
|
29
|
+
def apply(operand, **options)
|
30
30
|
raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}" unless operand.literal?
|
31
31
|
raise TypeError, "expected simple literal or xsd:string, but got #{operand.inspect}" unless (operand.datatype || RDF::XSD.string) == RDF::XSD.string
|
32
32
|
RDF::Literal(Digest::SHA1.new.hexdigest(operand.to_s))
|
@@ -26,7 +26,7 @@ module SPARQL; module Algebra
|
|
26
26
|
# the operand
|
27
27
|
# @return [RDF::Literal]
|
28
28
|
# @raise [TypeError] if the operand is not a simple literal
|
29
|
-
def apply(operand)
|
29
|
+
def apply(operand, **options)
|
30
30
|
raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}" unless operand.literal?
|
31
31
|
raise TypeError, "expected simple literal or xsd:string, but got #{operand.inspect}" unless (operand.datatype || RDF::XSD.string) == RDF::XSD.string
|
32
32
|
RDF::Literal(Digest::SHA256.new.hexdigest(operand.to_s))
|
@@ -26,7 +26,7 @@ module SPARQL; module Algebra
|
|
26
26
|
# the operand
|
27
27
|
# @return [RDF::Literal]
|
28
28
|
# @raise [TypeError] if the operand is not a simple literal
|
29
|
-
def apply(operand)
|
29
|
+
def apply(operand, **options)
|
30
30
|
raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}" unless operand.literal?
|
31
31
|
raise TypeError, "expected simple literal or xsd:string, but got #{operand.inspect}" unless (operand.datatype || RDF::XSD.string) == RDF::XSD.string
|
32
32
|
RDF::Literal(Digest::SHA384.new.hexdigest(operand.to_s))
|
@@ -26,7 +26,7 @@ module SPARQL; module Algebra
|
|
26
26
|
# the operand
|
27
27
|
# @return [RDF::Literal]
|
28
28
|
# @raise [TypeError] if the operand is not a simple literal
|
29
|
-
def apply(operand)
|
29
|
+
def apply(operand, **options)
|
30
30
|
raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}" unless operand.literal?
|
31
31
|
raise TypeError, "expected simple literal or xsd:string, but got #{operand.inspect}" unless (operand.datatype || RDF::XSD.string) == RDF::XSD.string
|
32
32
|
RDF::Literal(Digest::SHA512.new.hexdigest(operand.to_s))
|
@@ -23,7 +23,7 @@ module SPARQL; module Algebra
|
|
23
23
|
# a literal or IRI
|
24
24
|
# @return [RDF::Literal] a simple literal
|
25
25
|
# @raise [TypeError] if the operand is not a literal or IRI
|
26
|
-
def apply(term)
|
26
|
+
def apply(term, **options)
|
27
27
|
case term
|
28
28
|
when RDF::Literal then RDF::Literal(term.value)
|
29
29
|
when RDF::URI then RDF::Literal(term.to_s)
|
@@ -37,7 +37,7 @@ module SPARQL; module Algebra
|
|
37
37
|
# a literal
|
38
38
|
# @return [RDF::Literal]
|
39
39
|
# @raise [TypeError] if operands are not compatible
|
40
|
-
def apply(left, right)
|
40
|
+
def apply(left, right, **options)
|
41
41
|
case
|
42
42
|
when !left.compatible?(right)
|
43
43
|
raise TypeError, "expected two RDF::Literal operands, but got #{left.inspect} and #{right.inspect}"
|
@@ -37,7 +37,7 @@ module SPARQL; module Algebra
|
|
37
37
|
# a literal
|
38
38
|
# @return [RDF::Literal]
|
39
39
|
# @raise [TypeError] if operands are not compatible
|
40
|
-
def apply(left, right)
|
40
|
+
def apply(left, right, **options)
|
41
41
|
case
|
42
42
|
when !left.plain? || !right.plain?
|
43
43
|
raise TypeError, "expected two RDF::Literal operands, but got #{left.inspect} and #{right.inspect}"
|
@@ -24,7 +24,7 @@ module SPARQL; module Algebra
|
|
24
24
|
# datatype
|
25
25
|
# @return [RDF::Literal] a datatyped literal
|
26
26
|
# @see https://www.w3.org/TR/sparql11-query/#func-strdt
|
27
|
-
def apply(value, datatypeIRI)
|
27
|
+
def apply(value, datatypeIRI, **options)
|
28
28
|
raise TypeError, "Literal #{value.inspect} is not simple" unless value.simple?
|
29
29
|
RDF::Literal.new(value.to_s, datatype: datatypeIRI)
|
30
30
|
end
|
@@ -33,7 +33,7 @@ module SPARQL; module Algebra
|
|
33
33
|
# a literal
|
34
34
|
# @return [RDF::Literal::Boolean]
|
35
35
|
# @raise [TypeError] if operands are not compatible
|
36
|
-
def apply(left, right)
|
36
|
+
def apply(left, right, **options)
|
37
37
|
case
|
38
38
|
when !left.compatible?(right)
|
39
39
|
raise TypeError, "expected two RDF::Literal operands, but got #{left.inspect} and #{right.inspect}"
|
@@ -25,7 +25,7 @@ module SPARQL; module Algebra
|
|
25
25
|
# datatype
|
26
26
|
# @return [RDF::Literal] a datatyped literal
|
27
27
|
# @see https://www.w3.org/TR/sparql11-query/#func-strlang
|
28
|
-
def apply(value, langTag)
|
28
|
+
def apply(value, langTag, **options)
|
29
29
|
raise TypeError, "Literal #{value.inspect} is not simple" unless value.simple?
|
30
30
|
RDF::Literal.new(value.to_s, language: langTag.to_s)
|
31
31
|
end
|
@@ -25,7 +25,7 @@ module SPARQL; module Algebra
|
|
25
25
|
# the operand
|
26
26
|
# @return [RDF::Literal::Integer] length of string
|
27
27
|
# @raise [TypeError] if the operand is not a numeric value
|
28
|
-
def apply(operand)
|
28
|
+
def apply(operand, **options)
|
29
29
|
raise TypeError, "expected a plain RDF::Literal, but got #{operand.inspect}" unless operand.literal? && operand.plain?
|
30
30
|
RDF::Literal(operand.to_s.length)
|
31
31
|
end
|
@@ -33,7 +33,7 @@ module SPARQL; module Algebra
|
|
33
33
|
# a literal
|
34
34
|
# @return [RDF::Literal::Boolean]
|
35
35
|
# @raise [TypeError] if operands are not compatible
|
36
|
-
def apply(left, right)
|
36
|
+
def apply(left, right, **options)
|
37
37
|
case
|
38
38
|
when !left.compatible?(right)
|
39
39
|
raise TypeError, "expected two RDF::Literal operands, but got #{left.inspect} and #{right.inspect}"
|
@@ -24,7 +24,7 @@ module SPARQL; module Algebra
|
|
24
24
|
# Return a string that is the scheme specific part of UUID. That is, as a simple literal, the result of generating a UUID, converting to a simple literal and removing the initial urn:uuid:.
|
25
25
|
#
|
26
26
|
# @return [RDF::URI]
|
27
|
-
def apply
|
27
|
+
def apply(**options)
|
28
28
|
RDF::Literal(SecureRandom.uuid)
|
29
29
|
end
|
30
30
|
end # StrUUID
|
@@ -20,7 +20,7 @@ module SPARQL; module Algebra
|
|
20
20
|
# the operand
|
21
21
|
# @return [RDF::Literal]
|
22
22
|
# @raise [TypeError] if the operand is not a statement
|
23
|
-
def apply(operand)
|
23
|
+
def apply(operand, **options)
|
24
24
|
raise TypeError, "expected an RDF::Statement, but got #{operand.inspect}" unless operand.is_a?(RDF::Statement)
|
25
25
|
operand.subject
|
26
26
|
end
|
@@ -49,7 +49,7 @@ module SPARQL; module Algebra
|
|
49
49
|
# an optional length of the substring.
|
50
50
|
# @return [RDF::Literal]
|
51
51
|
# @raise [TypeError] if operands are not compatible
|
52
|
-
def apply(source, startingLoc, length)
|
52
|
+
def apply(source, startingLoc, length, **options)
|
53
53
|
raise TypeError, "expected a plain RDF::Literal, but got #{source.inspect}" unless source.literal? && source.plain?
|
54
54
|
text = text.to_s
|
55
55
|
|
@@ -20,7 +20,7 @@ module SPARQL; module Algebra
|
|
20
20
|
# a numeric literal
|
21
21
|
# @return [RDF::Literal::Numeric]
|
22
22
|
# @raise [TypeError] if either operand is not a numeric literal
|
23
|
-
def apply(left, right)
|
23
|
+
def apply(left, right, **options)
|
24
24
|
case
|
25
25
|
when left.is_a?(RDF::Literal::Numeric) && right.is_a?(RDF::Literal::Numeric)
|
26
26
|
left - right
|
@@ -22,7 +22,7 @@ module SPARQL; module Algebra
|
|
22
22
|
# @param [Enumerable<Array<RDF::Term>>] enum
|
23
23
|
# enum of evaluated operand
|
24
24
|
# @return [RDF::Literal::Numeric] The sum of the terms
|
25
|
-
def apply(enum)
|
25
|
+
def apply(enum, **options)
|
26
26
|
# FIXME: we don't actually do anything with distinct
|
27
27
|
operands.shift if distinct = (operands.first == :distinct)
|
28
28
|
if enum.empty?
|
@@ -26,7 +26,7 @@ module SPARQL; module Algebra
|
|
26
26
|
# the operand
|
27
27
|
# @return [RDF::Literal]
|
28
28
|
# @raise [TypeError] if the operand is not a simple literal
|
29
|
-
def apply(operand)
|
29
|
+
def apply(operand, **options)
|
30
30
|
raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime)
|
31
31
|
raise TypeError, "literal has no timezone" unless res = operand.timezone
|
32
32
|
res
|
@@ -17,7 +17,7 @@ module SPARQL; module Algebra
|
|
17
17
|
# @param [RDF::Term] object
|
18
18
|
# @return [RDF::URI]
|
19
19
|
# @raise [TypeError] if the operand is not a simple literal
|
20
|
-
def apply(subject, predicate, object)
|
20
|
+
def apply(subject, predicate, object, **options)
|
21
21
|
triple = RDF::Statement(subject, predicate, object)
|
22
22
|
raise TypeError, "valid components, but got #{triple.inspect}" unless triple.valid?
|
23
23
|
triple
|
@@ -24,7 +24,7 @@ module SPARQL; module Algebra
|
|
24
24
|
# the operand
|
25
25
|
# @return [RDF::Literal]
|
26
26
|
# @raise [TypeError] if the operand is not a simple literal
|
27
|
-
def apply(operand)
|
27
|
+
def apply(operand, **options)
|
28
28
|
raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime)
|
29
29
|
operand.tz
|
30
30
|
end
|