rdf 3.0.12 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHORS +1 -1
  3. data/README.md +46 -11
  4. data/VERSION +1 -1
  5. data/etc/doap.nt +74 -80
  6. data/lib/rdf.rb +35 -23
  7. data/lib/rdf/changeset.rb +87 -19
  8. data/lib/rdf/cli.rb +7 -7
  9. data/lib/rdf/format.rb +17 -10
  10. data/lib/rdf/mixin/enumerable.rb +3 -2
  11. data/lib/rdf/mixin/mutable.rb +5 -15
  12. data/lib/rdf/mixin/queryable.rb +12 -4
  13. data/lib/rdf/mixin/writable.rb +9 -14
  14. data/lib/rdf/model/dataset.rb +1 -1
  15. data/lib/rdf/model/graph.rb +5 -2
  16. data/lib/rdf/model/list.rb +5 -5
  17. data/lib/rdf/model/literal.rb +3 -3
  18. data/lib/rdf/model/statement.rb +30 -7
  19. data/lib/rdf/model/uri.rb +44 -23
  20. data/lib/rdf/nquads.rb +6 -6
  21. data/lib/rdf/ntriples.rb +6 -4
  22. data/lib/rdf/ntriples/reader.rb +29 -7
  23. data/lib/rdf/ntriples/writer.rb +10 -1
  24. data/lib/rdf/query.rb +27 -35
  25. data/lib/rdf/query/hash_pattern_normalizer.rb +14 -12
  26. data/lib/rdf/query/pattern.rb +51 -18
  27. data/lib/rdf/query/solution.rb +20 -1
  28. data/lib/rdf/query/solutions.rb +15 -5
  29. data/lib/rdf/query/variable.rb +17 -5
  30. data/lib/rdf/reader.rb +76 -25
  31. data/lib/rdf/repository.rb +32 -18
  32. data/lib/rdf/transaction.rb +1 -1
  33. data/lib/rdf/util.rb +6 -5
  34. data/lib/rdf/util/cache.rb +2 -2
  35. data/lib/rdf/util/coercions.rb +60 -0
  36. data/lib/rdf/util/file.rb +20 -10
  37. data/lib/rdf/util/logger.rb +6 -6
  38. data/lib/rdf/vocab/owl.rb +401 -86
  39. data/lib/rdf/vocab/rdfs.rb +81 -18
  40. data/lib/rdf/vocab/rdfv.rb +147 -1
  41. data/lib/rdf/vocab/writer.rb +41 -3
  42. data/lib/rdf/vocab/xsd.rb +203 -2
  43. data/lib/rdf/vocabulary.rb +108 -14
  44. data/lib/rdf/writer.rb +32 -10
  45. metadata +32 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcde96af39c44efa90ba7eaa1b32baefef595b7047289398ef7f87feff7dbb1a
4
- data.tar.gz: d378680c75bb888ad8d079bad863309378cbd6b340061d111614d5703f17dc9b
3
+ metadata.gz: 3edf1c89289474f1f14ee840b6cd5903c6443afd7ad8121e3ddfce5bcae30895
4
+ data.tar.gz: 12497c16ebc49b1bcfaa404609389b8c98cea22233868ff1378a810ede686371
5
5
  SHA512:
6
- metadata.gz: '022876050365a5ddc3f3a4e0569149583a65ba4398ed62268a4ecf7b616986fbc5662700c61d268105938fc9a3a22a7a6a73083f2a3e7e7fd7ad2fed793f9289'
7
- data.tar.gz: b7ce7cf2f38a1a75b527534162be5b0a78bf33c96c2338185186cab4fc2bbb94d63b5281396906a445b873789721a13fc89c366338763301bb5036e0e1efeeb3
6
+ metadata.gz: de42189a4269854a6292b4cd0b0de0a07c0a0d0e5b61a40cc9b4f460b66ada2f090fbadb0486e48d183f366ce776ea88ff89f715f61439c8c5ad7857d24047cb
7
+ data.tar.gz: 20725ce63013fed6385e9e1aade5b808d821de4ef5986cedbf9b87c34cc9f749b132437e2b7e496da12774214b709d6d3accf9b0861c14fa3353452ca5e0cbf5
data/AUTHORS CHANGED
@@ -1,3 +1,3 @@
1
1
  * Arto Bendiken <arto@bendiken.net>
