rdf 0.2.3 → 0.3.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -0
- data/{CONTRIBUTORS → CREDITS} +3 -1
- data/README +17 -8
- data/VERSION +1 -1
- data/etc/doap.nt +28 -10
- data/lib/rdf/format.rb +55 -47
- data/lib/rdf/mixin/countable.rb +3 -6
- data/lib/rdf/mixin/enumerable.rb +69 -69
- data/lib/rdf/mixin/indexable.rb +26 -0
- data/lib/rdf/mixin/mutable.rb +2 -2
- data/lib/rdf/mixin/queryable.rb +50 -12
- data/lib/rdf/mixin/writable.rb +8 -19
- data/lib/rdf/model/literal/boolean.rb +42 -6
- data/lib/rdf/model/literal/date.rb +17 -5
- data/lib/rdf/model/literal/datetime.rb +18 -6
- data/lib/rdf/model/literal/decimal.rb +32 -5
- data/lib/rdf/model/literal/double.rb +32 -5
- data/lib/rdf/model/literal/integer.rb +16 -5
- data/lib/rdf/model/literal/time.rb +6 -6
- data/lib/rdf/model/literal/token.rb +5 -5
- data/lib/rdf/model/literal/xml.rb +5 -5
- data/lib/rdf/model/literal.rb +24 -11
- data/lib/rdf/model/node.rb +14 -13
- data/lib/rdf/model/uri.rb +315 -42
- data/lib/rdf/model/value.rb +1 -1
- data/lib/rdf/ntriples/reader.rb +23 -15
- data/lib/rdf/ntriples/writer.rb +1 -1
- data/lib/rdf/query/pattern.rb +131 -15
- data/lib/rdf/query/solution.rb +94 -29
- data/lib/rdf/query/solutions.rb +202 -0
- data/lib/rdf/query/variable.rb +42 -18
- data/lib/rdf/query.rb +210 -160
- data/lib/rdf/reader.rb +300 -112
- data/lib/rdf/repository.rb +88 -6
- data/lib/rdf/transaction.rb +161 -0
- data/lib/rdf/util/cache.rb +5 -0
- data/lib/rdf/util/file.rb +31 -0
- data/lib/rdf/util/uuid.rb +36 -0
- data/lib/rdf/util.rb +2 -0
- data/lib/rdf/version.rb +3 -3
- data/lib/rdf/vocab.rb +43 -35
- data/lib/rdf/writer.rb +105 -50
- data/lib/rdf.rb +29 -27
- metadata +26 -17
data/AUTHORS
CHANGED
data/{CONTRIBUTORS → CREDITS}
RENAMED
@@ -1,5 +1,7 @@
|
|
1
|
+
* Călin Ardelean <calinucs@gmail.com>
|
2
|
+
* Joey Geiger <jgeiger@gmail.com>
|
1
3
|
* Fumihiro Kato <fumi@fumi.me>
|
2
|
-
* Gregg Kellogg <gregg@kellogg-assoc.com>
|
3
4
|
* Hellekin O. Wolf <hellekin@cepheide.org>
|
4
5
|
* John Fieber <jrf@ursamaris.org>
|
6
|
+
* Keita Urashima <ursm@ursm.jp>
|
5
7
|
* Pius Uzamere <pius@alum.mit.edu>
|
data/README
CHANGED
@@ -17,6 +17,9 @@ Features
|
|
17
17
|
* Provides a clean, well-designed RDF object model and related APIs.
|
18
18
|
* Supports parsing and serializing N-Triples out of the box, with more
|
19
19
|
serialization format support available through add-on plugins.
|
20
|
+
* Includes in-memory graph and repository implementations, with more storage
|
21
|
+
adapter support available through add-on plugins.
|
22
|
+
* Implements basic graph pattern (BGP) query evaluation.
|
20
23
|
* Plays nice with others: entirely contained in the `RDF` module, and does
|
21
24
|
not modify any of Ruby's core classes or standard library.
|
22
25
|
* Based entirely on Ruby's autoloading, meaning that you can generally make
|
@@ -109,6 +112,8 @@ Documentation
|
|
109
112
|
* {RDF::Repository}
|
110
113
|
* {RDF::Countable}
|
111
114
|
* {RDF::Enumerable}
|
115
|
+
* {RDF::Indexable}
|
116
|
+
* {RDF::Inferable}
|
112
117
|
* {RDF::Queryable}
|
113
118
|
* {RDF::Mutable}
|
114
119
|
* {RDF::Durable}
|
@@ -120,6 +125,7 @@ Documentation
|
|
120
125
|
* {RDF::Query}
|
121
126
|
* {RDF::Query::Pattern}
|
122
127
|
* {RDF::Query::Solution}
|
128
|
+
* {RDF::Query::Solutions}
|
123
129
|
* {RDF::Query::Variable}
|
124
130
|
|
125
131
|
### RDF Vocabularies
|
@@ -189,17 +195,20 @@ Mailing List
|
|
189
195
|
Authors
|
190
196
|
-------
|
191
197
|
|
192
|
-
* [Arto Bendiken](
|
193
|
-
* [Ben Lavender](
|
198
|
+
* [Arto Bendiken](http://github.com/bendiken) - <http://ar.to/>
|
199
|
+
* [Ben Lavender](http://github.com/bhuga) - <http://bhuga.net/>
|
200
|
+
* [Gregg Kellogg](http://github.com/gkellogg) - <http://kellogg-assoc.com/>
|
194
201
|
|
195
202
|
Contributors
|
196
203
|
------------
|
197
204
|
|
198
|
-
* [
|
199
|
-
* [
|
200
|
-
* [
|
201
|
-
* [
|
202
|
-
* [
|
205
|
+
* [Călin Ardelean](http://github.com/clnx) - <http://github.com/clnx>
|
206
|
+
* [Joey Geiger](http://github.com/jgeiger) - <http://github.com/jgeiger>
|
207
|
+
* [Fumihiro Kato](http://github.com/fumi) - <http://fumi.me/>
|
208
|
+
* [Hellekin O. Wolf](http://github.com/hellekin) - <http://hellekin.cepheide.org/>
|
209
|
+
* [John Fieber](http://github.com/jfieber) - <http://github.com/jfieber>
|
210
|
+
* [Keita Urashima](http://github.com/ursm) - <http://ursm.jp/>
|
211
|
+
* [Pius Uzamere](http://github.com/pius) - <http://pius.me/>
|
203
212
|
|
204
213
|
Contributing
|
205
214
|
------------
|
@@ -210,7 +219,7 @@ Contributing
|
|
210
219
|
[tutorial][YARD-GS] or just look at the existing code for examples.
|
211
220
|
* Don't touch the `.gemspec` or `VERSION` files. If you need to change them,
|
212
221
|
do so on your private branch only.
|
213
|
-
* Do feel free to add yourself to the `
|
222
|
+
* Do feel free to add yourself to the `CREDITS` file and the
|
214
223
|
corresponding list in the the `README`. Alphabetical order applies.
|
215
224
|
* Don't touch the `AUTHORS` file. If your contributions are significant
|
216
225
|
enough, be assured we will eventually add you in there.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0.pre
|
data/etc/doap.nt
CHANGED
@@ -12,6 +12,11 @@
|
|
12
12
|
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox> <mailto:blavender@gmail.com> .
|
13
13
|
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "dbf45f4ffbd27b67aa84f02a6a31c144727d10af" .
|
14
14
|
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/name> "Ben Lavender" .
|
15
|
+
<http://kellogg-assoc.com/#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
16
|
+
<http://kellogg-assoc.com/#me> <http://xmlns.com/foaf/0.1/homepage> <http://kellogg-assoc.com/> .
|
17
|
+
<http://kellogg-assoc.com/#me> <http://xmlns.com/foaf/0.1/mbox> <mailto:gregg@kellogg-assoc.com> .
|
18
|
+
<http://kellogg-assoc.com/#me> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "35bc44e6d0070e5ad50ccbe0d24403c96af2b9bd" .
|
19
|
+
<http://kellogg-assoc.com/#me> <http://xmlns.com/foaf/0.1/name> "Gregg Kellogg" .
|
15
20
|
<http://rubygems.org/gems/rdf> <http://purl.org/dc/terms/creator> <http://ar.to/#self> .
|
16
21
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://ar.to/> .
|
17
22
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://blog.datagraph.org/> .
|
@@ -22,16 +27,23 @@
|
|
22
27
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#description> "RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data."@en .
|
23
28
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://ar.to/#self> .
|
24
29
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://bhuga.net/#ben> .
|
30
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://kellogg-assoc.com/#me> .
|
25
31
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://ar.to/#self> .
|
32
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://bhuga.net/#ben> .
|
33
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://kellogg-assoc.com/#me> .
|
26
34
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#download-page> <http://rubyforge.org/projects/rdf/> .
|
27
35
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid1 .
|
28
36
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid2 .
|
29
37
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid3 .
|
30
38
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid4 .
|
31
39
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid5 .
|
40
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid6 .
|
41
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid7 .
|
32
42
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#homepage> <http://rdf.rubyforge.org/> .
|
33
43
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#license> <http://creativecommons.org/licenses/publicdomain/> .
|
34
44
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://ar.to/#self> .
|
45
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://bhuga.net/#ben> .
|
46
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://kellogg-assoc.com/#me> .
|
35
47
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#name> "RDF.rb" .
|
36
48
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#platform> "Ruby" .
|
37
49
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#shortdesc> "A Ruby library for working with Resource Description Framework (RDF) data."@en .
|
@@ -39,17 +51,23 @@
|
|
39
51
|
<http://rubygems.org/gems/rdf> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://usefulinc.com/ns/doap#Project> .
|
40
52
|
<http://rubygems.org/gems/rdf> <http://xmlns.com/foaf/0.1/maker> <http://ar.to/#self> .
|
41
53
|
_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
42
|
-
_:genid1 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "
|
43
|
-
_:genid1 <http://xmlns.com/foaf/0.1/name> "
|
54
|
+
_:genid1 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "274bd18402fc773ffc0606996aa1fb90b603aa29" .
|
55
|
+
_:genid1 <http://xmlns.com/foaf/0.1/name> "C\u0103lin Ardelean" .
|
44
56
|
_:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
45
|
-
_:genid2 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "
|
46
|
-
_:genid2 <http://xmlns.com/foaf/0.1/name> "
|
57
|
+
_:genid2 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f412d743150d7b27b8468d56e69ca147917ea6fc" .
|
58
|
+
_:genid2 <http://xmlns.com/foaf/0.1/name> "Joey Geiger" .
|
47
59
|
_:genid3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
48
|
-
_:genid3 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "
|
49
|
-
_:genid3 <http://xmlns.com/foaf/0.1/name> "
|
60
|
+
_:genid3 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "d31fdd6af7a279a89bf09fdc9f7c44d9d08bb930" .
|
61
|
+
_:genid3 <http://xmlns.com/foaf/0.1/name> "Fumihiro Kato" .
|
50
62
|
_:genid4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
51
|
-
_:genid4 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "
|
52
|
-
_:genid4 <http://xmlns.com/foaf/0.1/name> "
|
63
|
+
_:genid4 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "c69f3255ff0639543cc5edfd8116eac8df16fab8" .
|
64
|
+
_:genid4 <http://xmlns.com/foaf/0.1/name> "Hellekin O. Wolf" .
|
53
65
|
_:genid5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
54
|
-
_:genid5 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "
|
55
|
-
_:genid5 <http://xmlns.com/foaf/0.1/name> "
|
66
|
+
_:genid5 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f7653fc1ac0e82ebb32f092389bd5fc728eaae12" .
|
67
|
+
_:genid5 <http://xmlns.com/foaf/0.1/name> "John Fieber" .
|
68
|
+
_:genid6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
69
|
+
_:genid6 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "2b4247b6fd5bb4a1383378f325784318680d5ff9" .
|
70
|
+
_:genid6 <http://xmlns.com/foaf/0.1/name> "Keita Urashima" .
|
71
|
+
_:genid7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
72
|
+
_:genid7 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "bedbbf2451e5beb38d59687c0460032aff92cd3c" .
|
73
|
+
_:genid7 <http://xmlns.com/foaf/0.1/name> "Pius Uzamere" .
|
data/lib/rdf/format.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
module RDF
|
2
2
|
##
|
3
|
-
#
|
3
|
+
# The base class for RDF serialization formats.
|
4
|
+
#
|
5
|
+
# @example Loading an RDF serialization format implementation
|
6
|
+
# require 'rdf/ntriples'
|
4
7
|
#
|
5
8
|
# @example Iterating over known RDF serialization formats
|
6
9
|
# RDF::Format.each { |klass| puts klass.name }
|
7
10
|
#
|
8
11
|
# @example Getting a serialization format class
|
9
12
|
# RDF::Format.for(:ntriples) #=> RDF::NTriples::Format
|
10
|
-
# RDF::Format.for("
|
11
|
-
# RDF::Format.for(:file_name => "
|
13
|
+
# RDF::Format.for("etc/doap.nt")
|
14
|
+
# RDF::Format.for(:file_name => "etc/doap.nt")
|
12
15
|
# RDF::Format.for(:file_extension => "nt")
|
13
16
|
# RDF::Format.for(:content_type => "text/plain")
|
14
17
|
#
|
@@ -85,6 +88,11 @@ module RDF
|
|
85
88
|
|
86
89
|
when Hash
|
87
90
|
case
|
91
|
+
# Find a format based on the MIME content type
|
92
|
+
when mime_type = options[:content_type]
|
93
|
+
if content_types.has_key?(mime_type = mime_type.to_s)
|
94
|
+
content_types[mime_type].first
|
95
|
+
end
|
88
96
|
# Find a format based on the file name
|
89
97
|
when file_name = options[:file_name]
|
90
98
|
self.for(:file_extension => File.extname(file_name.to_s)[1..-1])
|
@@ -93,11 +101,6 @@ module RDF
|
|
93
101
|
if file_extensions.has_key?(file_ext = file_ext.to_sym)
|
94
102
|
self.for(:content_type => file_extensions[file_ext])
|
95
103
|
end
|
96
|
-
# Find a format based on the MIME content type
|
97
|
-
when mime_type = options[:content_type]
|
98
|
-
if content_types.has_key?(mime_type = mime_type.to_s)
|
99
|
-
content_types[mime_type].first
|
100
|
-
end
|
101
104
|
end
|
102
105
|
|
103
106
|
when Symbol
|
@@ -270,49 +273,54 @@ module RDF
|
|
270
273
|
end
|
271
274
|
end
|
272
275
|
|
273
|
-
|
276
|
+
protected
|
274
277
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
##
|
289
|
-
# Defines the content encoding for this RDF serialization format.
|
290
|
-
#
|
291
|
-
# @param [#to_sym] encoding
|
292
|
-
# @return [void]
|
293
|
-
def self.content_encoding(encoding)
|
294
|
-
@@content_encoding[self] = encoding.to_sym
|
295
|
-
end
|
278
|
+
##
|
279
|
+
# Defines a required Ruby library for this RDF serialization format.
|
280
|
+
#
|
281
|
+
# The given library will be required lazily, i.e. only when it is
|
282
|
+
# actually first needed, such as when instantiating a reader or parser
|
283
|
+
# instance for this format.
|
284
|
+
#
|
285
|
+
# @param [String, #to_s] library
|
286
|
+
# @return [void]
|
287
|
+
def self.require(library)
|
288
|
+
(@@requires[self] ||= []) << library.to_s
|
289
|
+
end
|
296
290
|
|
297
|
-
|
291
|
+
##
|
292
|
+
# Defines the content encoding for this RDF serialization format.
|
293
|
+
#
|
294
|
+
# @param [#to_sym] encoding
|
295
|
+
# @return [void]
|
296
|
+
def self.content_encoding(encoding)
|
297
|
+
@@content_encoding[self] = encoding.to_sym
|
298
|
+
end
|
298
299
|
|
299
|
-
|
300
|
+
private
|
300
301
|
|
301
|
-
|
302
|
-
@@requires = {} # @private
|
303
|
-
@@file_extensions = {} # @private
|
304
|
-
@@content_type = {} # @private
|
305
|
-
@@content_types = {} # @private
|
306
|
-
@@content_encoding = {} # @private
|
307
|
-
@@readers = {} # @private
|
308
|
-
@@writers = {} # @private
|
302
|
+
private_class_method :new
|
309
303
|
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
304
|
+
@@requires = {} # @private
|
305
|
+
@@file_extensions = {} # @private
|
306
|
+
@@content_type = {} # @private
|
307
|
+
@@content_types = {} # @private
|
308
|
+
@@content_encoding = {} # @private
|
309
|
+
@@readers = {} # @private
|
310
|
+
@@writers = {} # @private
|
311
|
+
@@subclasses = [] # @private
|
314
312
|
|
315
|
-
|
313
|
+
##
|
314
|
+
# @private
|
315
|
+
# @return [void]
|
316
|
+
def self.inherited(child)
|
317
|
+
@@subclasses << child
|
318
|
+
super
|
319
|
+
end
|
320
|
+
end # Format
|
316
321
|
|
317
|
-
|
318
|
-
|
322
|
+
##
|
323
|
+
# The base class for RDF serialization format errors.
|
324
|
+
class FormatError < IOError
|
325
|
+
end # FormatError
|
326
|
+
end # RDF
|
data/lib/rdf/mixin/countable.rb
CHANGED
@@ -23,9 +23,7 @@ module RDF
|
|
23
23
|
each { count += 1 }
|
24
24
|
count
|
25
25
|
end
|
26
|
-
|
27
|
-
alias_method :size, :count
|
28
|
-
alias_method :length, :count # @deprecated
|
26
|
+
alias_method :size, :count
|
29
27
|
|
30
28
|
##
|
31
29
|
# @private
|
@@ -36,7 +34,6 @@ module RDF
|
|
36
34
|
# Ensure that enumerators support the `#empty?` and `#count` methods:
|
37
35
|
super.extend(RDF::Countable)
|
38
36
|
end
|
39
|
-
|
40
37
|
alias_method :to_enum, :enum_for
|
41
|
-
end
|
42
|
-
end
|
38
|
+
end # Countable
|
39
|
+
end # RDF
|