redlander 0.3.6 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/ChangeLog +19 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +30 -0
- data/LICENSE +7 -0
- data/README.rdoc +85 -12
- data/Rakefile +5 -4
- data/lib/redland.rb +6 -2
- data/lib/redlander.rb +5 -3
- data/lib/redlander/model.rb +98 -16
- data/lib/redlander/model_proxy.rb +115 -58
- data/lib/redlander/node.rb +62 -59
- data/lib/redlander/parsing.rb +123 -0
- data/lib/redlander/serializing.rb +89 -0
- data/lib/redlander/statement.rb +61 -60
- data/lib/redlander/uri.rb +20 -13
- data/lib/redlander/version.rb +2 -1
- data/redlander.gemspec +28 -0
- data/spec/fixtures/doap.nt +62 -0
- data/spec/fixtures/doap.rdf +189 -0
- data/spec/fixtures/doap.ttl +53 -0
- data/spec/lib/redlander/model_spec.rb +304 -0
- data/spec/{redlander → lib/redlander}/node_spec.rb +26 -12
- data/spec/lib/redlander/statement_spec.rb +56 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +15 -4
- metadata +49 -37
- data/lib/redlander/error_container.rb +0 -42
- data/lib/redlander/parser.rb +0 -92
- data/lib/redlander/parser_proxy.rb +0 -22
- data/lib/redlander/serializer.rb +0 -85
- data/lib/redlander/storage.rb +0 -56
- data/lib/redlander/stream.rb +0 -57
- data/lib/redlander/stream_enumerator.rb +0 -17
- data/spec/redlander/model_spec.rb +0 -255
- data/spec/redlander/parser_spec.rb +0 -96
- data/spec/redlander/serializer_spec.rb +0 -52
- data/spec/redlander/statement_spec.rb +0 -77
data/lib/redlander/uri.rb
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
module Redlander
|
2
|
+
# @api private
|
3
|
+
# Uri (for internal use)
|
2
4
|
class Uri
|
5
|
+
# @api private
|
3
6
|
attr_reader :rdf_uri
|
4
7
|
|
8
|
+
# Create Redlander::Uri
|
9
|
+
#
|
10
|
+
# @param [URI, String] source String or URI object to wrap into Uri.
|
11
|
+
# @raise [NotImplementedError] if cannot create a Uri from the given source.
|
12
|
+
# @raise [RedlandError] if it fails to create a Uri.
|
5
13
|
def initialize(source)
|
6
14
|
@rdf_uri = case source
|
15
|
+
when FFI::Pointer
|
16
|
+
wrap(source)
|
7
17
|
when URI, String
|
8
18
|
Redland.librdf_new_uri(Redlander.rdf_world, source.to_s)
|
9
|
-
when Node
|
10
|
-
if source.resource?
|
11
|
-
copy_rdf_uri_on_initialize(Redland.librdf_node_get_uri(source.rdf_node))
|
12
|
-
elsif source.literal?
|
13
|
-
copy_rdf_uri_on_initialize(Redland.librdf_node_get_literal_value_datatype_uri(source.rdf_node))
|
14
|
-
else
|
15
|
-
raise NotImplementedError.new
|
16
|
-
end
|
17
19
|
else
|
18
|
-
#
|
19
|
-
raise NotImplementedError.new
|
20
|
+
raise NotImplementedError, "Cannot create Uri from '#{source.inspect}'"
|
20
21
|
end
|
21
|
-
raise RedlandError
|
22
|
+
raise RedlandError, "Failed to create Uri from '#{source.inspect}'" if @rdf_uri.null?
|
22
23
|
ObjectSpace.define_finalizer(self, proc { Redland.librdf_free_uri(@rdf_uri) })
|
23
24
|
end
|
24
25
|
|
@@ -26,12 +27,18 @@ module Redlander
|
|
26
27
|
Redland.librdf_uri_to_string(@rdf_uri)
|
27
28
|
end
|
28
29
|
|
30
|
+
def eql?(other_uri)
|
31
|
+
other_uri.is_a?(Uri) && (Redland.librdf_uri_equals(@rdf_uri, other_uri.rdf_uri) != 0)
|
32
|
+
end
|
33
|
+
alias_method :==, :eql?
|
34
|
+
|
29
35
|
|
30
36
|
private
|
31
37
|
|
32
|
-
|
38
|
+
# @api private
|
39
|
+
def wrap(u)
|
33
40
|
if u.null?
|
34
|
-
raise RedlandError
|
41
|
+
raise RedlandError, "Failed to create Uri"
|
35
42
|
else
|
36
43
|
Redland.librdf_new_uri_from_uri(u)
|
37
44
|
end
|
data/lib/redlander/version.rb
CHANGED
data/redlander.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path('../lib/redlander/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'redlander'
|
5
|
+
gem.authors = ['Slava Kravchenko']
|
6
|
+
gem.email = ['slava.kravchenko@gmail.com']
|
7
|
+
gem.version = ("$Release: #{Redlander::VERSION} $" =~ /[\.\d]+/) && $&
|
8
|
+
gem.platform = Gem::Platform::RUBY
|
9
|
+
gem.homepage = "https://github.com/cordawyn/redlander"
|
10
|
+
gem.summary = "Advanced Ruby bindings for Redland runtime library (librdf)."
|
11
|
+
gem.description = <<HERE
|
12
|
+
Redlander is Ruby bindings to Redland library (see http://librdf.org) written in C, which is used to manipulate RDF graphs. This is an alternative implementation of Ruby bindings (as opposed to the official bindings), aiming to be more intuitive, lightweight, high-performing and as bug-free as possible.
|
13
|
+
HERE
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($\)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
# gem.add_dependency("librdf0", "~> 1.0.14")
|
21
|
+
gem.add_dependency("xml_schema", "~> 0.1.0")
|
22
|
+
gem.add_dependency("ffi", "~> 1.1")
|
23
|
+
gem.add_development_dependency("rspec", "~> 2")
|
24
|
+
|
25
|
+
gem.license = "The MIT License (MIT)"
|
26
|
+
gem.extra_rdoc_files = ['README.rdoc', 'ChangeLog']
|
27
|
+
gem.has_rdoc = false
|
28
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<http://rubygems.org/gems/rdf> <http://purl.org/dc/terms/creator> <http://ar.to/#self> .
|
2
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://ar.to/> .
|
3
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://blog.datagraph.org/> .
|
4
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#bug-database> <http://github.com/bendiken/rdf/issues> .
|
5
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Resource_Description_Framework> .
|
6
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Ruby_(programming_language)> .
|
7
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#created> "2007-10-23" .
|
8
|
+
<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 .
|
9
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://ar.to/#self> .
|
10
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://bhuga.net/#ben> .
|
11
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://greggkellogg.net/foaf#me> .
|
12
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://ar.to/#self> .
|
13
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://bhuga.net/#ben> .
|
14
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://greggkellogg.net/foaf#me> .
|
15
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#download-page> <http://rubyforge.org/projects/rdf/> .
|
16
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid1 .
|
17
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid2 .
|
18
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid3 .
|
19
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid4 .
|
20
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid5 .
|
21
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid6 .
|
22
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid7 .
|
23
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid8 .
|
24
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid9 .
|
25
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#homepage> <http://rdf.rubyforge.org/> .
|
26
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#license> <http://creativecommons.org/licenses/publicdomain/> .
|
27
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://ar.to/#self> .
|
28
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://bhuga.net/#ben> .
|
29
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://greggkellogg.net/foaf#me> .
|
30
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#name> "RDF.rb" .
|
31
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#platform> "Ruby" .
|
32
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#shortdesc> "A Ruby library for working with Resource Description Framework (RDF) data."@en .
|
33
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#vendor> <http://datagraph.org/> .
|
34
|
+
<http://rubygems.org/gems/rdf> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://usefulinc.com/ns/doap#Project> .
|
35
|
+
<http://rubygems.org/gems/rdf> <http://xmlns.com/foaf/0.1/maker> <http://ar.to/#self> .
|
36
|
+
_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
37
|
+
_:genid1 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "274bd18402fc773ffc0606996aa1fb90b603aa29" .
|
38
|
+
_:genid1 <http://xmlns.com/foaf/0.1/name> "C\u0103lin Ardelean" .
|
39
|
+
_:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
40
|
+
_:genid2 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "6de43e9cf7de53427fea9765706703e4d957c17b" .
|
41
|
+
_:genid2 <http://xmlns.com/foaf/0.1/name> "Danny Gagne" .
|
42
|
+
_:genid3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
43
|
+
_:genid3 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f412d743150d7b27b8468d56e69ca147917ea6fc" .
|
44
|
+
_:genid3 <http://xmlns.com/foaf/0.1/name> "Joey Geiger" .
|
45
|
+
_:genid4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
46
|
+
_:genid4 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "d31fdd6af7a279a89bf09fdc9f7c44d9d08bb930" .
|
47
|
+
_:genid4 <http://xmlns.com/foaf/0.1/name> "Fumihiro Kato" .
|
48
|
+
_:genid5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
49
|
+
_:genid5 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "5bdcd8e2af4f5952aaeeffbdd371c41525ec761d" .
|
50
|
+
_:genid5 <http://xmlns.com/foaf/0.1/name> "Naoki Kawamukai" .
|
51
|
+
_:genid6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
52
|
+
_:genid6 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "c69f3255ff0639543cc5edfd8116eac8df16fab8" .
|
53
|
+
_:genid6 <http://xmlns.com/foaf/0.1/name> "Hellekin O. Wolf" .
|
54
|
+
_:genid7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
55
|
+
_:genid7 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f7653fc1ac0e82ebb32f092389bd5fc728eaae12" .
|
56
|
+
_:genid7 <http://xmlns.com/foaf/0.1/name> "John Fieber" .
|
57
|
+
_:genid8 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
58
|
+
_:genid8 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "2b4247b6fd5bb4a1383378f325784318680d5ff9" .
|
59
|
+
_:genid8 <http://xmlns.com/foaf/0.1/name> "Keita Urashima" .
|
60
|
+
_:genid9 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
61
|
+
_:genid9 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "bedbbf2451e5beb38d59687c0460032aff92cd3c" .
|
62
|
+
_:genid9 <http://xmlns.com/foaf/0.1/name> "Pius Uzamere" .
|
@@ -0,0 +1,189 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
3
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r10">
|
4
|
+
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
|
5
|
+
</rdf:Description>
|
6
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r10">
|
7
|
+
<ns0:name xmlns:ns0="http://xmlns.com/foaf/0.1/">Călin Ardelean</ns0:name>
|
8
|
+
</rdf:Description>
|
9
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r10">
|
10
|
+
<ns0:mbox_sha1sum xmlns:ns0="http://xmlns.com/foaf/0.1/">274bd18402fc773ffc0606996aa1fb90b603aa29</ns0:mbox_sha1sum>
|
11
|
+
</rdf:Description>
|
12
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r11">
|
13
|
+
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
|
14
|
+
</rdf:Description>
|
15
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r11">
|
16
|
+
<ns0:name xmlns:ns0="http://xmlns.com/foaf/0.1/">Danny Gagne</ns0:name>
|
17
|
+
</rdf:Description>
|
18
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r11">
|
19
|
+
<ns0:mbox_sha1sum xmlns:ns0="http://xmlns.com/foaf/0.1/">6de43e9cf7de53427fea9765706703e4d957c17b</ns0:mbox_sha1sum>
|
20
|
+
</rdf:Description>
|
21
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r12">
|
22
|
+
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
|
23
|
+
</rdf:Description>
|
24
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r12">
|
25
|
+
<ns0:name xmlns:ns0="http://xmlns.com/foaf/0.1/">Joey Geiger</ns0:name>
|
26
|
+
</rdf:Description>
|
27
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r12">
|
28
|
+
<ns0:mbox_sha1sum xmlns:ns0="http://xmlns.com/foaf/0.1/">f412d743150d7b27b8468d56e69ca147917ea6fc</ns0:mbox_sha1sum>
|
29
|
+
</rdf:Description>
|
30
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r13">
|
31
|
+
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
|
32
|
+
</rdf:Description>
|
33
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r13">
|
34
|
+
<ns0:name xmlns:ns0="http://xmlns.com/foaf/0.1/">Fumihiro Kato</ns0:name>
|
35
|
+
</rdf:Description>
|
36
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r13">
|
37
|
+
<ns0:mbox_sha1sum xmlns:ns0="http://xmlns.com/foaf/0.1/">d31fdd6af7a279a89bf09fdc9f7c44d9d08bb930</ns0:mbox_sha1sum>
|
38
|
+
</rdf:Description>
|
39
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r14">
|
40
|
+
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
|
41
|
+
</rdf:Description>
|
42
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r14">
|
43
|
+
<ns0:name xmlns:ns0="http://xmlns.com/foaf/0.1/">Naoki Kawamukai</ns0:name>
|
44
|
+
</rdf:Description>
|
45
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r14">
|
46
|
+
<ns0:mbox_sha1sum xmlns:ns0="http://xmlns.com/foaf/0.1/">5bdcd8e2af4f5952aaeeffbdd371c41525ec761d</ns0:mbox_sha1sum>
|
47
|
+
</rdf:Description>
|
48
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r15">
|
49
|
+
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
|
50
|
+
</rdf:Description>
|
51
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r15">
|
52
|
+
<ns0:name xmlns:ns0="http://xmlns.com/foaf/0.1/">Hellekin O. Wolf</ns0:name>
|
53
|
+
</rdf:Description>
|
54
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r15">
|
55
|
+
<ns0:mbox_sha1sum xmlns:ns0="http://xmlns.com/foaf/0.1/">c69f3255ff0639543cc5edfd8116eac8df16fab8</ns0:mbox_sha1sum>
|
56
|
+
</rdf:Description>
|
57
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r16">
|
58
|
+
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
|
59
|
+
</rdf:Description>
|
60
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r16">
|
61
|
+
<ns0:name xmlns:ns0="http://xmlns.com/foaf/0.1/">John Fieber</ns0:name>
|
62
|
+
</rdf:Description>
|
63
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r16">
|
64
|
+
<ns0:mbox_sha1sum xmlns:ns0="http://xmlns.com/foaf/0.1/">f7653fc1ac0e82ebb32f092389bd5fc728eaae12</ns0:mbox_sha1sum>
|
65
|
+
</rdf:Description>
|
66
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r17">
|
67
|
+
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
|
68
|
+
</rdf:Description>
|
69
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r17">
|
70
|
+
<ns0:name xmlns:ns0="http://xmlns.com/foaf/0.1/">Keita Urashima</ns0:name>
|
71
|
+
</rdf:Description>
|
72
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r17">
|
73
|
+
<ns0:mbox_sha1sum xmlns:ns0="http://xmlns.com/foaf/0.1/">2b4247b6fd5bb4a1383378f325784318680d5ff9</ns0:mbox_sha1sum>
|
74
|
+
</rdf:Description>
|
75
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r18">
|
76
|
+
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
|
77
|
+
</rdf:Description>
|
78
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r18">
|
79
|
+
<ns0:name xmlns:ns0="http://xmlns.com/foaf/0.1/">Pius Uzamere</ns0:name>
|
80
|
+
</rdf:Description>
|
81
|
+
<rdf:Description rdf:nodeID="r1342778465r20668r18">
|
82
|
+
<ns0:mbox_sha1sum xmlns:ns0="http://xmlns.com/foaf/0.1/">bedbbf2451e5beb38d59687c0460032aff92cd3c</ns0:mbox_sha1sum>
|
83
|
+
</rdf:Description>
|
84
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
85
|
+
<rdf:type rdf:resource="http://usefulinc.com/ns/doap#Project"/>
|
86
|
+
</rdf:Description>
|
87
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
88
|
+
<ns0:name xmlns:ns0="http://usefulinc.com/ns/doap#">RDF.rb</ns0:name>
|
89
|
+
</rdf:Description>
|
90
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
91
|
+
<ns0:homepage xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://rdf.rubyforge.org/"/>
|
92
|
+
</rdf:Description>
|
93
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
94
|
+
<ns0:license xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://creativecommons.org/licenses/publicdomain/"/>
|
95
|
+
</rdf:Description>
|
96
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
97
|
+
<ns0:shortdesc xmlns:ns0="http://usefulinc.com/ns/doap#" xml:lang="en">A Ruby library for working with Resource Description Framework (RDF) data.</ns0:shortdesc>
|
98
|
+
</rdf:Description>
|
99
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
100
|
+
<ns0:description xmlns:ns0="http://usefulinc.com/ns/doap#" xml:lang="en">RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data.</ns0:description>
|
101
|
+
</rdf:Description>
|
102
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
103
|
+
<ns0:created xmlns:ns0="http://usefulinc.com/ns/doap#">2007-10-23</ns0:created>
|
104
|
+
</rdf:Description>
|
105
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
106
|
+
<ns0:platform xmlns:ns0="http://usefulinc.com/ns/doap#">Ruby</ns0:platform>
|
107
|
+
</rdf:Description>
|
108
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
109
|
+
<ns0:category xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://dbpedia.org/resource/Resource_Description_Framework"/>
|
110
|
+
</rdf:Description>
|
111
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
112
|
+
<ns0:category xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://dbpedia.org/resource/Ruby_(programming_language)"/>
|
113
|
+
</rdf:Description>
|
114
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
115
|
+
<ns0:download-page xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://rubyforge.org/projects/rdf/"/>
|
116
|
+
</rdf:Description>
|
117
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
118
|
+
<ns0:bug-database xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://github.com/bendiken/rdf/issues"/>
|
119
|
+
</rdf:Description>
|
120
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
121
|
+
<ns0:blog xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://ar.to/"/>
|
122
|
+
</rdf:Description>
|
123
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
124
|
+
<ns0:blog xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://blog.datagraph.org/"/>
|
125
|
+
</rdf:Description>
|
126
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
127
|
+
<ns0:vendor xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://datagraph.org/"/>
|
128
|
+
</rdf:Description>
|
129
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
130
|
+
<ns0:developer xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://ar.to/#self"/>
|
131
|
+
</rdf:Description>
|
132
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
133
|
+
<ns0:developer xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://bhuga.net/#ben"/>
|
134
|
+
</rdf:Description>
|
135
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
136
|
+
<ns0:developer xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://greggkellogg.net/foaf#me"/>
|
137
|
+
</rdf:Description>
|
138
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
139
|
+
<ns0:maintainer xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://ar.to/#self"/>
|
140
|
+
</rdf:Description>
|
141
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
142
|
+
<ns0:maintainer xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://bhuga.net/#ben"/>
|
143
|
+
</rdf:Description>
|
144
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
145
|
+
<ns0:maintainer xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://greggkellogg.net/foaf#me"/>
|
146
|
+
</rdf:Description>
|
147
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
148
|
+
<ns0:documenter xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://ar.to/#self"/>
|
149
|
+
</rdf:Description>
|
150
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
151
|
+
<ns0:documenter xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://bhuga.net/#ben"/>
|
152
|
+
</rdf:Description>
|
153
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
154
|
+
<ns0:documenter xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:resource="http://greggkellogg.net/foaf#me"/>
|
155
|
+
</rdf:Description>
|
156
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
157
|
+
<ns0:helper xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:nodeID="r1342778465r20668r10"/>
|
158
|
+
</rdf:Description>
|
159
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
160
|
+
<ns0:helper xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:nodeID="r1342778465r20668r11"/>
|
161
|
+
</rdf:Description>
|
162
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
163
|
+
<ns0:helper xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:nodeID="r1342778465r20668r12"/>
|
164
|
+
</rdf:Description>
|
165
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
166
|
+
<ns0:helper xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:nodeID="r1342778465r20668r13"/>
|
167
|
+
</rdf:Description>
|
168
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
169
|
+
<ns0:helper xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:nodeID="r1342778465r20668r14"/>
|
170
|
+
</rdf:Description>
|
171
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
172
|
+
<ns0:helper xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:nodeID="r1342778465r20668r15"/>
|
173
|
+
</rdf:Description>
|
174
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
175
|
+
<ns0:helper xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:nodeID="r1342778465r20668r16"/>
|
176
|
+
</rdf:Description>
|
177
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
178
|
+
<ns0:helper xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:nodeID="r1342778465r20668r17"/>
|
179
|
+
</rdf:Description>
|
180
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
181
|
+
<ns0:helper xmlns:ns0="http://usefulinc.com/ns/doap#" rdf:nodeID="r1342778465r20668r18"/>
|
182
|
+
</rdf:Description>
|
183
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
184
|
+
<ns0:maker xmlns:ns0="http://xmlns.com/foaf/0.1/" rdf:resource="http://ar.to/#self"/>
|
185
|
+
</rdf:Description>
|
186
|
+
<rdf:Description rdf:about="http://rubygems.org/gems/rdf">
|
187
|
+
<ns0:creator xmlns:ns0="http://purl.org/dc/terms/" rdf:resource="http://ar.to/#self"/>
|
188
|
+
</rdf:Description>
|
189
|
+
</rdf:RDF>
|
@@ -0,0 +1,53 @@
|
|
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://rdf.rubyforge.org/> ;
|
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:download-page <http://rubyforge.org/projects/rdf/> ;
|
19
|
+
doap:bug-database <http://github.com/bendiken/rdf/issues> ;
|
20
|
+
doap:blog <http://ar.to/>, <http://blog.datagraph.org/> ;
|
21
|
+
doap:vendor <http://datagraph.org/> ;
|
22
|
+
doap:developer <http://ar.to/#self>, <http://bhuga.net/#ben>, <http://greggkellogg.net/foaf#me> ;
|
23
|
+
doap:maintainer <http://ar.to/#self>, <http://bhuga.net/#ben>, <http://greggkellogg.net/foaf#me> ;
|
24
|
+
doap:documenter <http://ar.to/#self>, <http://bhuga.net/#ben>, <http://greggkellogg.net/foaf#me> ;
|
25
|
+
doap:helper [a foaf:Person ;
|
26
|
+
foaf:name "Călin Ardelean" ;
|
27
|
+
foaf:mbox_sha1sum "274bd18402fc773ffc0606996aa1fb90b603aa29"] ;
|
28
|
+
doap:helper [a foaf:Person ;
|
29
|
+
foaf:name "Danny Gagne" ;
|
30
|
+
foaf:mbox_sha1sum "6de43e9cf7de53427fea9765706703e4d957c17b"] ;
|
31
|
+
doap:helper [a foaf:Person ;
|
32
|
+
foaf:name "Joey Geiger" ;
|
33
|
+
foaf:mbox_sha1sum "f412d743150d7b27b8468d56e69ca147917ea6fc"] ;
|
34
|
+
doap:helper [a foaf:Person ;
|
35
|
+
foaf:name "Fumihiro Kato" ;
|
36
|
+
foaf:mbox_sha1sum "d31fdd6af7a279a89bf09fdc9f7c44d9d08bb930"] ;
|
37
|
+
doap:helper [a foaf:Person ;
|
38
|
+
foaf:name "Naoki Kawamukai" ;
|
39
|
+
foaf:mbox_sha1sum "5bdcd8e2af4f5952aaeeffbdd371c41525ec761d"] ;
|
40
|
+
doap:helper [a foaf:Person ;
|
41
|
+
foaf:name "Hellekin O. Wolf" ;
|
42
|
+
foaf:mbox_sha1sum "c69f3255ff0639543cc5edfd8116eac8df16fab8"] ;
|
43
|
+
doap:helper [a foaf:Person ;
|
44
|
+
foaf:name "John Fieber" ;
|
45
|
+
foaf:mbox_sha1sum "f7653fc1ac0e82ebb32f092389bd5fc728eaae12"] ;
|
46
|
+
doap:helper [a foaf:Person ;
|
47
|
+
foaf:name "Keita Urashima" ;
|
48
|
+
foaf:mbox_sha1sum "2b4247b6fd5bb4a1383378f325784318680d5ff9"] ;
|
49
|
+
doap:helper [a foaf:Person ;
|
50
|
+
foaf:name "Pius Uzamere" ;
|
51
|
+
foaf:mbox_sha1sum "bedbbf2451e5beb38d59687c0460032aff92cd3c"] ;
|
52
|
+
foaf:maker <http://ar.to/#self> ;
|
53
|
+
dc:creator <http://ar.to/#self> .
|
@@ -0,0 +1,304 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Model do
|
4
|
+
let(:model) { described_class.new }
|
5
|
+
subject { model }
|
6
|
+
|
7
|
+
describe "statements" do
|
8
|
+
subject { model.statements }
|
9
|
+
|
10
|
+
it { should be_an_instance_of(ModelProxy) }
|
11
|
+
|
12
|
+
context "for a non-countable storage" do
|
13
|
+
before do
|
14
|
+
subject.create(statement_attributes)
|
15
|
+
Redland.stub(:librdf_model_size => -1)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return size derived from count" do
|
19
|
+
subject.size.should eql subject.count
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when enumerated" do
|
24
|
+
context "without a block" do
|
25
|
+
subject { model.statements.each }
|
26
|
+
|
27
|
+
it { should be_a Enumerator }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with a block" do
|
31
|
+
before do
|
32
|
+
@statement = subject.create(statement_attributes)
|
33
|
+
@statements = []
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should be iterated over" do
|
37
|
+
expect {
|
38
|
+
subject.each { |s| @statements << s }
|
39
|
+
}.to change(@statements, :size).by(1)
|
40
|
+
expect(@statements).to include @statement
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when searched" do
|
46
|
+
subject { model.statements.find(:first, @conditions) }
|
47
|
+
|
48
|
+
before { @statement = model.statements.create(statement_attributes) }
|
49
|
+
|
50
|
+
context "with empty conditions" do
|
51
|
+
before { @conditions = {} }
|
52
|
+
|
53
|
+
it { should eql @statement }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "with matching conditions" do
|
57
|
+
before { @conditions = {:object => @statement.object} }
|
58
|
+
|
59
|
+
it { should eql @statement }
|
60
|
+
end
|
61
|
+
|
62
|
+
context "with non-matching conditions" do
|
63
|
+
before { @conditions = {:object => "another object"} }
|
64
|
+
|
65
|
+
it { should be_nil }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when adding" do
|
70
|
+
context "via #create" do
|
71
|
+
it "should be created in the model" do
|
72
|
+
expect { subject.create(statement_attributes) }.to change(subject, :size).by(1)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should not add duplicate statements" do
|
76
|
+
expect {
|
77
|
+
2.times { subject.create(statement_attributes) }
|
78
|
+
}.to change(subject, :size).by(1)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "via #add" do
|
83
|
+
before { @statement = Statement.new(statement_attributes) }
|
84
|
+
|
85
|
+
it "should be added to the model" do
|
86
|
+
expect { subject.add(@statement) }.to change(subject, :size).by(1)
|
87
|
+
subject.should include(@statement)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should not add duplicate statements" do
|
91
|
+
expect {
|
92
|
+
2.times { subject.add(@statement) }
|
93
|
+
}.to change(subject, :size).by(1)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "when deleting" do
|
99
|
+
before { @statement = subject.create(statement_attributes) }
|
100
|
+
|
101
|
+
it "should be removed from the model" do
|
102
|
+
expect { subject.delete(@statement) }.to change(subject, :size).by(-1)
|
103
|
+
subject.should_not include(@statement)
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "all statements" do
|
107
|
+
before { subject.create(statement_attributes.merge(:object => "another one")) }
|
108
|
+
|
109
|
+
it "should completely wipe the model" do
|
110
|
+
expect { subject.delete_all }.to change(subject, :size).from(2).to(0)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def statement_attributes
|
119
|
+
s = URI.parse('http://example.com/concepts#subject')
|
120
|
+
p = URI.parse('http://example.com/concepts#label')
|
121
|
+
o = "subject!"
|
122
|
+
{
|
123
|
+
:subject => s,
|
124
|
+
:predicate => p,
|
125
|
+
:object => o
|
126
|
+
}
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "serialization" do
|
131
|
+
before do
|
132
|
+
s = URI.parse("http://example.com/concepts#two-dimensional_seismic_imaging")
|
133
|
+
p = URI.parse("http://www.w3.org/2000/01/rdf-schema#label")
|
134
|
+
o = "2-D seismic imaging@en"
|
135
|
+
subject.statements.create(:subject => s, :predicate => p, :object => o)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should produce RDF/XML content" do
|
139
|
+
content = subject.to_rdfxml
|
140
|
+
content.should be_an_instance_of(String)
|
141
|
+
content.should include('2-D seismic imaging')
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should produce N-Triples content" do
|
145
|
+
content = subject.to_ntriples
|
146
|
+
content.should be_an_instance_of(String)
|
147
|
+
content.should include('2-D seismic imaging@en')
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should produce Turtle content" do
|
151
|
+
content = subject.to_turtle
|
152
|
+
content.should be_an_instance_of(String)
|
153
|
+
content.should include('2-D seismic imaging@en')
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should produce JSON content" do
|
157
|
+
content = subject.to_json
|
158
|
+
content.should be_an_instance_of(String)
|
159
|
+
content.should include('2-D seismic imaging@en')
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should produce DOT content" do
|
163
|
+
content = subject.to_dot
|
164
|
+
content.should be_an_instance_of(String)
|
165
|
+
content.should include('2-D seismic imaging@en')
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "file destination" do
|
169
|
+
before { cleanup }
|
170
|
+
|
171
|
+
after { cleanup }
|
172
|
+
|
173
|
+
it "should produce a file" do
|
174
|
+
subject.to_file(filename)
|
175
|
+
File.should be_exists(filename)
|
176
|
+
File.size(filename).should_not be_zero
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
private
|
181
|
+
|
182
|
+
def cleanup
|
183
|
+
File.delete(filename) if File.exists?(filename)
|
184
|
+
end
|
185
|
+
|
186
|
+
def filename
|
187
|
+
"test_model.rdf"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "deserialization" do
|
192
|
+
it "should return an instance of Model" do
|
193
|
+
source = URI("file://#{Redlander.fixture_path('doap.rdf')}")
|
194
|
+
subject.from(source, :format => "rdfxml").should be_a Model
|
195
|
+
end
|
196
|
+
|
197
|
+
context "from RDF/XML" do
|
198
|
+
before { @filename = Redlander.fixture_path("doap.rdf") }
|
199
|
+
|
200
|
+
it "should parse from string" do
|
201
|
+
expect {
|
202
|
+
subject.from_rdfxml File.read(@filename), :base_uri => "http://rubygems.org/gems/rdf"
|
203
|
+
}.to change(subject.statements, :size).by(62)
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should parse from URI/file" do
|
207
|
+
expect {
|
208
|
+
subject.from_rdfxml URI("file://" + @filename), :base_uri => "http://rubygems.org/gems/rdf"
|
209
|
+
}.to change(subject.statements, :size).by(62)
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should filter statements" do
|
213
|
+
filter_object = URI("http://ar.to/#self")
|
214
|
+
expect {
|
215
|
+
subject.from_rdfxml URI("file://" + @filename), :base_uri => "http://rubygems.org/gems/rdf" do |st|
|
216
|
+
st.object.resource? ? st.object.uri != filter_object : true
|
217
|
+
end
|
218
|
+
}.to change(subject.statements, :size).by(57)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
context "from NTriples" do
|
223
|
+
before { @filename = Redlander.fixture_path("doap.nt") }
|
224
|
+
|
225
|
+
it "should parse from string" do
|
226
|
+
expect {
|
227
|
+
subject.from_ntriples File.read(@filename)
|
228
|
+
}.to change(subject.statements, :size).by(62)
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should parse from URI/file" do
|
232
|
+
expect {
|
233
|
+
subject.from_ntriples URI("file://" + @filename)
|
234
|
+
}.to change(subject.statements, :size).by(62)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
context "from Turtle" do
|
239
|
+
before { @filename = Redlander.fixture_path("doap.ttl") }
|
240
|
+
|
241
|
+
it "should parse from string" do
|
242
|
+
expect {
|
243
|
+
subject.from_turtle File.read(@filename), :base_uri => "http://rubygems.org/gems/rdf"
|
244
|
+
}.to change(subject.statements, :size).by(62)
|
245
|
+
end
|
246
|
+
|
247
|
+
it "should parse from URI/file" do
|
248
|
+
expect {
|
249
|
+
subject.from_turtle URI("file://" + @filename), :base_uri => "http://rubygems.org/gems/rdf"
|
250
|
+
}.to change(subject.statements, :size).by(62)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
describe "transactions" do
|
256
|
+
before do
|
257
|
+
Redland.stub(:librdf_model_transaction_start => 0,
|
258
|
+
:librdf_model_transaction_commit => 0,
|
259
|
+
:librdf_model_transaction_rollback => 0)
|
260
|
+
end
|
261
|
+
|
262
|
+
context "when start fails" do
|
263
|
+
before { Redland.stub(:librdf_model_transaction_start => -1) }
|
264
|
+
|
265
|
+
it "should not raise RedlandError" do
|
266
|
+
lambda {
|
267
|
+
subject.transaction { true }
|
268
|
+
}.should_not raise_exception RedlandError
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should raise RedlandError" do
|
272
|
+
expect { subject.transaction_start! }.to raise_exception RedlandError
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
context "when commit fails" do
|
277
|
+
before { Redland.stub(:librdf_model_transaction_commit => -1) }
|
278
|
+
|
279
|
+
it "should not raise RedlandError" do
|
280
|
+
lambda {
|
281
|
+
subject.transaction { true }
|
282
|
+
}.should_not raise_exception RedlandError
|
283
|
+
end
|
284
|
+
|
285
|
+
it "should raise RedlandError" do
|
286
|
+
expect { subject.transaction_commit! }.to raise_exception RedlandError
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
context "when rollback fails" do
|
291
|
+
before { Redland.stub(:librdf_model_transaction_rollback => -1) }
|
292
|
+
|
293
|
+
it "should not raise RedlandError" do
|
294
|
+
lambda {
|
295
|
+
subject.rollback
|
296
|
+
}.should_not raise_exception RedlandError
|
297
|
+
end
|
298
|
+
|
299
|
+
it "should raise RedlandError" do
|
300
|
+
expect { subject.transaction_rollback! }.to raise_exception RedlandError
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|