2
2
  * Ben Lavender <blavender@gmail.com>
3
- * Gregg Kellogg <gregg@kellogg-assoc.com>
3
+ * Gregg Kellogg <gregg@greggkellogg.net>
data/README.md CHANGED
@@ -4,10 +4,6 @@ This is a pure-Ruby library for working with [Resource Description Framework
4
4
  (RDF)][RDF] data.
5
5
 
6
6
  * <https://ruby-rdf.github.com/rdf>
7
- * <https://blog.datagraph.org/2010/12/rdf-for-ruby>
8
- * <https://blog.datagraph.org/2010/03/rdf-for-ruby>
9
- * <https://blog.datagraph.org/2010/04/parsing-rdf-with-ruby>
10
- * <https://blog.datagraph.org/2010/04/rdf-repository-howto>
11
7
 
12
8
  [![Gem Version](https://badge.fury.io/rb/rdf.png)](https://badge.fury.io/rb/rdf)
13
9
  [![Build Status](https://travis-ci.org/ruby-rdf/rdf.png?branch=master)](https://travis-ci.org/ruby-rdf/rdf)
@@ -29,9 +25,11 @@ This is a pure-Ruby library for working with [Resource Description Framework
29
25
  not modify any of Ruby's core classes or standard library.
30
26
  * Based entirely on Ruby's autoloading, meaning that you can generally make
31
27
  use of any one part of the library without needing to load up the rest.
32
- * Compatible with Ruby Ruby >= 2.2.2, Rubinius and JRuby 9.0+.
28
+ * Compatible with Ruby Ruby >= 2.4, Rubinius and JRuby 9.0+.
29
+ * Note, changes in mapping hashes to keyword arguments for Ruby 2.7+ may require that arguments be passed more explicitly, especially when the first argument is a Hash and there are optional keyword arguments. In this case, Hash argument may need to be explicitly included within `{}` and the optional keyword arguments may need to be specified using `**{}` if there are no keyword arguments.
33
30
  * Performs auto-detection of input to select appropriate Reader class if one
34
31
  cannot be determined from file characteristics.
32
+ * Provisional support for [RDF*][].
35
33
 
36
34
  ### HTTP requests
37
35
 
@@ -189,7 +187,7 @@ Note that no prefixes are loaded automatically, however they can be provided as
189
187
  FOAF.name => :name,
190
188
  FOAF.mbox => :email,
191
189
  }
192
- })
190
+ }, **{})
193
191
 
194
192
  query.execute(graph) do |solution|
195
193
  puts "name=#{solution.name} email=#{solution.email}"
@@ -222,6 +220,46 @@ A separate [SPARQL][SPARQL doc] gem builds on basic BGP support to provide full
222
220
  foaf[:name] #=> RDF::URI("http://xmlns.com/foaf/0.1/name")
223
221
  foaf['mbox'] #=> RDF::URI("http://xmlns.com/foaf/0.1/mbox")
224
222
 
