rdf 1.1.11 → 1.1.12
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.rb +1 -1
- data/lib/rdf/model/value.rb +15 -13
- data/lib/rdf/query.rb +36 -3
- data/lib/rdf/query/pattern.rb +14 -0
- data/lib/rdf/util/file.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 424861a5701eb72e91b109582c0fa5a822a55077
|
4
|
+
data.tar.gz: 6e3bb83de003042827fc25fd5b77522fa957c6a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cab68b2efe3db88ea4f11b71818c2966ccda4f41a3a41aeff008d41535bec2798c4e03e9db39219f767b3255974291243f14aeb5798b5733629e829a5a1bc74d
|
7
|
+
data.tar.gz: e7edd05ebdeec991a7403d26debf884a98ff94dbf74985c77b092aafe61f53bdc7f937b6ac77266d6506cebc01f0de1bbf2b832811ef6a3e9afecd4a55247239
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.12
|
data/lib/rdf.rb
CHANGED
data/lib/rdf/model/value.rb
CHANGED
@@ -37,7 +37,7 @@ module RDF
|
|
37
37
|
end
|
38
38
|
|
39
39
|
##
|
40
|
-
#
|
40
|
+
# Is this a {RDF::Statement}?
|
41
41
|
#
|
42
42
|
# @return [Boolean]
|
43
43
|
def statement?
|
@@ -45,7 +45,7 @@ module RDF
|
|
45
45
|
end
|
46
46
|
|
47
47
|
##
|
48
|
-
#
|
48
|
+
# Is this a {RDF::List}?
|
49
49
|
#
|
50
50
|
# @return [Boolean]
|
51
51
|
def list?
|
@@ -53,7 +53,7 @@ module RDF
|
|
53
53
|
end
|
54
54
|
|
55
55
|
##
|
56
|
-
#
|
56
|
+
# Is this a {RDF::Term}?
|
57
57
|
#
|
58
58
|
# @return [Boolean]
|
59
59
|
def term?
|
@@ -61,7 +61,7 @@ module RDF
|
|
61
61
|
end
|
62
62
|
|
63
63
|
##
|
64
|
-
#
|
64
|
+
# Is this a {RDF::Resource}?
|
65
65
|
#
|
66
66
|
# @return [Boolean]
|
67
67
|
def resource?
|
@@ -69,7 +69,7 @@ module RDF
|
|
69
69
|
end
|
70
70
|
|
71
71
|
##
|
72
|
-
#
|
72
|
+
# Is this a {RDF::Literal}?
|
73
73
|
#
|
74
74
|
# @return [Boolean]
|
75
75
|
def literal?
|
@@ -77,7 +77,7 @@ module RDF
|
|
77
77
|
end
|
78
78
|
|
79
79
|
##
|
80
|
-
#
|
80
|
+
# Is this a {RDF::Node}, or does it contain a node?
|
81
81
|
#
|
82
82
|
# @return [Boolean]
|
83
83
|
def node?
|
@@ -85,7 +85,7 @@ module RDF
|
|
85
85
|
end
|
86
86
|
|
87
87
|
##
|
88
|
-
#
|
88
|
+
# Is this an {RDF::IRI}?
|
89
89
|
#
|
90
90
|
# By default this is simply an alias for {RDF::Value#uri?}.
|
91
91
|
#
|
@@ -95,7 +95,7 @@ module RDF
|
|
95
95
|
end
|
96
96
|
|
97
97
|
##
|
98
|
-
#
|
98
|
+
# Is this an {RDF::URI}?
|
99
99
|
#
|
100
100
|
# @return [Boolean]
|
101
101
|
def uri?
|
@@ -103,7 +103,7 @@ module RDF
|
|
103
103
|
end
|
104
104
|
|
105
105
|
##
|
106
|
-
#
|
106
|
+
# Is this a {RDF::Query::Variable}, or does it contain a variable?
|
107
107
|
#
|
108
108
|
# @return [Boolean]
|
109
109
|
# @since 0.1.7
|
@@ -112,7 +112,9 @@ module RDF
|
|
112
112
|
end
|
113
113
|
|
114
114
|
##
|
115
|
-
#
|
115
|
+
# Is this constant, or are all of its components constant?
|
116
|
+
#
|
117
|
+
# Same as `!variable?`
|
116
118
|
#
|
117
119
|
# @return [Boolean] `true` or `false`
|
118
120
|
# @see #variable?
|
@@ -121,7 +123,7 @@ module RDF
|
|
121
123
|
end
|
122
124
|
|
123
125
|
##
|
124
|
-
# Is this
|
126
|
+
# Is this value named?
|
125
127
|
#
|
126
128
|
# @return [Boolean] `true` or `false`
|
127
129
|
def anonymous?
|
@@ -129,7 +131,7 @@ module RDF
|
|
129
131
|
end
|
130
132
|
|
131
133
|
##
|
132
|
-
#
|
134
|
+
# Is this value valid, and composed only of valid components?
|
133
135
|
#
|
134
136
|
# @return [Boolean] `true` or `false`
|
135
137
|
# @since 0.3.9
|
@@ -138,7 +140,7 @@ module RDF
|
|
138
140
|
end
|
139
141
|
|
140
142
|
##
|
141
|
-
#
|
143
|
+
# Is this value invalid, or is it composed of any invalid components?
|
142
144
|
#
|
143
145
|
# @return [Boolean] `true` or `false`
|
144
146
|
# @since 0.2.1
|
data/lib/rdf/query.rb
CHANGED
@@ -64,10 +64,10 @@ module RDF
|
|
64
64
|
# _:a foaf:name "Alice" .
|
65
65
|
# _:a foaf:mbox <mailto:alice@work.example.org> .
|
66
66
|
#
|
67
|
-
#
|
68
67
|
# @see http://www.w3.org/TR/rdf-sparql-query/#rdfDataset
|
69
68
|
# @since 0.3.0
|
70
69
|
class Query
|
70
|
+
include Enumerable
|
71
71
|
autoload :Pattern, 'rdf/query/pattern'
|
72
72
|
autoload :Solution, 'rdf/query/solution'
|
73
73
|
autoload :Solutions, 'rdf/query/solutions'
|
@@ -313,8 +313,8 @@ module RDF
|
|
313
313
|
unless context.nil?
|
314
314
|
if patterns.empty?
|
315
315
|
patterns = [Pattern.new(nil, nil, nil, :context => context)]
|
316
|
-
|
317
|
-
|
316
|
+
else
|
317
|
+
apply_context(context)
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
@@ -431,6 +431,28 @@ module RDF
|
|
431
431
|
options[:context]
|
432
432
|
end
|
433
433
|
|
434
|
+
# Apply the context specified (or configured) to all patterns that have no context
|
435
|
+
# @param [RDF::IRI, RDF::Query::Variable] context (self.context)
|
436
|
+
def apply_context(context = options[:context])
|
437
|
+
patterns.each {|pattern| pattern.context = context if pattern.context.nil?} unless context.nil?
|
438
|
+
end
|
439
|
+
|
440
|
+
##
|
441
|
+
# Returns `true` if any pattern contains a variable.
|
442
|
+
#
|
443
|
+
# @return [Boolean]
|
444
|
+
def variable?
|
445
|
+
patterns.any?(&:variable?) || context && context.variable?
|
446
|
+
end
|
447
|
+
|
448
|
+
##
|
449
|
+
# Returns `true` if any pattern contains a blank node.
|
450
|
+
#
|
451
|
+
# @return [Boolean]
|
452
|
+
def has_blank_nodes?
|
453
|
+
patterns.any?(&:has_blank_nodes?) || context && context.node?
|
454
|
+
end
|
455
|
+
|
434
456
|
# Query has no patterns
|
435
457
|
# @return [Boolean]
|
436
458
|
def empty?
|
@@ -448,6 +470,17 @@ module RDF
|
|
448
470
|
end
|
449
471
|
alias_method :each, :each_solution
|
450
472
|
|
473
|
+
##
|
474
|
+
# Enumerates over each statement (pattern).
|
475
|
+
#
|
476
|
+
# @yield [RDF::Query::Pattern]
|
477
|
+
# @yieldparam [::Query::Pattern] pattern
|
478
|
+
# @return [Enumerator]
|
479
|
+
def each_statement(&block)
|
480
|
+
apply_context
|
481
|
+
patterns.each(&block)
|
482
|
+
end
|
483
|
+
|
451
484
|
##
|
452
485
|
# Duplicate query, including patterns and solutions
|
453
486
|
# @return [RDF::Query]
|
data/lib/rdf/query/pattern.rb
CHANGED
@@ -231,6 +231,20 @@ module RDF; class Query
|
|
231
231
|
variables
|
232
232
|
end
|
233
233
|
|
234
|
+
##
|
235
|
+
# Binds the pattern to a solution, making it no longer variable if all variables are resolved to bound variables
|
236
|
+
#
|
237
|
+
# @param [RDF::Query::Solution] solution
|
238
|
+
# @return [self]
|
239
|
+
def bind(solution)
|
240
|
+
self.to_quad.each_with_index do |term, index|
|
241
|
+
if term && term.variable? && solution[term]
|
242
|
+
self[index] = solution[term]
|
243
|
+
end
|
244
|
+
end
|
245
|
+
self
|
246
|
+
end
|
247
|
+
|
234
248
|
##
|
235
249
|
# Returns `true` if this pattern contains bindings.
|
236
250
|
#
|
data/lib/rdf/util/file.rb
CHANGED
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: 1.1.
|
4
|
+
version: 1.1.12
|
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: 2015-
|
13
|
+
date: 2015-05-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: link_header
|