rdf 3.1.13 → 3.1.15
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/rdf/model/literal.rb +57 -0
- data/lib/rdf/model/literal/numeric.rb +4 -2
- data/lib/rdf/model/statement.rb +1 -1
- data/lib/rdf/query/pattern.rb +6 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8747674533ca06af62b3ee536ea4342be3c8bedc8831b1a1838e244d927263cb
|
4
|
+
data.tar.gz: fbc0593916678f9f696d4c461b29df01549da5af7d436b700d66735f5350054d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb56f5b72af92421afb2216ca5d1dec10907860a2f1ad069e4d69e37ee3126219dfb0c60fab256c1088424b9a8dcc42f6637e98b1c52258cc88163b394e06fc5
|
7
|
+
data.tar.gz: dcd897b9313decf48df3a89d4e8885ac74da1b966d194c28faa56a2edff2f4b123d093322655985ae1c0c059c6e8e49be9f18bbc9b1ef9c87634394d9090064b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.15
|
data/lib/rdf/model/literal.rb
CHANGED
@@ -308,6 +308,37 @@ module RDF
|
|
308
308
|
end
|
309
309
|
alias_method :===, :==
|
310
310
|
|
311
|
+
##
|
312
|
+
# Compares `self` to `other` for sorting purposes (with type check).
|
313
|
+
#
|
314
|
+
# @param [Object] other
|
315
|
+
# @return [Integer] `-1`, `0`, or `1`
|
316
|
+
def <=>(other)
|
317
|
+
case other
|
318
|
+
when Literal
|
319
|
+
case
|
320
|
+
when self.eql?(other)
|
321
|
+
0
|
322
|
+
when self.language? && other.language?
|
323
|
+
# Literals with languages can compare if languages are identical
|
324
|
+
self.to_s <=> other.to_s
|
325
|
+
when self.simple? && other.simple?
|
326
|
+
self.to_s <=> other.to_s
|
327
|
+
when !self.valid?
|
328
|
+
type_error("#{self.inspect} is invalid") || 0
|
329
|
+
when !other.valid?
|
330
|
+
type_error("#{other.inspect} is invalid") || 0
|
331
|
+
when self.comperable_datatype2?(other)
|
332
|
+
self.object <=> other.object
|
333
|
+
else
|
334
|
+
type_error("#{self.inspect} and #{other.inspect} are not comperable") || 0
|
335
|
+
end
|
336
|
+
when String
|
337
|
+
self.simple? && self.value <=> other
|
338
|
+
else 1
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
311
342
|
##
|
312
343
|
# Returns `true` if this is a plain literal. A plain literal
|
313
344
|
# may have a language, but may not have a datatype. For
|
@@ -399,6 +430,32 @@ module RDF
|
|
399
430
|
end
|
400
431
|
end
|
401
432
|
|
433
|
+
##
|
434
|
+
# Returns `true` if the literal has a datatype and the comparison should
|
435
|
+
# return false instead of raise a type error.
|
436
|
+
#
|
437
|
+
# Used for <=> operator.
|
438
|
+
#
|
439
|
+
# This behavior is intuited from SPARQL data-r2/expr-equal/eq-2-2
|
440
|
+
# @return [Boolean]
|
441
|
+
def comperable_datatype2?(other)
|
442
|
+
case self
|
443
|
+
when RDF::Literal::Numeric, RDF::Literal::Boolean
|
444
|
+
case other
|
445
|
+
when RDF::Literal::Numeric, RDF::Literal::Boolean
|
446
|
+
true
|
447
|
+
else
|
448
|
+
self.plain? || other.plain? ||
|
449
|
+
self.language? || other.language? ||
|
450
|
+
self.datatype == other.datatype
|
451
|
+
end
|
452
|
+
else
|
453
|
+
self.plain? || other.plain? ||
|
454
|
+
self.language? || other.language? ||
|
455
|
+
self.datatype == other.datatype
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
402
459
|
##
|
403
460
|
# Converts this literal into its canonical lexical representation.
|
404
461
|
#
|
@@ -11,6 +11,9 @@ module RDF; class Literal
|
|
11
11
|
# @return [Integer] `-1`, `0`, or `1`
|
12
12
|
# @since 0.3.0
|
13
13
|
def <=>(other)
|
14
|
+
# If lexically invalid, use regular literal testing
|
15
|
+
return super unless self.valid? && (!other.respond_to?(:valid?) || other.valid?)
|
16
|
+
|
14
17
|
case other
|
15
18
|
when ::Numeric
|
16
19
|
to_d <=> other
|
@@ -30,11 +33,10 @@ module RDF; class Literal
|
|
30
33
|
# @since 0.3.0
|
31
34
|
def ==(other)
|
32
35
|
# If lexically invalid, use regular literal testing
|
33
|
-
return super unless self.valid?
|
36
|
+
return super unless self.valid? && (!other.respond_to?(:valid?) || other.valid?)
|
34
37
|
|
35
38
|
case other
|
36
39
|
when Literal::Numeric
|
37
|
-
return super unless other.valid?
|
38
40
|
(cmp = (self <=> other)) ? cmp.zero? : false
|
39
41
|
when RDF::URI, RDF::Node
|
40
42
|
# Interpreting SPARQL data-r2/expr-equal/eq-2-2, numeric can't be compared with other types
|
data/lib/rdf/model/statement.rb
CHANGED
@@ -301,7 +301,7 @@ module RDF
|
|
301
301
|
# @see RDF::Literal#==
|
302
302
|
# @see RDF::Query::Variable#==
|
303
303
|
def eql?(other)
|
304
|
-
other.is_a?(Statement) && self
|
304
|
+
other.is_a?(Statement) && self.to_a.eql?(other.to_a) && (self.graph_name || false) == (other.graph_name || false)
|
305
305
|
end
|
306
306
|
|
307
307
|
##
|
data/lib/rdf/query/pattern.rb
CHANGED
@@ -59,6 +59,12 @@ module RDF; class Query
|
|
59
59
|
super
|
60
60
|
end
|
61
61
|
|
62
|
+
##
|
63
|
+
# Create a new pattern from the quads, recursivly dupping sub-patterns.
|
64
|
+
def dup
|
65
|
+
self.class.from(self.to_quad.map {|t| t.is_a?(RDF::Query::Pattern) ? t.dup : t})
|
66
|
+
end
|
67
|
+
|
62
68
|
##
|
63
69
|
# Any additional options for this pattern.
|
64
70
|
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arto Bendiken
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-06-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: link_header
|
@@ -303,7 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
303
303
|
- !ruby/object:Gem::Version
|
304
304
|
version: '0'
|
305
305
|
requirements: []
|
306
|
-
rubygems_version: 3.2.
|
306
|
+
rubygems_version: 3.2.15
|
307
307
|
signing_key:
|
308
308
|
specification_version: 4
|
309
309
|
summary: A Ruby library for working with Resource Description Framework (RDF) data.
|