223
+ ## RDF* (RDFStar)
224
+
225
+ [RDF.rb][] includes provisional support for [RDF*][] with an N-Triples/N-Quads syntax extension that uses inline statements in the _subject_ or _object_ position.
226
+
227
+ Internally, an `RDF::Statement` is treated as another resource, along with `RDF::URI` and `RDF::Node`, which allows an `RDF::Statement` to have a `#subject` or `#object` which is also an `RDF::Statement`.
228
+
229
+ **Note: This feature is subject to change or elimination as the standards process progresses.**
230
+
231
+ ### Serializing a Graph containing embedded statements
232
+
233
+ require 'rdf/ntriples'
234
+ statement = RDF::Statement(RDF::URI('bob'), RDF::Vocab::FOAF.age, RDF::Literal(23))
235
+ graph = RDF::Graph.new << [statement, RDF::URI("ex:certainty"), RDF::Literal(0.9)]
236
+ graph.dump(:ntriples, validate: false)
237
+ # => '<<<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>>> <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
238
+
239
+ ### Reading a Graph containing embedded statements
240
+
241
+ By default, the N-Triples reader will reject a document containing a subject resource.
242
+
243
+ nt = '<<<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>>> <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
244
+ graph = RDF::Graph.new do |graph|
245
+ RDF::NTriples::Reader.new(nt) {|reader| graph << reader}
246
+ end
247
+ # => RDF::ReaderError
248
+
249
+ Readers support a `rdfstar` option with either `:PG` (Property Graph) or `:SA` (Separate Assertions) modes. In `:PG` mode, statements that are used in the subject or object positions are also implicitly added to the graph:
250
+
251
+ graph = RDF::Graph.new do |graph|
252
+ RDF::NTriples::Reader.new(nt, rdfstar: :PG) {|reader| graph << reader}
253
+ end
254
+ graph.count #=> 2
255
+
256
+ When using the `:SA` mode, only one statement is asserted, although the reified statement is contained within the graph.
257
+
258
+ graph = RDF::Graph.new do |graph|
259
+ RDF::NTriples::Reader.new(nt, rdfstar: :SA) {|reader| graph << reader}
260
+ end
261
+ graph.count #=> 1
262
+
225
263
  ## Documentation
226
264
 
227
265
  <https://rubydoc.info/github/ruby-rdf/rdf>
@@ -248,8 +286,6 @@ A separate [SPARQL][SPARQL doc] gem builds on basic BGP support to provide full
248
286
 
249
287
  ### RDF Serialization
250
288
 
251
- <https://blog.datagraph.org/2010/04/parsing-rdf-with-ruby>
252
-
253
289
  * {RDF::Format}
254
290
  * {RDF::Reader}
255
291
  * {RDF::Writer}
@@ -294,8 +330,6 @@ from BNode identity (i.e., they each entail the other)
294
330
 
295
331
  ### RDF Storage
296
332
 
297
- <https://blog.datagraph.org/2010/04/rdf-repository-howto>
298
-
299
333
  * {RDF::Repository}
300
334
  * {RDF::Countable}
301
335
  * {RDF::Enumerable}
