rdf 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/CREDITS +1 -0
- data/README +1 -0
- data/VERSION +1 -1
- data/lib/rdf/model/list.rb +71 -3
- data/lib/rdf/model/statement.rb +2 -3
- data/lib/rdf/nquads.rb +4 -2
- data/lib/rdf/ntriples/format.rb +1 -1
- data/lib/rdf/query/solution.rb +17 -1
- data/lib/rdf/query/solutions.rb +14 -0
- metadata +64 -78
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDhiOWNkYTQ3MGU2ZDJjZDYzM2E0NTg4ODdmODkyYjZmYTc3YWRhNQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MDg3YzA1NjYzZjBiYmM5NGE4ODdmYjE2MDZmOGMxYjVjNzcwM2NkMg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZmY2MzBlOWNiYjMyY2YyMzUyODMzNzliMTM5M2M1YTRkZGNiMTNhOTY1NmE5
|
10
|
+
YWNmMmFlZDY0NjlkY2JiNzY3OTFkNjllYzdmMTYzNzk5MmI1ZGRiOThlNjQ3
|
11
|
+
ZDEyZmU5NTc5NWQ3ZDU5ODM4MjkyN2ZlOTY1NDg2YTMxOGVlMzE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjJiMmQ2MjA1MWQ1OGM0ZmE1ZDM5NmJhNzY1Y2IwYjg2ZGEzYTdhYzZjODI5
|
14
|
+
MTU4NjJiN2ZiN2FmYWRiYTRjYzhjNmRiYWI4NDEzNjQ4ZTc1ODU4YTg4Zjdh
|
15
|
+
NmVjNDk4NDgzODIxYzYwMWYyNThiMGUyNWUyYWU3OWJmNTRmMTI=
|
data/CREDITS
CHANGED
data/README
CHANGED
@@ -334,6 +334,7 @@ follows:
|
|
334
334
|
* [John Fieber](http://github.com/jfieber) - <http://github.com/jfieber>
|
335
335
|
* [Keita Urashima](http://github.com/ursm) - <http://ursm.jp/>
|
336
336
|
* [Pius Uzamere](http://github.com/pius) - <http://pius.me/>
|
337
|
+
* [Judson Lester](https://github.com/nyarly) - <https://github.com/nyarly>
|
337
338
|
|
338
339
|
## Contributing
|
339
340
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.7
|
data/lib/rdf/model/list.rb
CHANGED
@@ -38,10 +38,12 @@ module RDF
|
|
38
38
|
# @yield [list]
|
39
39
|
# @yieldparam [RDF::List] list
|
40
40
|
def initialize(subject = nil, graph = nil, values = nil, &block)
|
41
|
-
@subject = subject || RDF
|
41
|
+
@subject = subject || RDF.nil
|
42
42
|
@graph = graph || RDF::Graph.new
|
43
43
|
|
44
|
-
|
44
|
+
unless values.to_a.empty?
|
45
|
+
values.reverse_each {|value| self.unshift(value)}
|
46
|
+
end
|
45
47
|
|
46
48
|
if block_given?
|
47
49
|
case block.arity
|
@@ -69,6 +71,7 @@ module RDF
|
|
69
71
|
rest = nil
|
70
72
|
firsts = rests = 0
|
71
73
|
@graph.query(:subject => li) do |st|
|
74
|
+
return false unless st.subject.node?
|
72
75
|
case st.predicate
|
73
76
|
when RDF.type
|
74
77
|
# Be tollerant about rdf:type entries, as some OWL vocabularies use it excessively
|
@@ -205,6 +208,71 @@ module RDF
|
|
205
208
|
at(index)
|
206
209
|
end
|
207
210
|
|
211
|
+
##
|
212
|
+
# Appends an element to the head of this list. Existing references are not updated, as the list subject changes as a side-effect.
|
213
|
+
#
|
214
|
+
# @example
|
215
|
+
# RDF::List[].unshift(1).unshift(2).unshift(3) #=> RDF::List[3, 2, 1]
|
216
|
+
#
|
217
|
+
# @param [RDF::Term] value
|
218
|
+
# @return [RDF::List]
|
219
|
+
# @see http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-unshift
|
220
|
+
#
|
221
|
+
def unshift(value)
|
222
|
+
value = case value
|
223
|
+
when nil then RDF.nil
|
224
|
+
when RDF::Value then value
|
225
|
+
when Array then RDF::List.new(nil, graph, value)
|
226
|
+
else value
|
227
|
+
end
|
228
|
+
|
229
|
+
new_subject, old_subject = RDF::Node.new, subject
|
230
|
+
|
231
|
+
graph.insert([new_subject, RDF.type, RDF.List])
|
232
|
+
graph.insert([new_subject, RDF.first, value.is_a?(RDF::List) ? value.subject : value])
|
233
|
+
graph.insert([new_subject, RDF.rest, old_subject])
|
234
|
+
|
235
|
+
@subject = new_subject
|
236
|
+
|
237
|
+
return self
|
238
|
+
end
|
239
|
+
|
240
|
+
##
|
241
|
+
# Removes and returns the element at the head of this list.
|
242
|
+
#
|
243
|
+
# @example
|
244
|
+
# RDF::List[1,2,3].shift #=> 1
|
245
|
+
#
|
246
|
+
# @return [RDF::Term]
|
247
|
+
# @see http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-shift
|
248
|
+
def shift
|
249
|
+
return nil if empty?
|
250
|
+
|
251
|
+
value = first
|
252
|
+
old_subject, new_subject = subject, rest_subject
|
253
|
+
graph.delete([old_subject, RDF.type, RDF.List])
|
254
|
+
graph.delete([old_subject, RDF.first, value])
|
255
|
+
graph.delete([old_subject, RDF.rest, new_subject])
|
256
|
+
|
257
|
+
@subject = new_subject
|
258
|
+
return value
|
259
|
+
end
|
260
|
+
|
261
|
+
##
|
262
|
+
# Empties this list
|
263
|
+
#
|
264
|
+
# @example
|
265
|
+
# RDF::List[1, 2, 2, 3].clear #=> RDF::List[]
|
266
|
+
#
|
267
|
+
# @return [RDF::List]
|
268
|
+
# @see http://ruby-doc.org/core-1.9.3/classes/Array.html#method-i-clear
|
269
|
+
def clear
|
270
|
+
until empty?
|
271
|
+
shift
|
272
|
+
end
|
273
|
+
return self
|
274
|
+
end
|
275
|
+
|
208
276
|
##
|
209
277
|
# Appends an element to the tail of this list.
|
210
278
|
#
|
@@ -223,7 +291,7 @@ module RDF
|
|
223
291
|
end
|
224
292
|
|
225
293
|
if empty?
|
226
|
-
new_subject =
|
294
|
+
@subject = new_subject = RDF::Node.new
|
227
295
|
else
|
228
296
|
old_subject, new_subject = last_subject, RDF::Node.new
|
229
297
|
graph.delete([old_subject, RDF.rest, RDF.nil])
|
data/lib/rdf/model/statement.rb
CHANGED
@@ -182,12 +182,11 @@ module RDF
|
|
182
182
|
end
|
183
183
|
|
184
184
|
##
|
185
|
-
# Returns `true` if
|
186
|
-
# node.
|
185
|
+
# Returns `true` if any resource of this statement is a blank node.
|
187
186
|
#
|
188
187
|
# @return [Boolean]
|
189
188
|
def has_blank_nodes?
|
190
|
-
|
189
|
+
to_quad.compact.any?(&:node?)
|
191
190
|
end
|
192
191
|
|
193
192
|
##
|
data/lib/rdf/nquads.rb
CHANGED
@@ -38,12 +38,14 @@ module RDF
|
|
38
38
|
def self.detect(sample)
|
39
39
|
!!sample.match(%r(
|
40
40
|
(?:\s*(?:<[^>]*>) | (?:_:\w+)) # Subject
|
41
|
+
\s*
|
41
42
|
(?:\s*<[^>]*>) # Predicate
|
42
43
|
\s*
|
43
44
|
(?:(?:<[^>]*>) | (?:_:\w+) | (?:"[^"\n]*"(?:^^|@\S+)?)) # Object
|
44
|
-
|
45
|
+
\s*
|
46
|
+
(?:\s*(?:<[^>]*>) | (?:_:\w+)) # Context
|
45
47
|
\s*\.
|
46
|
-
)
|
48
|
+
)x) && !(
|
47
49
|
sample.match(%r(@(base|prefix|keywords)|\{)) || # Not Turtle/N3/TriG
|
48
50
|
sample.match(%r(<(html|rdf))i) # Not HTML or XML
|
49
51
|
)
|
data/lib/rdf/ntriples/format.rb
CHANGED
@@ -40,7 +40,7 @@ module RDF::NTriples
|
|
40
40
|
\s*
|
41
41
|
(?:(?:<[^>]*>) | (?:_:\w+) | (?:"[^"\n]*"(?:^^|@\S+)?)) # Object
|
42
42
|
\s*\.
|
43
|
-
)
|
43
|
+
)x) && !(
|
44
44
|
sample.match(%r(@(base|prefix|keywords)|\{)) || # Not Turtle/N3/TriG
|
45
45
|
sample.match(%r(<(html|rdf))i) # Not HTML or XML
|
46
46
|
) && !RDF::NQuads::Format.detect(sample)
|
data/lib/rdf/query/solution.rb
CHANGED
@@ -182,17 +182,33 @@ class RDF::Query
|
|
182
182
|
|
183
183
|
##
|
184
184
|
# Compatible Mappings
|
185
|
+
#
|
185
186
|
# Two solution mappings u1 and u2 are compatible if, for every variable v in dom(u1) and in dom(u2), u1(v) = u2(v).
|
186
187
|
#
|
187
188
|
# @param [RDF::Query::Solution, #to_hash] other
|
188
189
|
# another query solution or hash bindings
|
189
190
|
# @return [Boolean]
|
191
|
+
# @see http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#defn_algCompatibleMapping
|
190
192
|
def compatible?(other)
|
191
193
|
@bindings.all? do |k, v|
|
192
194
|
!other.to_hash.has_key?(k) || other[k].eql?(v)
|
193
195
|
end
|
194
196
|
end
|
195
|
-
|
197
|
+
|
198
|
+
##
|
199
|
+
# Disjoint mapping
|
200
|
+
#
|
201
|
+
# A solution is disjoint with another solution if it shares no common variables in their domains.
|
202
|
+
#
|
203
|
+
# @param [RDF::Query::Solution] other
|
204
|
+
# @return [Boolean]
|
205
|
+
# @see http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#defn_algMinus
|
206
|
+
def disjoint?(other)
|
207
|
+
@bindings.none? do |k, v|
|
208
|
+
v && other.to_hash.has_key?(k) && other[k].eql?(v)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
196
212
|
##
|
197
213
|
# Isomorphic Mappings
|
198
214
|
# Two solution mappings u1 and u2 are isomorphic if,
|
data/lib/rdf/query/solutions.rb
CHANGED
@@ -106,6 +106,20 @@ module RDF; class Query
|
|
106
106
|
end
|
107
107
|
alias_method :filter!, :filter
|
108
108
|
|
109
|
+
##
|
110
|
+
# Difference between solution sets, from SPARQL 1.1.
|
111
|
+
#
|
112
|
+
# The `minus` operation on solutions returns those solutions which either have no compatible solution in `other`, or the solution domains are disjoint.
|
113
|
+
#
|
114
|
+
# @param [RDF::Query::Solutions] other
|
115
|
+
# @return [RDF::Query::Solutions] a new solution set
|
116
|
+
# @see http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#defn_algMinus
|
117
|
+
def minus(other)
|
118
|
+
self.dup.filter! do |soln|
|
119
|
+
!other.any? {|soln2| soln.compatible?(soln2) && !soln.disjoint?(soln2)}
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
109
123
|
##
|
110
124
|
# Reorders this solution sequence by the given `variables`.
|
111
125
|
#
|
metadata
CHANGED
@@ -1,101 +1,89 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Arto Bendiken
|
9
8
|
- Ben Lavender
|
10
9
|
- Gregg Kellogg
|
11
|
-
autorequire:
|
10
|
+
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date: 2013-
|
13
|
+
date: 2013-06-15 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: addressable
|
18
|
-
version_requirements: !ruby/object:Gem::Requirement
|
19
|
-
requirements:
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '2.2'
|
23
|
-
none: false
|
24
17
|
requirement: !ruby/object:Gem::Requirement
|
25
18
|
requirements:
|
26
|
-
- -
|
19
|
+
- - ! '>='
|
27
20
|
- !ruby/object:Gem::Version
|
28
21
|
version: '2.2'
|
29
|
-
none: false
|
30
|
-
prerelease: false
|
31
22
|
type: :runtime
|
32
|
-
|
33
|
-
name: rdf-spec
|
23
|
+
prerelease: false
|
34
24
|
version_requirements: !ruby/object:Gem::Requirement
|
35
25
|
requirements:
|
36
|
-
- -
|
26
|
+
- - ! '>='
|
37
27
|
- !ruby/object:Gem::Version
|
38
|
-
version: '
|
39
|
-
|
28
|
+
version: '2.2'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rdf-spec
|
40
31
|
requirement: !ruby/object:Gem::Requirement
|
41
32
|
requirements:
|
42
|
-
- -
|
33
|
+
- - ~>
|
43
34
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
45
|
-
none: false
|
46
|
-
prerelease: false
|
35
|
+
version: 1.0.7
|
47
36
|
type: :development
|
48
|
-
|
49
|
-
name: rdf-rdfxml
|
37
|
+
prerelease: false
|
50
38
|
version_requirements: !ruby/object:Gem::Requirement
|
51
39
|
requirements:
|
52
|
-
- -
|
40
|
+
- - ~>
|
53
41
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
|
56
|
-
|
42
|
+
version: 1.0.7
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rdf-rdfxml
|
57
45
|
requirement: !ruby/object:Gem::Requirement
|
58
46
|
requirements:
|
59
|
-
- -
|
47
|
+
- - ! '>='
|
60
48
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
MA==
|
63
|
-
none: false
|
64
|
-
prerelease: false
|
49
|
+
version: '0'
|
65
50
|
type: :development
|
66
|
-
|
67
|
-
name: rspec
|
51
|
+
prerelease: false
|
68
52
|
version_requirements: !ruby/object:Gem::Requirement
|
69
53
|
requirements:
|
70
|
-
- -
|
54
|
+
- - ! '>='
|
71
55
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
73
|
-
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rspec
|
74
59
|
requirement: !ruby/object:Gem::Requirement
|
75
60
|
requirements:
|
76
|
-
- -
|
61
|
+
- - ! '>='
|
77
62
|
- !ruby/object:Gem::Version
|
78
63
|
version: '2.12'
|
79
|
-
none: false
|
80
|
-
prerelease: false
|
81
64
|
type: :development
|
82
|
-
|
83
|
-
name: yard
|
65
|
+
prerelease: false
|
84
66
|
version_requirements: !ruby/object:Gem::Requirement
|
85
67
|
requirements:
|
86
|
-
- -
|
68
|
+
- - ! '>='
|
87
69
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
89
|
-
|
70
|
+
version: '2.12'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: yard
|
90
73
|
requirement: !ruby/object:Gem::Requirement
|
91
74
|
requirements:
|
92
|
-
- -
|
75
|
+
- - ! '>='
|
93
76
|
- !ruby/object:Gem::Version
|
94
77
|
version: '0.8'
|
95
|
-
none: false
|
96
|
-
prerelease: false
|
97
78
|
type: :development
|
98
|
-
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0.8'
|
85
|
+
description: RDF.rb is a pure-Ruby library for working with Resource Description Framework
|
86
|
+
(RDF) data.
|
99
87
|
email: public-rdf-ruby@w3.org
|
100
88
|
executables:
|
101
89
|
- rdf
|
@@ -110,19 +98,8 @@ files:
|
|
110
98
|
- bin/rdf
|
111
99
|
- etc/doap.nt
|
112
100
|
- lib/df.rb
|
113
|
-
- lib/rdf.rb
|
114
101
|
- lib/rdf/cli.rb
|
115
102
|
- lib/rdf/format.rb
|
116
|
-
- lib/rdf/nquads.rb
|
117
|
-
- lib/rdf/ntriples.rb
|
118
|
-
- lib/rdf/query.rb
|
119
|
-
- lib/rdf/reader.rb
|
120
|
-
- lib/rdf/repository.rb
|
121
|
-
- lib/rdf/transaction.rb
|
122
|
-
- lib/rdf/util.rb
|
123
|
-
- lib/rdf/version.rb
|
124
|
-
- lib/rdf/vocab.rb
|
125
|
-
- lib/rdf/writer.rb
|
126
103
|
- lib/rdf/mixin/countable.rb
|
127
104
|
- lib/rdf/mixin/durable.rb
|
128
105
|
- lib/rdf/mixin/enumerable.rb
|
@@ -135,13 +112,6 @@ files:
|
|
135
112
|
- lib/rdf/mixin/writable.rb
|
136
113
|
- lib/rdf/model/graph.rb
|
137
114
|
- lib/rdf/model/list.rb
|
138
|
-
- lib/rdf/model/literal.rb
|
139
|
-
- lib/rdf/model/node.rb
|
140
|
-
- lib/rdf/model/resource.rb
|
141
|
-
- lib/rdf/model/statement.rb
|
142
|
-
- lib/rdf/model/term.rb
|
143
|
-
- lib/rdf/model/uri.rb
|
144
|
-
- lib/rdf/model/value.rb
|
145
115
|
- lib/rdf/model/literal/boolean.rb
|
146
116
|
- lib/rdf/model/literal/date.rb
|
147
117
|
- lib/rdf/model/literal/datetime.rb
|
@@ -153,18 +123,33 @@ files:
|
|
153
123
|
- lib/rdf/model/literal/time.rb
|
154
124
|
- lib/rdf/model/literal/token.rb
|
155
125
|
- lib/rdf/model/literal/xml.rb
|
126
|
+
- lib/rdf/model/literal.rb
|
127
|
+
- lib/rdf/model/node.rb
|
128
|
+
- lib/rdf/model/resource.rb
|
129
|
+
- lib/rdf/model/statement.rb
|
130
|
+
- lib/rdf/model/term.rb
|
131
|
+
- lib/rdf/model/uri.rb
|
132
|
+
- lib/rdf/model/value.rb
|
133
|
+
- lib/rdf/nquads.rb
|
156
134
|
- lib/rdf/ntriples/format.rb
|
157
135
|
- lib/rdf/ntriples/reader.rb
|
158
136
|
- lib/rdf/ntriples/writer.rb
|
137
|
+
- lib/rdf/ntriples.rb
|
159
138
|
- lib/rdf/query/hash_pattern_normalizer.rb
|
160
139
|
- lib/rdf/query/pattern.rb
|
161
140
|
- lib/rdf/query/solution.rb
|
162
141
|
- lib/rdf/query/solutions.rb
|
163
142
|
- lib/rdf/query/variable.rb
|
143
|
+
- lib/rdf/query.rb
|
144
|
+
- lib/rdf/reader.rb
|
145
|
+
- lib/rdf/repository.rb
|
146
|
+
- lib/rdf/transaction.rb
|
164
147
|
- lib/rdf/util/aliasing.rb
|
165
148
|
- lib/rdf/util/cache.rb
|
166
149
|
- lib/rdf/util/file.rb
|
167
150
|
- lib/rdf/util/uuid.rb
|
151
|
+
- lib/rdf/util.rb
|
152
|
+
- lib/rdf/version.rb
|
168
153
|
- lib/rdf/vocab/cc.rb
|
169
154
|
- lib/rdf/vocab/cert.rb
|
170
155
|
- lib/rdf/vocab/dc.rb
|
@@ -184,31 +169,32 @@ files:
|
|
184
169
|
- lib/rdf/vocab/wot.rb
|
185
170
|
- lib/rdf/vocab/xhtml.rb
|
186
171
|
- lib/rdf/vocab/xsd.rb
|
172
|
+
- lib/rdf/vocab.rb
|
173
|
+
- lib/rdf/writer.rb
|
174
|
+
- lib/rdf.rb
|
187
175
|
homepage: http://ruby-rdf.github.com/
|
188
176
|
licenses:
|
189
177
|
- Public Domain
|
190
|
-
|
178
|
+
metadata: {}
|
179
|
+
post_install_message:
|
191
180
|
rdoc_options: []
|
192
181
|
require_paths:
|
193
182
|
- lib
|
194
183
|
required_ruby_version: !ruby/object:Gem::Requirement
|
195
184
|
requirements:
|
196
|
-
- -
|
185
|
+
- - ! '>='
|
197
186
|
- !ruby/object:Gem::Version
|
198
187
|
version: 1.8.1
|
199
|
-
none: false
|
200
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
189
|
requirements:
|
202
|
-
- -
|
190
|
+
- - ! '>='
|
203
191
|
- !ruby/object:Gem::Version
|
204
|
-
version:
|
205
|
-
MA==
|
206
|
-
none: false
|
192
|
+
version: '0'
|
207
193
|
requirements: []
|
208
194
|
rubyforge_project: rdf
|
209
|
-
rubygems_version:
|
210
|
-
signing_key:
|
211
|
-
specification_version:
|
195
|
+
rubygems_version: 2.0.3
|
196
|
+
signing_key:
|
197
|
+
specification_version: 4
|
212
198
|
summary: A Ruby library for working with Resource Description Framework (RDF) data.
|
213
199
|
test_files: []
|
214
200
|
has_rdoc: false
|