rdf-spec 1.0.9 → 1.1.0.p1
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 +14 -6
- data/AUTHORS +1 -1
- data/README +16 -23
- data/VERSION +1 -1
- data/etc/bendiken.nq +8 -8
- data/etc/bendiken.nt +8 -0
- data/etc/bendiken.ttl +17 -0
- data/etc/bhuga.nq +6 -6
- data/etc/bhuga.nt +6 -0
- data/etc/bhuga.ttl +15 -0
- data/etc/{triples.nt → doap.nq} +73 -76
- data/etc/doap.nt +39 -39
- data/etc/doap.ttl +79 -0
- data/etc/gkellogg.nq +5 -6
- data/etc/gkellogg.nt +5 -0
- data/etc/gkellogg.ttl +14 -0
- data/etc/test-data.nt +1 -0
- data/lib/rdf/spec.rb +0 -20
- data/lib/rdf/spec/countable.rb +26 -21
- data/lib/rdf/spec/durable.rb +13 -9
- data/lib/rdf/spec/enumerable.rb +314 -264
- data/lib/rdf/spec/format.rb +8 -9
- data/lib/rdf/spec/indexable.rb +13 -6
- data/lib/rdf/spec/matchers.rb +38 -38
- data/lib/rdf/spec/mutable.rb +81 -84
- data/lib/rdf/spec/queryable.rb +168 -195
- data/lib/rdf/spec/readable.rb +7 -3
- data/lib/rdf/spec/reader.rb +43 -43
- data/lib/rdf/spec/repository.rb +26 -15
- data/lib/rdf/spec/transaction.rb +90 -42
- data/lib/rdf/spec/writable.rb +55 -68
- data/lib/rdf/spec/writer.rb +36 -35
- data/spec/version_spec.rb +1 -1
- metadata +41 -34
- data/etc/quads.nq +0 -95
data/etc/doap.ttl
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
@base <http://rubygems.org/gems/rdf> .
|
2
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
3
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
4
|
+
@prefix dc: <http://purl.org/dc/terms/> .
|
5
|
+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
|
6
|
+
@prefix doap: <http://usefulinc.com/ns/doap#> .
|
7
|
+
|
8
|
+
<> a doap:Project ;
|
9
|
+
doap:name "RDF.rb" ;
|
10
|
+
doap:homepage <http://rubygems.org/gems/rdf> ;
|
11
|
+
doap:license <http://creativecommons.org/licenses/publicdomain/> ;
|
12
|
+
doap:shortdesc "A Ruby library for working with Resource Description Framework (RDF) data."@en ;
|
13
|
+
doap:description "RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data."@en ;
|
14
|
+
doap:created "2007-10-23" ;
|
15
|
+
doap:platform "Ruby" ;
|
16
|
+
doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
|
17
|
+
<http://dbpedia.org/resource/Ruby_(programming_language)> ;
|
18
|
+
doap:implements <http://www.w3.org/TR/rdf-concepts/>,
|
19
|
+
<http://sw.deri.org/2008/07/n-quads/>,
|
20
|
+
<http://www.w3.org/2001/sw/RDFCore/ntriples/> ;
|
21
|
+
doap:download-page <http://rubyforge.org/projects/rdf/> ;
|
22
|
+
doap:bug-database <http://github.com/ruby-rdf/rdf/issues> ;
|
23
|
+
doap:blog <http://ar.to/>, <http://blog.datagraph.org/> ;
|
24
|
+
doap:vendor <http://datagraph.org/> ;
|
25
|
+
doap:developer <http://ar.to/#self>, <http://bhuga.net/#ben>, <http://greggkellogg.net/foaf#me> ;
|
26
|
+
doap:maintainer <http://ar.to/#self>, <http://bhuga.net/#ben>, <http://greggkellogg.net/foaf#me> ;
|
27
|
+
doap:documenter <http://ar.to/#self>, <http://bhuga.net/#ben>, <http://greggkellogg.net/foaf#me> ;
|
28
|
+
doap:helper [a foaf:Person ;
|
29
|
+
foaf:name "Călin Ardelean" ;
|
30
|
+
foaf:mbox_sha1sum "274bd18402fc773ffc0606996aa1fb90b603aa29"] ;
|
31
|
+
doap:helper [a foaf:Person ;
|
32
|
+
foaf:name "Danny Gagne" ;
|
33
|
+
foaf:mbox_sha1sum "6de43e9cf7de53427fea9765706703e4d957c17b"] ;
|
34
|
+
doap:helper [a foaf:Person ;
|
35
|
+
foaf:name "Joey Geiger" ;
|
36
|
+
foaf:mbox_sha1sum "f412d743150d7b27b8468d56e69ca147917ea6fc"] ;
|
37
|
+
doap:helper [a foaf:Person ;
|
38
|
+
foaf:name "Fumihiro Kato" ;
|
39
|
+
foaf:mbox_sha1sum "d31fdd6af7a279a89bf09fdc9f7c44d9d08bb930"] ;
|
40
|
+
doap:helper [a foaf:Person ;
|
41
|
+
foaf:name "Naoki Kawamukai" ;
|
42
|
+
foaf:mbox_sha1sum "5bdcd8e2af4f5952aaeeffbdd371c41525ec761d"] ;
|
43
|
+
doap:helper [a foaf:Person ;
|
44
|
+
foaf:name "Hellekin O. Wolf" ;
|
45
|
+
foaf:mbox_sha1sum "c69f3255ff0639543cc5edfd8116eac8df16fab8"] ;
|
46
|
+
doap:helper [a foaf:Person ;
|
47
|
+
foaf:name "John Fieber" ;
|
48
|
+
foaf:mbox_sha1sum "f7653fc1ac0e82ebb32f092389bd5fc728eaae12"] ;
|
49
|
+
doap:helper [a foaf:Person ;
|
50
|
+
foaf:name "Keita Urashima" ;
|
51
|
+
foaf:mbox_sha1sum "2b4247b6fd5bb4a1383378f325784318680d5ff9"] ;
|
52
|
+
doap:helper [a foaf:Person ;
|
53
|
+
foaf:name "Pius Uzamere" ;
|
54
|
+
foaf:mbox_sha1sum "bedbbf2451e5beb38d59687c0460032aff92cd3c"] ;
|
55
|
+
foaf:maker <http://ar.to/#self> ;
|
56
|
+
dc:creator <http://ar.to/#self> .
|
57
|
+
|
58
|
+
<http://ar.to/#self> a foaf:Person ;
|
59
|
+
foaf:name "Arto Bendiken" ;
|
60
|
+
foaf:mbox <mailto:arto.bendiken@gmail.com> ;
|
61
|
+
foaf:mbox_sha1sum "d0737cceb55eb7d740578d2db1bc0727e3ed49ce",
|
62
|
+
"a033f652c84a4d73b8c26d318c2395699dd2bdfb" ;
|
63
|
+
foaf:homepage <http://ar.to/> ;
|
64
|
+
foaf:made <> ;
|
65
|
+
rdfs:isDefinedBy <http://datagraph.org/bendiken/foaf> .
|
66
|
+
|
67
|
+
<http://bhuga.net/#ben> a foaf:Person ;
|
68
|
+
foaf:name "Ben Lavender" ;
|
69
|
+
foaf:mbox <mailto:blavender@gmail.com> ;
|
70
|
+
foaf:mbox_sha1sum "dbf45f4ffbd27b67aa84f02a6a31c144727d10af" ;
|
71
|
+
foaf:homepage <http://bhuga.net/> ;
|
72
|
+
rdfs:isDefinedBy <http://datagraph.org/bhuga/foaf> .
|
73
|
+
|
74
|
+
<http://greggkellogg.net/foaf#me> a foaf:Person ;
|
75
|
+
foaf:name "Gregg Kellogg" ;
|
76
|
+
foaf:mbox <mailto:gregg@greggkellogg.net> ;
|
77
|
+
foaf:mbox_sha1sum "35bc44e6d0070e5ad50ccbe0d24403c96af2b9bd" ;
|
78
|
+
foaf:homepage <http://greggkellogg.net/>;
|
79
|
+
rdfs:isDefinedBy <http://greggkellogg.net/foaf> .
|
data/etc/gkellogg.nq
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
<http://greggkellogg.net
|
2
|
-
<http://greggkellogg.net
|
3
|
-
<http://greggkellogg.net
|
4
|
-
<http://greggkellogg.net
|
5
|
-
<http://greggkellogg.net
|
6
|
-
<http://greggkellogg.net/foaf#me> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://greggkellogg.net/foaf> <http://greggkellogg.net/foaf#me> .
|
1
|
+
<http://greggkellogg.net/#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> <http://greggkellogg.net/#me> .
|
2
|
+
<http://greggkellogg.net/#me> <http://xmlns.com/foaf/0.1/name> "Gregg Kellogg" <http://greggkellogg.net/#me> .
|
3
|
+
<http://greggkellogg.net/#me> <http://xmlns.com/foaf/0.1/mbox> <mailto:gregg@greggkellogg.net> <http://greggkellogg.net/#me> .
|
4
|
+
<http://greggkellogg.net/#me> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "b7a856d39fc3f02573271d9901f1f9107147f657" <http://greggkellogg.net/#me> .
|
5
|
+
<http://greggkellogg.net/#me> <http://xmlns.com/foaf/0.1/homepage> <http://greggkellogg.net/> <http://greggkellogg.net/#me> .
|
data/etc/gkellogg.nt
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
<http://greggkellogg.net/#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
2
|
+
<http://greggkellogg.net/#me> <http://xmlns.com/foaf/0.1/name> "Gregg Kellogg" .
|
3
|
+
<http://greggkellogg.net/#me> <http://xmlns.com/foaf/0.1/mbox> <mailto:gregg@greggkellogg.net> .
|
4
|
+
<http://greggkellogg.net/#me> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "b7a856d39fc3f02573271d9901f1f9107147f657" .
|
5
|
+
<http://greggkellogg.net/#me> <http://xmlns.com/foaf/0.1/homepage> <http://greggkellogg.net/> .
|
data/etc/gkellogg.ttl
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
@base <http://rubygems.org/gems/rdf> .
|
2
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
3
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
4
|
+
@prefix dc: <http://purl.org/dc/terms/> .
|
5
|
+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
|
6
|
+
@prefix doap: <http://usefulinc.com/ns/doap#> .
|
7
|
+
@prefix ex: <http://example.org/> .
|
8
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
9
|
+
|
10
|
+
<http://greggkellogg.net/#me> a foaf:Person ;
|
11
|
+
foaf:name "Gregg Kellogg" ;
|
12
|
+
foaf:mbox <mailto:gregg@greggkellogg.net> ;
|
13
|
+
foaf:mbox_sha1sum "b7a856d39fc3f02573271d9901f1f9107147f657" ;
|
14
|
+
foaf:homepage <http://greggkellogg.net/> .
|
data/etc/test-data.nt
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# Test data from SPARQLdata-r2/expr-equals
|
1
2
|
<http://example.org/xi1> <http://example.org/p> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
|
2
3
|
<http://example.org/xi2> <http://example.org/p> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
|
3
4
|
<http://example.org/xi3> <http://example.org/p> "01"^^<http://www.w3.org/2001/XMLSchema#integer> .
|
data/lib/rdf/spec.rb
CHANGED
@@ -46,25 +46,5 @@ module RDF
|
|
46
46
|
module Spec
|
47
47
|
autoload :Matchers, 'rdf/spec/matchers'
|
48
48
|
autoload :VERSION, 'rdf/spec/version'
|
49
|
-
TRIPLES_FILE = File.expand_path("../../../etc/triples.nt", __FILE__)
|
50
|
-
QUADS_FILE = File.expand_path("../../../etc/quads.nq", __FILE__)
|
51
|
-
|
52
|
-
##
|
53
|
-
# Return quads for tests
|
54
|
-
#
|
55
|
-
# @return [Array<RDF::Statement>]
|
56
|
-
def self.quads
|
57
|
-
require 'rdf/nquads'
|
58
|
-
(@quads ||= RDF::NQuads::Reader.new(File.open(QUADS_FILE)).to_a).dup
|
59
|
-
end
|
60
|
-
|
61
|
-
##
|
62
|
-
# Return triples for tests
|
63
|
-
#
|
64
|
-
# @return [Array<RDF::Statement>]
|
65
|
-
def self.triples
|
66
|
-
require 'rdf/ntriples'
|
67
|
-
(@triples ||= RDF::NTriples::Reader.new(File.open(TRIPLES_FILE)).to_a).dup
|
68
|
-
end
|
69
49
|
end # Spec
|
70
50
|
end # RDF
|
data/lib/rdf/spec/countable.rb
CHANGED
@@ -7,38 +7,43 @@ module RDF_Countable
|
|
7
7
|
before :each do
|
8
8
|
raise '+@countable+ must be defined in a before(:each) block' unless instance_variable_get('@countable')
|
9
9
|
|
10
|
-
@
|
10
|
+
@filename = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'etc', 'doap.nt'))
|
11
|
+
@statements = RDF::NTriples::Reader.new(File.open(@filename)).to_a
|
11
12
|
|
12
13
|
if @countable.empty?
|
13
|
-
if @countable.respond_to?(:<<)
|
14
|
+
if @countable.respond_to?(:<<)
|
14
15
|
@statements.each { |statement| @countable << statement }
|
15
16
|
else
|
16
|
-
raise "+@countable+ must respond to #<< or be pre-populated with the statements in #{
|
17
|
+
raise "+@countable+ must respond to #<< or be pre-populated with the statements in #{@filename} in a before(:each) block"
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
22
|
describe RDF::Countable do
|
22
|
-
|
23
|
-
|
24
|
-
it {should respond_to(:empty?)}
|
25
|
-
it {should_not be_empty}
|
26
|
-
it {should respond_to(:count)}
|
27
|
-
its(:count) {should == @statements.size}
|
28
|
-
it {should respond_to(:size)}
|
29
|
-
its(:size) {should == @statements.size}
|
30
|
-
|
31
|
-
context "when empty" do
|
32
|
-
subject {[].extend(RDF::Countable)}
|
33
|
-
it {should be_empty}
|
34
|
-
its(:count) {should == 0}
|
35
|
-
its(:size) {should == 0}
|
23
|
+
it "responds to #empty?" do
|
24
|
+
@countable.should respond_to(:empty?)
|
36
25
|
end
|
37
26
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
27
|
+
it "responds to #count and #size" do
|
28
|
+
@countable.should respond_to(:count, :size)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "implements #empty?" do
|
32
|
+
([].extend(RDF::Countable)).empty?.should be_true
|
33
|
+
([42].extend(RDF::Countable)).empty?.should be_false
|
34
|
+
@countable.empty?.should be_false
|
35
|
+
end
|
36
|
+
|
37
|
+
it "implements #count and #size" do
|
38
|
+
%w(count size).each do |method|
|
39
|
+
@countable.send(method).should >= @statements.size
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns countable enumerators" do
|
44
|
+
@countable.to_enum.should be_countable
|
45
|
+
@countable.enum_for.should be_countable
|
46
|
+
@countable.enum_for(:each).should be_countable
|
42
47
|
end
|
43
48
|
end
|
44
49
|
end
|
data/lib/rdf/spec/durable.rb
CHANGED
@@ -23,25 +23,29 @@ module RDF_Durable
|
|
23
23
|
|
24
24
|
before :each do
|
25
25
|
raise '+@load_durable+ must be defined in a before(:each) block' unless instance_variable_get('@load_durable')
|
26
|
+
# RDF::Queryable cares about the contents of this file too much to let someone set it
|
27
|
+
@filename = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'etc', 'doap.nt'))
|
26
28
|
end
|
27
29
|
|
28
30
|
describe RDF::Durable do
|
29
|
-
subject {@load_durable.call}
|
30
|
-
it {should respond_to(:durable?)}
|
31
31
|
it "should support #durable?" do
|
32
|
-
|
32
|
+
@load_durable.call.should respond_to(:durable?)
|
33
|
+
[true,false].member?(@load_durable.call.durable?).should be_true
|
33
34
|
end
|
34
35
|
|
35
|
-
it {should respond_to(:nondurable?)}
|
36
36
|
it "should support #nondurable?" do
|
37
|
-
|
37
|
+
@load_durable.call.should respond_to(:nondurable?)
|
38
|
+
[true,false].member?(@load_durable.call.nondurable?).should be_true
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should not be both durable and nondurable" do
|
42
|
+
@load_durable.call.nondurable?.should_not == @load_durable.call.durable?
|
38
43
|
end
|
39
|
-
its(:nondurable?) {should_not == subject.durable?}
|
40
44
|
|
41
45
|
it "should save contents between instantiations" do
|
42
|
-
if
|
43
|
-
|
44
|
-
|
46
|
+
if @load_durable.call.durable?
|
47
|
+
@load_durable.call.load(@filename)
|
48
|
+
@load_durable.call.count.should == File.readlines(@filename).size
|
45
49
|
end
|
46
50
|
end
|
47
51
|
end
|
data/lib/rdf/spec/enumerable.rb
CHANGED
@@ -7,36 +7,38 @@ module RDF_Enumerable
|
|
7
7
|
before :each do
|
8
8
|
raise '+@enumerable+ must be defined in a before(:each) block' unless instance_variable_get('@enumerable')
|
9
9
|
|
10
|
-
@
|
10
|
+
@filename = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'etc', 'doap.nt'))
|
11
|
+
@statements ||= RDF::NTriples::Reader.new(File.open(@filename)).to_a
|
11
12
|
|
12
13
|
if @enumerable.empty?
|
13
|
-
if @enumerable.respond_to?(:<<)
|
14
|
+
if @enumerable.respond_to?(:<<)
|
14
15
|
@statements.each { |statement| @enumerable << statement }
|
15
16
|
else
|
16
|
-
raise "@enumerable must respond to #<< or be pre-populated with the statements in #{
|
17
|
+
raise "@enumerable must respond to #<< or be pre-populated with the statements in #{@filename} in a before(:each) block"
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
|
-
@supports_context = @enumerable.supports?(:context)
|
21
|
+
@supports_context = @enumerable.respond_to?(:supports?) && @enumerable.supports?(:context)
|
21
22
|
end
|
22
23
|
|
23
24
|
describe RDF::Enumerable do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
it {should respond_to(:supports?)}
|
25
|
+
describe "#supports?" do
|
26
|
+
it "responds to #supports?" do
|
27
|
+
@enumerable.respond_to?(:support?)
|
28
|
+
end
|
29
|
+
end
|
30
30
|
|
31
31
|
describe "valid?" do
|
32
|
-
it
|
32
|
+
it "returns true if all statements are valid" do
|
33
|
+
@enumerable.should be_valid
|
34
|
+
end
|
33
35
|
|
34
36
|
it "returns false if any statement is invalid" do
|
35
|
-
if
|
37
|
+
if @enumerable.respond_to?(:<<)
|
36
38
|
s = RDF::Statement.from([nil, nil, nil])
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
s.should_not be_valid
|
40
|
+
@enumerable << s
|
41
|
+
@enumerable.should_not be_valid
|
40
42
|
else
|
41
43
|
pending("can't add statement to immutable enumerable")
|
42
44
|
end
|
@@ -44,383 +46,431 @@ module RDF_Enumerable
|
|
44
46
|
end
|
45
47
|
|
46
48
|
context "when counting statements" do
|
47
|
-
it
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
it
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
49
|
+
it "should respond to #empty?" do
|
50
|
+
@enumerable.should respond_to(:empty?)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should respond to #count and #size" do
|
54
|
+
@enumerable.should respond_to(*%w(count size))
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should implement #empty?" do
|
58
|
+
([].extend(RDF::Enumerable)).empty?.should be_true
|
59
|
+
@enumerable.empty?.should be_false
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should implement #count and #size" do
|
63
|
+
%w(count size).each do |method|
|
64
|
+
@enumerable.send(method).should == @statements.size
|
65
|
+
end
|
59
66
|
end
|
60
67
|
end
|
61
68
|
|
62
69
|
context "when enumerating statements" do
|
63
|
-
it
|
64
|
-
|
70
|
+
it "should respond to #statements" do
|
71
|
+
@enumerable.should respond_to(:statements)
|
72
|
+
end
|
65
73
|
|
66
|
-
|
67
|
-
|
68
|
-
specify {subject.statements.each { |statement| expect(statement).to be_a_statement }}
|
74
|
+
it "should respond to #has_statement?" do
|
75
|
+
@enumerable.should respond_to(:has_statement?)
|
69
76
|
end
|
70
77
|
|
71
|
-
it
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
78
|
+
it "should respond to #each_statement" do
|
79
|
+
@enumerable.should respond_to(:each_statement)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should respond to #enum_statement" do
|
83
|
+
@enumerable.should respond_to(:enum_statement)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should implement #statements" do
|
87
|
+
@enumerable.statements.should be_an_enumerator
|
88
|
+
@enumerable.statements.to_a.size.should == @statements.size
|
89
|
+
@enumerable.statements.each { |statement| statement.should be_a_statement }
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should implement #has_statement?" do
|
93
|
+
@statements.each do |statement|
|
94
|
+
@enumerable.has_statement?(statement).should be_true
|
79
95
|
end
|
80
96
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
expect(subject).not_to have_statement(s)
|
88
|
-
end
|
97
|
+
if @supports_context
|
98
|
+
context = RDF::URI.new("urn:context:1")
|
99
|
+
@statements.each do |statement|
|
100
|
+
s = statement.dup
|
101
|
+
s.context = context
|
102
|
+
@enumerable.has_statement?(s).should be_false
|
89
103
|
end
|
90
104
|
end
|
91
105
|
|
92
|
-
|
93
|
-
|
94
|
-
end
|
106
|
+
unknown_statement = RDF::Statement.new(RDF::Node.new, RDF::URI.new("http://example.org/unknown"), RDF::Node.new)
|
107
|
+
@enumerable.has_statement?(unknown_statement).should be_false
|
95
108
|
end
|
96
109
|
|
97
|
-
it {should respond_to(:each_statement)}
|
98
|
-
its(:each_statement) {should be_an_enumerator}
|
99
110
|
it "should implement #each_statement" do
|
100
|
-
|
111
|
+
@enumerable.each_statement.should be_an_enumerator
|
112
|
+
@enumerable.each_statement { |statement| statement.should be_a_statement }
|
101
113
|
end
|
102
114
|
|
103
|
-
it
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
it "should enumerate all statements" do
|
110
|
-
expect(subject.enum_statement.to_a).to include(*@enumerable.each_statement.to_a)
|
111
|
-
end
|
115
|
+
it "should implement #enum_statement" do
|
116
|
+
@enumerable.enum_statement.should be_an_enumerator
|
117
|
+
@enumerable.enum_statement.should be_countable
|
118
|
+
@enumerable.enum_statement.should be_enumerable
|
119
|
+
@enumerable.enum_statement.should be_queryable
|
120
|
+
@enumerable.enum_statement.to_a.should == @enumerable.each_statement.to_a
|
112
121
|
end
|
113
122
|
end
|
114
123
|
|
115
124
|
context "when enumerating triples" do
|
116
|
-
it
|
117
|
-
|
118
|
-
|
119
|
-
it {should respond_to(:enum_triple)}
|
125
|
+
it "should respond to #triples" do
|
126
|
+
@enumerable.should respond_to(:triples)
|
127
|
+
end
|
120
128
|
|
121
|
-
|
122
|
-
|
123
|
-
specify {expect(subject.triples.to_a.size).to eq @statements.size}
|
124
|
-
specify {subject.triples.each { |triple| expect(triple).to be_a_triple }}
|
129
|
+
it "should respond to #has_triple?" do
|
130
|
+
@enumerable.should respond_to(:has_triple?)
|
125
131
|
end
|
126
132
|
|
127
|
-
|
128
|
-
|
129
|
-
non_bnode_statements.each do |statement|
|
130
|
-
expect(subject).to have_triple(statement.to_triple)
|
131
|
-
end
|
132
|
-
end
|
133
|
+
it "should respond to #each_triple" do
|
134
|
+
@enumerable.should respond_to(:each_triple)
|
133
135
|
end
|
134
136
|
|
135
|
-
|
136
|
-
|
137
|
-
specify {subject.each_triple { |*triple| expect(triple).to be_a_triple }}
|
137
|
+
it "should respond to #enum_triple" do
|
138
|
+
@enumerable.should respond_to(:enum_triple)
|
138
139
|
end
|
139
140
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
141
|
+
it "should implement #triples" do
|
142
|
+
@enumerable.triples.should be_an_enumerator
|
143
|
+
@enumerable.triples.to_a.size.should == @statements.size
|
144
|
+
@enumerable.triples.each { |triple| triple.should be_a_triple }
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should implement #has_triple?" do
|
148
|
+
@statements.each do |statement|
|
149
|
+
@enumerable.has_triple?(statement.to_triple).should be_true
|
145
150
|
end
|
146
151
|
end
|
152
|
+
|
153
|
+
it "should implement #each_triple" do
|
154
|
+
@enumerable.each_triple.should be_an_enumerator
|
155
|
+
@enumerable.each_triple { |*triple| triple.should be_a_triple }
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should implement #enum_triple" do
|
159
|
+
@enumerable.enum_triple.should be_an_enumerator
|
160
|
+
@enumerable.enum_triple.should be_countable
|
161
|
+
@enumerable.enum_triple.to_a.should == @enumerable.each_triple.to_a
|
162
|
+
end
|
147
163
|
end
|
148
164
|
|
149
165
|
context "when enumerating quads" do
|
150
|
-
it
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
non_bnode_statements.each do |statement|
|
165
|
-
expect(subject).to have_quad(statement.to_quad)
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
166
|
+
it "should respond to #quads" do
|
167
|
+
@enumerable.should respond_to(:quads)
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should respond to #has_quad?" do
|
171
|
+
@enumerable.should respond_to(:has_quad?)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should respond to #each_quad" do
|
175
|
+
@enumerable.should respond_to(:each_quad)
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should respond to #enum_quad" do
|
179
|
+
@enumerable.should respond_to(:enum_quad)
|
169
180
|
end
|
170
181
|
|
171
|
-
|
172
|
-
|
173
|
-
|
182
|
+
it "should implement #quads" do
|
183
|
+
@enumerable.quads.should be_an_enumerator
|
184
|
+
@enumerable.quads.to_a.size.should == @statements.size
|
185
|
+
@enumerable.quads.each { |quad| quad.should be_a_quad }
|
174
186
|
end
|
175
187
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
it "should enumerate all quads" do
|
180
|
-
expect(subject.enum_quad.to_a).to include(*@enumerable.each_quad.to_a)
|
188
|
+
it "should implement #has_quad?" do
|
189
|
+
@statements.each do |statement|
|
190
|
+
@enumerable.has_quad?(statement.to_quad).should be_true
|
181
191
|
end
|
182
192
|
end
|
193
|
+
|
194
|
+
it "should implement #each_quad" do
|
195
|
+
@enumerable.each_quad.should be_an_enumerator
|
196
|
+
@enumerable.each_quad { |*quad| quad.should be_a_quad }
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should implement #enum_quad" do
|
200
|
+
@enumerable.enum_quad.should be_an_enumerator
|
201
|
+
@enumerable.enum_quad.should be_countable
|
202
|
+
@enumerable.enum_quad.to_a.should == @enumerable.each_quad.to_a
|
203
|
+
end
|
183
204
|
end
|
184
205
|
|
185
206
|
context "when enumerating subjects" do
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
it
|
191
|
-
|
192
|
-
|
193
|
-
|
207
|
+
it "should respond to #subjects" do
|
208
|
+
@enumerable.should respond_to(:subjects)
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should respond to #has_subject?" do
|
212
|
+
@enumerable.should respond_to(:has_subject?)
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should respond to #each_subject" do
|
216
|
+
@enumerable.should respond_to(:each_subject)
|
217
|
+
end
|
218
|
+
|
219
|
+
it "should respond to #enum_subject" do
|
220
|
+
@enumerable.should respond_to(:enum_subject)
|
221
|
+
end
|
222
|
+
|
223
|
+
describe "#subjects" do
|
194
224
|
subject {@enumerable.subjects}
|
195
|
-
specify {
|
196
|
-
specify {subject.each { |value|
|
225
|
+
specify {subject.should be_an_enumerator}
|
226
|
+
specify {subject.each { |value| value.should be_a_resource }}
|
197
227
|
context ":unique => false" do
|
198
228
|
subject {@enumerable.subjects(:unique => false)}
|
199
|
-
specify {
|
200
|
-
specify {subject.each { |value|
|
229
|
+
specify {subject.should be_an_enumerator}
|
230
|
+
specify {subject.each { |value| value.should be_a_resource }}
|
201
231
|
end
|
202
232
|
end
|
203
233
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
checked << statement.subject
|
210
|
-
end
|
211
|
-
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
212
|
-
expect(@enumerable).not_to have_subject(uri)
|
234
|
+
it "should implement #has_subject?" do
|
235
|
+
checked = []
|
236
|
+
@statements.each do |statement|
|
237
|
+
@enumerable.has_subject?(statement.subject).should be_true unless checked.include?(statement.subject)
|
238
|
+
checked << statement.subject
|
213
239
|
end
|
240
|
+
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
241
|
+
@enumerable.has_predicate?(uri).should be_false
|
214
242
|
end
|
215
243
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
244
|
+
it "should implement #each_subject" do
|
245
|
+
@enumerable.each_subject.should be_an_enumerator
|
246
|
+
subjects = @statements.map { |s| s.subject }.uniq
|
247
|
+
@enumerable.each_subject.to_a.size.should == subjects.size
|
248
|
+
@enumerable.each_subject do |value|
|
249
|
+
value.should be_a_value
|
250
|
+
subjects.should include(value)
|
251
|
+
end
|
221
252
|
end
|
222
253
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
expect(subject.enum_subject.reject(&:node?)).to include(*subjects)
|
228
|
-
end
|
254
|
+
it "should implement #enum_subject" do
|
255
|
+
@enumerable.enum_subject.should be_an_enumerator
|
256
|
+
@enumerable.enum_subject.should be_countable
|
257
|
+
@enumerable.enum_subject.to_a.should == @enumerable.each_subject.to_a
|
229
258
|
end
|
230
259
|
end
|
231
260
|
|
232
261
|
context "when enumerating predicates" do
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
it
|
238
|
-
|
239
|
-
|
240
|
-
|
262
|
+
it "should respond to #predicates" do
|
263
|
+
@enumerable.should respond_to(:predicates)
|
264
|
+
end
|
265
|
+
|
266
|
+
it "should respond to #has_predicate?" do
|
267
|
+
@enumerable.should respond_to(:has_predicate?)
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should respond to #each_predicate" do
|
271
|
+
@enumerable.should respond_to(:each_predicate)
|
272
|
+
end
|
273
|
+
|
274
|
+
it "should respond to #enum_predicate" do
|
275
|
+
@enumerable.should respond_to(:enum_predicate)
|
276
|
+
end
|
277
|
+
|
278
|
+
describe "#predicates" do
|
241
279
|
subject {@enumerable.predicates}
|
242
|
-
specify {
|
243
|
-
specify {subject.each { |value|
|
280
|
+
specify {subject.should be_an_enumerator}
|
281
|
+
specify {subject.each { |value| value.should be_a_uri }}
|
244
282
|
context ":unique => false" do
|
245
283
|
subject {@enumerable.predicates(:unique => false)}
|
246
|
-
specify {
|
247
|
-
specify {subject.each { |value|
|
284
|
+
specify {subject.should be_an_enumerator}
|
285
|
+
specify {subject.each { |value| value.should be_a_resource }}
|
248
286
|
end
|
249
287
|
end
|
250
288
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
@
|
255
|
-
|
256
|
-
checked << statement.predicate
|
257
|
-
end
|
258
|
-
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
259
|
-
expect(@enumerable).not_to have_predicate(uri)
|
289
|
+
it "should implement #has_predicate?" do
|
290
|
+
checked = []
|
291
|
+
@statements.each do |statement|
|
292
|
+
@enumerable.has_predicate?(statement.predicate).should be_true unless checked.include?(statement.object)
|
293
|
+
checked << statement.predicate
|
260
294
|
end
|
295
|
+
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
296
|
+
@enumerable.has_predicate?(uri).should be_false
|
261
297
|
end
|
262
298
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
299
|
+
it "should implement #each_predicate" do
|
300
|
+
predicates = @statements.map { |s| s.predicate }.uniq
|
301
|
+
@enumerable.each_predicate.should be_an_enumerator
|
302
|
+
@enumerable.each_predicate.to_a.size.should == predicates.size
|
303
|
+
@enumerable.each_predicate do |value|
|
304
|
+
value.should be_a_uri
|
305
|
+
predicates.should include(value)
|
306
|
+
end
|
268
307
|
end
|
269
308
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
expect(subject.enum_predicate.to_a).to include(*predicates)
|
275
|
-
end
|
309
|
+
it "should implement #enum_predicate" do
|
310
|
+
@enumerable.enum_predicate.should be_an_enumerator
|
311
|
+
@enumerable.enum_predicate.should be_countable
|
312
|
+
@enumerable.enum_predicate.to_a.should == @enumerable.each_predicate.to_a
|
276
313
|
end
|
277
314
|
end
|
278
315
|
|
279
316
|
context "when enumerating objects" do
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
it
|
285
|
-
|
286
|
-
|
287
|
-
|
317
|
+
it "should respond to #objects" do
|
318
|
+
@enumerable.should respond_to(:objects)
|
319
|
+
end
|
320
|
+
|
321
|
+
it "should respond to #has_object?" do
|
322
|
+
@enumerable.should respond_to(:has_object?)
|
323
|
+
end
|
324
|
+
|
325
|
+
it "should respond to #each_object" do
|
326
|
+
@enumerable.should respond_to(:each_object)
|
327
|
+
end
|
328
|
+
|
329
|
+
it "should respond to #enum_object" do
|
330
|
+
@enumerable.should respond_to(:enum_object)
|
331
|
+
end
|
332
|
+
|
333
|
+
describe "#objects" do
|
288
334
|
subject {@enumerable.objects}
|
289
|
-
specify {
|
290
|
-
specify {subject.each { |value|
|
335
|
+
specify {subject.should be_an_enumerator}
|
336
|
+
specify {subject.each { |value| value.should be_a_value }}
|
291
337
|
context ":unique => false" do
|
292
338
|
subject {@enumerable.objects(:unique => false)}
|
293
|
-
specify {
|
294
|
-
specify {subject.each { |value|
|
339
|
+
specify {subject.should be_an_enumerator}
|
340
|
+
specify {subject.each { |value| value.should be_a_value }}
|
295
341
|
end
|
296
342
|
end
|
297
343
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
checked << statement.object
|
304
|
-
end
|
305
|
-
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
306
|
-
expect(@enumerable).not_to have_object(uri)
|
344
|
+
it "should implement #has_object?" do
|
345
|
+
checked = []
|
346
|
+
@statements.each do |statement|
|
347
|
+
@enumerable.has_object?(statement.object).should be_true unless checked.include?(statement.object)
|
348
|
+
checked << statement.object
|
307
349
|
end
|
350
|
+
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
351
|
+
@enumerable.has_object?(uri).should be_false
|
308
352
|
end
|
309
353
|
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
354
|
+
it "should implement #each_object" do
|
355
|
+
objects = @statements.map { |s| s.object }.uniq
|
356
|
+
@enumerable.each_object.should be_an_enumerator
|
357
|
+
@enumerable.each_object.to_a.size.should == objects.size
|
358
|
+
@enumerable.each_object do |value|
|
359
|
+
value.should be_a_value
|
360
|
+
objects.should include(value)
|
361
|
+
end
|
315
362
|
end
|
316
363
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
expect(subject.enum_object.reject(&:node?)).to include(*objects)
|
322
|
-
end
|
364
|
+
it "should implement #enum_object" do
|
365
|
+
@enumerable.enum_object.should be_an_enumerator
|
366
|
+
@enumerable.enum_object.should be_countable
|
367
|
+
@enumerable.enum_object.to_a.should == @enumerable.each_object.to_a
|
323
368
|
end
|
324
369
|
end
|
325
370
|
|
326
371
|
context "when enumerating contexts" do
|
327
|
-
it
|
328
|
-
|
329
|
-
|
330
|
-
|
372
|
+
it "should respond to #contexts" do
|
373
|
+
@enumerable.should respond_to(:contexts)
|
374
|
+
end
|
375
|
+
|
376
|
+
it "should respond to #has_context?" do
|
377
|
+
@enumerable.should respond_to(:has_context?)
|
378
|
+
end
|
379
|
+
|
380
|
+
it "should respond to #each_context" do
|
381
|
+
@enumerable.should respond_to(:each_context)
|
382
|
+
end
|
383
|
+
|
384
|
+
it "should respond to #enum_context" do
|
385
|
+
@enumerable.should respond_to(:enum_context)
|
386
|
+
end
|
331
387
|
|
332
|
-
its(:contexts) {should be_an_enumerator}
|
333
388
|
describe "#contexts" do
|
334
389
|
subject {@enumerable.contexts}
|
335
|
-
specify {
|
336
|
-
|
337
|
-
subject.each { |value| expect(value).to be_a_resource }
|
338
|
-
end
|
390
|
+
specify {subject.should be_an_enumerator}
|
391
|
+
specify {subject.each { |value| value.should be_a_resource }}
|
339
392
|
context ":unique => false" do
|
340
393
|
subject {@enumerable.contexts(:unique => false)}
|
341
|
-
specify {
|
342
|
-
|
343
|
-
subject.each { |value| expect(value).to be_a_resource }
|
344
|
-
end
|
394
|
+
specify {subject.should be_an_enumerator}
|
395
|
+
specify {subject.each { |value| value.should be_a_resource }}
|
345
396
|
end
|
346
397
|
end
|
347
398
|
|
348
399
|
it "should implement #has_context?" do
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
expect(@enumerable).to have_context(statement.context)
|
353
|
-
end
|
400
|
+
@statements.each do |statement|
|
401
|
+
if statement.has_context?
|
402
|
+
@enumerable.has_context?(statement.context).should be_true
|
354
403
|
end
|
355
|
-
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
356
|
-
expect(@enumerable).not_to have_context(uri)
|
357
404
|
end
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
end
|
371
|
-
it "should have all contexts" do
|
372
|
-
subject.each_context {|value| expect(contexts).to include(value)}
|
405
|
+
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
406
|
+
@enumerable.has_context?(uri).should be_false
|
407
|
+
end
|
408
|
+
|
409
|
+
it "should implement #each_context" do
|
410
|
+
contexts = @statements.map { |s| s.context }.uniq
|
411
|
+
contexts.delete nil
|
412
|
+
@enumerable.each_context.should be_an_enumerator
|
413
|
+
@enumerable.each_context.to_a.size.should == contexts.size
|
414
|
+
@enumerable.each_context do |value|
|
415
|
+
value.should be_a_resource
|
416
|
+
contexts.should include(value)
|
373
417
|
end
|
374
418
|
end
|
375
419
|
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
expect(subject.enum_context.to_a).to include(*@enumerable.each_context.to_a)
|
381
|
-
end
|
420
|
+
it "should implement #enum_context" do
|
421
|
+
@enumerable.enum_context.should be_an_enumerator
|
422
|
+
@enumerable.enum_context.should be_countable
|
423
|
+
@enumerable.enum_context.to_a.should == @enumerable.each_context.to_a
|
382
424
|
end
|
383
425
|
end
|
384
426
|
|
385
427
|
context "when enumerating graphs" do
|
386
|
-
it
|
387
|
-
|
428
|
+
it "should respond to #each_graph" do
|
429
|
+
@enumerable.should respond_to(:enum_graph)
|
430
|
+
end
|
431
|
+
|
432
|
+
it "should respond to #enum_graph" do
|
433
|
+
@enumerable.should respond_to(:enum_graph)
|
434
|
+
end
|
388
435
|
|
389
436
|
describe "#each_graph" do
|
390
437
|
subject {@enumerable.each_graph}
|
391
438
|
it {should be_an_enumerator}
|
392
|
-
specify {subject.each { |value|
|
439
|
+
specify {subject.each { |value| value.should be_a_graph }}
|
393
440
|
end
|
394
441
|
|
395
442
|
describe "#enum_graph" do
|
396
443
|
subject {@enumerable.enum_graph}
|
397
|
-
it {should be_an_enumerator}
|
398
|
-
it {should be_countable}
|
444
|
+
it {subject.should be_an_enumerator}
|
445
|
+
it {subject.should be_countable}
|
399
446
|
it "enumerates the same as #each_graph" do
|
400
|
-
subject.to_a.should
|
447
|
+
subject.to_a.should == @enumerable.each_graph.to_a
|
401
448
|
end
|
402
449
|
end
|
403
450
|
end
|
404
451
|
|
405
452
|
context "when converting" do
|
406
|
-
it
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
453
|
+
it "should respond to #to_hash" do
|
454
|
+
@enumerable.should respond_to(:to_hash)
|
455
|
+
end
|
456
|
+
|
457
|
+
it "should implement #to_hash" do
|
458
|
+
@enumerable.to_hash.should be_instance_of(Hash)
|
459
|
+
@enumerable.to_hash.keys.size.should == @enumerable.subjects.to_a.size
|
412
460
|
end
|
413
461
|
end
|
414
462
|
|
415
463
|
context "when dumping" do
|
416
|
-
it
|
464
|
+
it "should respond to #dump" do
|
465
|
+
@enumerable.should respond_to(:dump)
|
466
|
+
end
|
417
467
|
|
418
468
|
it "should implement #dump" do
|
419
|
-
|
469
|
+
@enumerable.dump(:ntriples).should == RDF::NTriples::Writer.buffer() {|w| w << @enumerable}
|
420
470
|
end
|
421
471
|
|
422
472
|
it "raises error on unknown format" do
|
423
|
-
|
473
|
+
lambda {@enumerable.dump(:foobar)}.should raise_error(RDF::WriterError, /No writer found/)
|
424
474
|
end
|
425
475
|
end
|
426
476
|
end
|