@@ -418,7 +452,7 @@ see or the accompanying {file:UNLICENSE} file.
418
452
  [YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
419
453
  [PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
420
454
  [JSONLD doc]: https://rubydoc.info/github/ruby-rdf/json-ld
421
- [LinkedData doc]: https://rubydoc.info/github/datagraph/linkeddata
455
+ [LinkedData doc]: https://rubydoc.info/github/ruby-rdf/linkeddata
422
456
  [Microdata doc]: https://rubydoc.info/github/ruby-rdf/rdf-microdata
423
457
  [N3 doc]: https://rubydoc.info/github/ruby-rdf/rdf-n3
424
458
  [RDFa doc]: https://rubydoc.info/github/ruby-rdf/rdf-rdfa
@@ -441,6 +475,7 @@ see or the accompanying {file:UNLICENSE} file.
441
475
  [RDF::TriX]: https://ruby-rdf.github.com/rdf-trix
442
476
  [RDF::Turtle]: https://ruby-rdf.github.com/rdf-turtle
443
477
  [RDF::Raptor]: https://ruby-rdf.github.com/rdf-raptor
478
+ [RDF*]: https://lists.w3.org/Archives/Public/public-rdf-star/
444
479
  [LinkedData]: https://ruby-rdf.github.com/linkeddata
445
480
  [JSON::LD]: https://ruby-rdf.github.com/json-ld
446
481
  [RestClient]: https://rubygems.org/gems/rest-client
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.12
1
+ 3.1.3
@@ -1,85 +1,79 @@
1
- <https://rubygems.org/gems/rdf> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://usefulinc.com/ns/doap#Project> .
2
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#name> "RDF.rb" .
1
+ _:g6720 <http://xmlns.com/foaf/0.1/name> "Hellekin O. Wolf" .
2
+ _:g6720 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "c69f3255ff0639543cc5edfd8116eac8df16fab8" .
3
+ _:g6720 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
4
+ _:g6680 <http://xmlns.com/foaf/0.1/name> "Fumihiro Kato" .
5
+ _:g6680 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "d31fdd6af7a279a89bf09fdc9f7c44d9d08bb930" .
6
+ _:g6680 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
7
+ <https://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/homepage> <https://bhuga.net/> .
8
+ <https://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/name> "Ben Lavender" .
9
+ <https://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox> <mailto:blavender@gmail.com> .
10
+ <https://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "dbf45f4ffbd27b67aa84f02a6a31c144727d10af" .
11
+ <https://bhuga.net/#ben> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
12
+ _:g6660 <http://xmlns.com/foaf/0.1/name> "Joey Geiger" .
13
+ _:g6660 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f412d743150d7b27b8468d56e69ca147917ea6fc" .
14
+ _:g6660 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
15
+ _:g6740 <http://xmlns.com/foaf/0.1/name> "John Fieber" .
16
+ _:g6740 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f7653fc1ac0e82ebb32f092389bd5fc728eaae12" .
17
+ _:g6740 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
18
+ _:g6640 <http://xmlns.com/foaf/0.1/name> "Danny Gagne" .
19
+ _:g6640 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "6de43e9cf7de53427fea9765706703e4d957c17b" .
20
+ _:g6640 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
21
+ _:g6780 <http://xmlns.com/foaf/0.1/name> "Pius Uzamere" .
22
+ _:g6780 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "bedbbf2451e5beb38d59687c0460032aff92cd3c" .
23
+ _:g6780 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
24
+ _:g6700 <http://xmlns.com/foaf/0.1/name> "Naoki Kawamukai" .
25
+ _:g6700 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "5bdcd8e2af4f5952aaeeffbdd371c41525ec761d" .
26
+ _:g6700 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
3
27
  <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#homepage> <https://rubygems.org/gems/rdf> .
4
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#license> <http://creativecommons.org/licenses/publicdomain/> .
5
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#shortdesc> "A Ruby library for working with Resource Description Framework (RDF) data."@en .
6
28
  <https://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 .
7
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#created> "2007-10-23" .
8
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#platform> "Ruby" .
9
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Resource_Description_Framework> .
10
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Ruby_(programming_language)> .
11
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#implements> <http://www.w3.org/TR/rdf11-concepts/> .
12
29
  <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#implements> <http://www.w3.org/TR/n-quads/> .
30
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#implements> <http://www.w3.org/TR/rdf11-concepts/> .
13
31
  <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#implements> <http://www.w3.org/TR/n-triples/> .
32
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <https://bhuga.net/#ben> .
33
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <https://greggkellogg.net/foaf#me> .
34
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <https://ar.to/#self> .
14
35
  <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#download-page> <https://rubygems.org/gems/rdf/> .
15
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#bug-database> <http://github.com/ruby-rdf/rdf/issues> .
16
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://ar.to/> .
17
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://blog.datagraph.org/> .
18
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#vendor> <http://datagraph.org/> .
19
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://ar.to/#self> .
20
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://bhuga.net/#ben> .
21
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://greggkellogg.net/foaf#me> .
22
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://ar.to/#self> .
23
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://bhuga.net/#ben> .
24
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://greggkellogg.net/foaf#me> .
25
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://ar.to/#self> .
26
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://bhuga.net/#ben> .
27
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://greggkellogg.net/foaf#me> .
28
- _:g70186318075540 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
29
- _:g70186318075540 <http://xmlns.com/foaf/0.1/name> "Călin Ardelean" .
30
- _:g70186318075540 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "274bd18402fc773ffc0606996aa1fb90b603aa29" .
31
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g70186318075540 .
32
- _:g70186318591960 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
33
- _:g70186318591960 <http://xmlns.com/foaf/0.1/name> "Danny Gagne" .
34
- _:g70186318591960 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "6de43e9cf7de53427fea9765706703e4d957c17b" .
35
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g70186318591960 .
36
- _:g70186318228820 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
37
- _:g70186318228820 <http://xmlns.com/foaf/0.1/name> "Joey Geiger" .
38
- _:g70186318228820 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f412d743150d7b27b8468d56e69ca147917ea6fc" .
39
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g70186318228820 .
40
- _:g70186318408440 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
41
- _:g70186318408440 <http://xmlns.com/foaf/0.1/name> "Fumihiro Kato" .
42
- _:g70186318408440 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "d31fdd6af7a279a89bf09fdc9f7c44d9d08bb930" .
43
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g70186318408440 .
44
- _:g70186318725620 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
45
- _:g70186318725620 <http://xmlns.com/foaf/0.1/name> "Naoki Kawamukai" .
46
- _:g70186318725620 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "5bdcd8e2af4f5952aaeeffbdd371c41525ec761d" .
47
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g70186318725620 .
48
- _:g70186319866820 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
49
- _:g70186319866820 <http://xmlns.com/foaf/0.1/name> "Hellekin O. Wolf" .
50
- _:g70186319866820 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "c69f3255ff0639543cc5edfd8116eac8df16fab8" .
51
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g70186319866820 .
52
- _:g70186321042840 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
53
- _:g70186321042840 <http://xmlns.com/foaf/0.1/name> "John Fieber" .
54
- _:g70186321042840 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f7653fc1ac0e82ebb32f092389bd5fc728eaae12" .
55
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g70186321042840 .
56
- _:g70186319319640 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
57
- _:g70186319319640 <http://xmlns.com/foaf/0.1/name> "Keita Urashima" .
58
- _:g70186319319640 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "2b4247b6fd5bb4a1383378f325784318680d5ff9" .
59
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g70186319319640 .
60
- _:g70186321063140 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
61
- _:g70186321063140 <http://xmlns.com/foaf/0.1/name> "Pius Uzamere" .
62
- _:g70186321063140 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "bedbbf2451e5beb38d59687c0460032aff92cd3c" .
63
- <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g70186321063140 .
64
- <https://rubygems.org/gems/rdf> <http://xmlns.com/foaf/0.1/maker> <http://ar.to/#self> .
65
- <https://rubygems.org/gems/rdf> <http://purl.org/dc/terms/creator> <http://ar.to/#self> .
66
- <http://ar.to/#self> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
67
- <http://ar.to/#self> <http://xmlns.com/foaf/0.1/name> "Arto Bendiken" .
68
- <http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox> <mailto:arto@bendiken.net> .
69
- <http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "a033f652c84a4d73b8c26d318c2395699dd2bdfb" .
70
- <http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "d0737cceb55eb7d740578d2db1bc0727e3ed49ce" .
71
- <http://ar.to/#self> <http://xmlns.com/foaf/0.1/homepage> <http://ar.to/> .
72
- <http://ar.to/#self> <http://xmlns.com/foaf/0.1/made> <https://rubygems.org/gems/rdf> .
73
- <http://ar.to/#self> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://datagraph.org/bendiken/foaf> .
74
- <http://bhuga.net/#ben> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
75
- <http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/name> "Ben Lavender" .
76
- <http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox> <mailto:blavender@gmail.com> .
77
- <http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "dbf45f4ffbd27b67aa84f02a6a31c144727d10af" .
78
- <http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/homepage> <http://bhuga.net/> .
79
- <http://bhuga.net/#ben> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://datagraph.org/bhuga/foaf> .
80
- <http://greggkellogg.net/foaf#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
81
- <http://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/name> "Gregg Kellogg" .
82
- <http://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/mbox> <mailto:gregg@greggkellogg.net> .
83
- <http://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "35bc44e6d0070e5ad50ccbe0d24403c96af2b9bd" .
84
- <http://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/homepage> <http://greggkellogg.net/> .
85
- <http://greggkellogg.net/foaf#me> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://greggkellogg.net/foaf> .
36
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <https://bhuga.net/#ben> .
37
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <https://greggkellogg.net/foaf#me> .
38
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <https://ar.to/#self> .
39
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#created> "2007-10-23" .
40
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#shortdesc> "A Ruby library for working with Resource Description Framework (RDF) data."@en .
41
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <https://ar.to/> .
42
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <https://greggkellogg.net/> .
43
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#license> <https://unlicense.org/1.0/> .
44
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Ruby_(programming_language)> .
45
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Resource_Description_Framework> .
46
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#name> "RDF.rb" .
47
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#programming-language> "Ruby" .
48
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g6720 .
49
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g6680 .
50
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g6660 .
51
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g6740 .
52
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g6640 .
53
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g6780 .
54
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g6700 .
55
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g6560 .
56
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:g6760 .
57
+ <https://rubygems.org/gems/rdf> <http://xmlns.com/foaf/0.1/maker> <https://ar.to/#self> .
58
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <https://greggkellogg.net/foaf#me> .
59
+ <https://rubygems.org/gems/rdf> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://usefulinc.com/ns/doap#Project> .
60
+ <https://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#bug-database> <https://github.com/ruby-rdf/rdf/issues> .
61
+ <https://rubygems.org/gems/rdf> <http://purl.org/dc/terms/creator> <https://ar.to/#self> .
62
+ <https://greggkellogg.net/foaf#me> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <https://greggkellogg.net/foaf> .
63
+ <https://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/homepage> <https://greggkellogg.net/> .
64
+ <https://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/name> "Gregg Kellogg" .
65
+ <https://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/mbox> <mailto:gregg@greggkellogg.net> .
66
+ <https://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "35bc44e6d0070e5ad50ccbe0d24403c96af2b9bd" .
67
+ <https://greggkellogg.net/foaf#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
68
+ <https://ar.to/#self> <http://xmlns.com/foaf/0.1/homepage> <https://ar.to/> .
69
+ <https://ar.to/#self> <http://xmlns.com/foaf/0.1/name> "Arto Bendiken" .
70
+ <https://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox> <mailto:arto@bendiken.net> .
71
+ <https://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "a033f652c84a4d73b8c26d318c2395699dd2bdfb" .
72
+ <https://ar.to/#self> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
73
+ <https://ar.to/#self> <http://xmlns.com/foaf/0.1/made> <https://rubygems.org/gems/rdf> .
74
+ _:g6760 <http://xmlns.com/foaf/0.1/name> "Keita Urashima" .
75
+ _:g6760 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "2b4247b6fd5bb4a1383378f325784318680d5ff9" .
76
+ _:g6760 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
77
+ _:g6560 <http://xmlns.com/foaf/0.1/name> "Călin Ardelean" .
78
+ _:g6560 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "274bd18402fc773ffc0606996aa1fb90b603aa29" .
79
+ _:g6560 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
data/lib/rdf.rb CHANGED
@@ -6,6 +6,9 @@ require 'time'
6
6
  require 'rdf/version'
7
7
  require 'rdf/extensions'
8
8
 
9
+ # When loading, issue deprecation warning on forthcoming unsupported versions of Ruby
10
+ warn "[DEPRECATION] Ruby 2.4+ required in next version 3.1 of RDF.rb" if RUBY_VERSION < "2.4"
11
+
9
12
  module RDF
10
13
  # RDF mixins
11
14
  autoload :Countable, 'rdf/mixin/countable'
@@ -56,16 +59,18 @@ module RDF
56
59
  # RDF vocabularies
57
60
  autoload :Vocabulary, 'rdf/vocabulary'
58
61
  autoload :StrictVocabulary, 'rdf/vocabulary'
59
- VOCABS = Dir.glob(File.expand_path("../rdf/vocab/*.rb", __FILE__)).map { |f| File.basename(f)[0...-(File.extname(f).size)].to_sym } rescue []
60
62
 
61
- # Use const_missing instead of autoload to load most vocabularies so we can provide deprecation messages
62
- def self.const_missing(constant)
63
- if VOCABS.include?(constant.to_s.downcase.to_sym)
64
- require "rdf/vocab/#{constant.to_s.downcase}"
65
- const_get(constant)
66
- else
67
- super
68
- end
63
+ VOCABS = {
64
+ owl: {uri: "http://www.w3.org/2002/07/owl#", class_name: "OWL"},
65
+ rdfs: {uri: "http://www.w3.org/2000/01/rdf-schema#", class_name: "RDFS"},
66
+ rdfv: {uri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", class_name: "RDFV"},
67
+ xsd: {uri: "http://www.w3.org/2001/XMLSchema#", class_name: "XSD"},
68
+ }
69
+
70
+ # Autoload vocabularies
71
+ VOCABS.each do |id, params|
72
+ v = (params[:class_name] ||= id.to_s.upcase).to_sym
73
+ autoload v, File.expand_path("../rdf/vocab/#{id}", __FILE__)
69
74
  end
70
75
 
71
76
  # Utilities
@@ -76,8 +81,8 @@ module RDF
76
81
  #
77
82
  # @param (see RDF::Resource#initialize)
78
83
  # @return [RDF::Resource]
79
- def self.Resource(*args, &block)
80
- Resource.new(*args, &block)
84
+ def self.Resource(*args)
85
+ Resource.new(*args)
81
86
  end
82
87
 
83
88
  ##
@@ -85,8 +90,8 @@ module RDF
85
90
  #
86
91
  # @param (see RDF::Node#initialize)
87
92
  # @return [RDF::Node]
88
- def self.Node(*args, &block)
89
- Node.new(*args, &block)
93
+ def self.Node(*args)
94
+ Node.new(*args)
90
95
  end
91
96
 
92
97
  ##
@@ -94,8 +99,15 @@ module RDF
94
99
  #
95
100
  # @param (see RDF::URI#initialize)
96
101
  # @return [RDF::URI]
97
- def self.URI(uri, *args, &block)
98
- uri.respond_to?(:to_uri) ? uri.to_uri : URI.new(uri, *args, &block)
102
+ def self.URI(*args)
103
+ if args.first.respond_to?(:to_uri)
104
+ args.first.to_uri
105
+ elsif args.first.is_a?(Hash)
106
+ URI.new(**args.first)
107
+ else
108
+ opts = args.last.is_a?(Hash) ? args.pop : {}
109
+ URI.new(*args, **opts)
110
+ end
99
111
  end
100
112
 
101
113
  ##
@@ -103,10 +115,10 @@ module RDF
103
115
  #
104
116
  # @param (see RDF::Literal#initialize)
105
117
  # @return [RDF::Literal]
106
- def self.Literal(literal, *args, &block)
118
+ def self.Literal(literal, **options)
107
119
  case literal
108
120
  when RDF::Literal then literal
109
- else Literal.new(literal, *args, &block)
121
+ else Literal.new(literal, **options)
110
122
  end
111
123
  end
112
124
 
@@ -116,7 +128,7 @@ module RDF
116
128
  # @param (see RDF::Graph#initialize)
117
129
  # @return [RDF::Graph]
118
130
  def self.Graph(**options, &block)
119
- Graph.new(options, &block)
131
+ Graph.new(**options, &block)
120
132
  end
121
133
 
122
134
  ##
@@ -168,11 +180,11 @@ module RDF
168
180
  # @option options [RDF::Resource] :graph_name (nil)
169
181
  # @return [RDF::Statement]
170
182
  #
171
- def self.Statement(*args)
172
- if args.empty?
183
+ def self.Statement(*args, **options)
184
+ if args.empty? && options.empty?
173
185
  RDF[:Statement]
174
186
  else
175
- Statement.new(*args)
187
+ Statement.new(*args, **options)
176
188
  end
177
189
  end
178
190
 
@@ -190,8 +202,8 @@ module RDF
190
202
  #
191
203
  # @param (see RDF::Vocabulary#initialize)
192
204
  # @return [Class]
193
- def self.StrictVocabulary(prefix)
194
- StrictVocabulary.create(prefix)
205
+ def self.StrictVocabulary(uri)
206
+ StrictVocabulary.create(uri)
195
207
  end
196
208
 
197
209
  ##
@@ -31,10 +31,11 @@ module RDF
31
31
  #
32
32
  # @since 2.0.0
33
33
  class Changeset
34
- include RDF::Mutable
34
+ # include RDF::Mutable
35
+ include RDF::Util::Coercions
35
36
 
36
37
  ##
37
- # Applies a changeset to the given mutable RDF::Enumerable .
38
+ # Applies a changeset to the given {RDF::Mutable} object.
38
39
  #
39
40
  # @param [RDF::Mutable] mutable
40
41
  # @param [Hash{Symbol => Object}] options
@@ -42,7 +43,7 @@ module RDF
42
43
  # @yieldparam [RDF::Changeset] changes
43
44
  # @return [void]
44
45
  def self.apply(mutable, **options, &block)
45
- self.new(&block).apply(mutable, options)
46
+ self.new(&block).apply(mutable, **options)
46
47
  end
47
48
 
48
49
  ##
@@ -98,6 +99,24 @@ module RDF
98
99
  false
99
100
  end
100
101
 
102
+ ##
103
+ # Returns `false` as changesets are not {RDF::Writable}.
104
+ #
105
+ # @return [Boolean]
106
+ # @see RDF::Writable#writable?
107
+ def writable?
108
+ false
109
+ end
110
+
111
+ ##
112
+ # Returns `false` as changesets are not {RDF::Mutable}.
113
+ #
114
+ # @return [Boolean]
115
+ # @see RDF::Mutable#mutable?
116
+ def mutable?
117
+ false
118
+ end
119
+
101
120
  ##
102
121
  # Applies this changeset to the given mutable RDF::Enumerable.
103
122
  #
@@ -127,35 +146,84 @@ module RDF
127
146
 
128
147
  ##
129
148
  # Outputs a developer-friendly representation of this changeset to
130
- # `stderr`.
149
+ # `$stderr`.
131
150
  #
132
151
  # @return [void]
133
152
  def inspect!
134
153
  $stderr.puts(self.inspect)
135
154
  end
136
155
 
137
- protected
138
-
139
156
  ##
140
- # Appends an RDF statement to the sequence to insert when applied.
157
+ # Returns the sum of both the `inserts` and `deletes` counts.
141
158
  #
142
- # @param [RDF::Statement] statement
143
- # @return [void]
144
- # @see RDF::Writable#insert_statement
145
- def insert_statement(statement)
146
- self.inserts << statement
159
+ # @return [Integer]
160
+ def count
161
+ inserts.count + deletes.count
147
162
  end
148
163
 
164
+ # Append statements to `inserts`. Statements _should_ be constant
165
+ # as variable statements will at best be ignored or at worst raise
166
+ # an error when applied.
167
+ #
168
+ # @param statements [Enumerable, RDF::Statement] Some statements
169
+ # @return [self]
170
+ def insert(*statements)
171
+ coerce_statements(statements) do |stmts|
172
+ append_statements :inserts, stmts
173
+ end
174
+
175
+ self
176
+ end
177
+ alias_method :insert!, :insert
178
+ alias_method :<<, :insert
179
+
180
+ # Append statements to `deletes`. Statements _may_ contain
181
+ # variables, although support will depend on the {RDF::Mutable}
182
+ # target.
183
+ #
184
+ # @param statements [Enumerable, RDF::Statement] Some statements
185
+ # @return [self]
186
+ def delete(*statements)
187
+ coerce_statements(statements) do |stmts|
188
+ append_statements :deletes, stmts
189
+ end
190
+
191
+ self
192
+ end
193
+ alias_method :delete!, :delete
194
+ alias_method :>>, :delete
195
+
196
+ private
197
+
149
198
  ##
150
- # Appends an RDF statement to the sequence to delete when applied.
199
+ # Append statements to the appropriate target. This is a little
200
+ # shim to go in between the other shim and the target.
151
201
  #
152
- # @param [RDF::Statement] statement
153
- # @return [void]
154
- # @see RDF::Mutable#delete_statement
155
- def delete_statement(statement)
156
- self.deletes << statement
202
+ # @param target [Symbol] the method to send
203
+ # @param arg [Enumerable, RDF::Statement]
204
+ #
205
+ def append_statements(target, arg)
206
+ # coerce to an enumerator
207
+ stmts = case
208
+ when arg.is_a?(RDF::Statement)
209
+ [arg]
210
+ when arg.respond_to?(:each_statement)
211
+ arg.each_statement
212
+ when arg.respond_to?(:each)
213
+ arg
214
+ else
215
+ raise ArgumentError, "Invalid statement: #{arg.class}"
216
+ end
217
+
218
+ stmts.each { |s| send(target) << s }
219
+ end
220
+
221
+ # This simply returns its argument as a query in order to trick
222
+ # {RDF::Mutable#delete} into working.
223
+ def query(stmt)
224
+ RDF::Query.new RDF::Query::Pattern.from(stmt)
157
225
  end
158
226
 
159
- undef_method :load, :update, :clear
227
+ undef_method :load
160
228
  end # Changeset
161
229
  end # RDF