tripod 0.0.10 → 0.2
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.
- data/README.md +11 -5
- data/lib/tripod.rb +3 -0
- data/lib/tripod/attributes.rb +49 -57
- data/lib/tripod/components.rb +2 -0
- data/lib/tripod/errors.rb +1 -0
- data/lib/tripod/errors/field_not_present.rb +8 -0
- data/lib/tripod/fields.rb +4 -31
- data/lib/tripod/finders.rb +19 -12
- data/lib/tripod/persistence.rb +12 -0
- data/lib/tripod/predicates.rb +78 -0
- data/lib/tripod/repository.rb +20 -3
- data/lib/tripod/resource.rb +23 -24
- data/lib/tripod/serialization.rb +27 -0
- data/lib/tripod/sparql_client.rb +15 -4
- data/lib/tripod/version.rb +1 -1
- data/spec/app/models/person.rb +4 -0
- data/spec/tripod/attributes_spec.rb +79 -70
- data/spec/tripod/fields_spec.rb +15 -65
- data/spec/tripod/finders_spec.rb +14 -19
- data/spec/tripod/persistence_spec.rb +62 -58
- data/spec/tripod/predicates_spec.rb +82 -0
- data/spec/tripod/repository_spec.rb +53 -26
- data/spec/tripod/resource_spec.rb +20 -40
- data/spec/tripod/serialization_spec.rb +36 -0
- data/spec/tripod/state_spec.rb +2 -2
- data/tripod.gemspec +3 -2
- metadata +38 -20
@@ -4,60 +4,40 @@ describe Tripod::Resource do
|
|
4
4
|
|
5
5
|
describe "#initialize" do
|
6
6
|
|
7
|
-
|
8
|
-
Person.new()
|
7
|
+
it "should raise an error if the URI is given as nil" do
|
8
|
+
lambda { Person.new(nil) }.should raise_error(Tripod::Errors::UriNotSet)
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
person
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'uri passed in' do
|
17
|
-
|
18
|
-
context 'graph passed in' do
|
19
|
-
let(:person) do
|
20
|
-
Person.new('http://foobar', 'http://graph')
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'sets the uri instance variable' do
|
24
|
-
person.uri.should == RDF::URI.new('http://foobar')
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'sets the graph_uri instance variable' do
|
28
|
-
person.graph_uri.should == RDF::URI.new('http://graph')
|
29
|
-
end
|
11
|
+
context 'with a URI' do
|
12
|
+
let(:person) do
|
13
|
+
Person.new('http://foobar')
|
30
14
|
end
|
31
15
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
16
|
+
it 'sets the uri instance variable' do
|
17
|
+
person.uri.should == RDF::URI.new('http://foobar')
|
18
|
+
end
|
36
19
|
|
37
|
-
|
38
|
-
|
39
|
-
|
20
|
+
it 'sets the graph_uri instance variable from the class by default' do
|
21
|
+
person.graph_uri.should == RDF::URI.new('http://graph')
|
22
|
+
end
|
40
23
|
|
41
|
-
|
42
|
-
|
43
|
-
end
|
24
|
+
it "sets the rdf type from the class" do
|
25
|
+
person.rdf_type.should == 'http://person'
|
44
26
|
end
|
45
27
|
|
28
|
+
it "initialises a repo" do
|
29
|
+
person.repository.class.should == RDF::Repository
|
30
|
+
end
|
46
31
|
end
|
47
32
|
|
48
|
-
context '
|
49
|
-
|
33
|
+
context 'with a URI and a graph URI' do
|
50
34
|
let(:person) do
|
51
|
-
Person.new
|
35
|
+
Person.new('http://foobar', 'http://foobar/graph')
|
52
36
|
end
|
53
37
|
|
54
|
-
it
|
55
|
-
person.
|
56
|
-
person.graph_uri.should be_nil
|
38
|
+
it "overrides the default graph URI with what's given" do
|
39
|
+
person.graph_uri.should == RDF::URI.new('http://foobar/graph')
|
57
40
|
end
|
58
41
|
end
|
59
|
-
|
60
42
|
end
|
61
|
-
|
62
|
-
|
63
43
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Tripod::Serialization do
|
4
|
+
|
5
|
+
let(:person) do
|
6
|
+
p = Person.new('http://garry')
|
7
|
+
p.name = 'Garry'
|
8
|
+
p.age = 30
|
9
|
+
p
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#to_rdf" do
|
13
|
+
it "should dump the contents of the repository as rdfxml" do
|
14
|
+
person.to_rdf.should == person.repository.dump(:rdfxml)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#to_ttl" do
|
19
|
+
it "should dump the contents of the repository with the n3 serializer" do
|
20
|
+
person.to_ttl.should == person.repository.dump(:n3)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#to_nt" do
|
25
|
+
it "should dump the contents of the repository as ntriples" do
|
26
|
+
person.to_nt.should == person.repository.dump(:ntriples)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#to_json" do
|
31
|
+
it "should dump the contents of the repository as ntriples" do
|
32
|
+
person.to_json.should == person.repository.dump(:jsonld)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/spec/tripod/state_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe Tripod::State do
|
|
7
7
|
context "when calling new on the resource" do
|
8
8
|
|
9
9
|
let(:person) do
|
10
|
-
Person.new
|
10
|
+
Person.new('http://uri', 'http://graph')
|
11
11
|
end
|
12
12
|
|
13
13
|
it "returns true" do
|
@@ -54,7 +54,7 @@ describe Tripod::State do
|
|
54
54
|
describe "destroyed?" do
|
55
55
|
|
56
56
|
let(:person) do
|
57
|
-
Person.new
|
57
|
+
Person.new('http://uri', 'http://graph')
|
58
58
|
end
|
59
59
|
|
60
60
|
context "when destroyed is true" do
|
data/tripod.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["ric@swirrl.com"]
|
7
7
|
gem.description = %q{RDF ruby ORM}
|
8
8
|
gem.summary = %q{Active Model style RDF ORM}
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "http://github.com/Swirrl/tripod"
|
10
10
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
12
|
gem.files = `git ls-files`.split("\n")
|
@@ -21,9 +21,10 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_dependency "rest-client"
|
22
22
|
gem.add_dependency "activemodel", "~> 3.1"
|
23
23
|
gem.add_dependency "equivalent-xml"
|
24
|
-
gem.add_dependency "rdf", "~> 0
|
24
|
+
gem.add_dependency "rdf", "~> 1.0"
|
25
25
|
gem.add_dependency "rdf-rdfxml"
|
26
26
|
gem.add_dependency "rdf-n3"
|
27
27
|
gem.add_dependency "rdf-json"
|
28
|
+
gem.add_dependency "json-ld"
|
28
29
|
gem.add_dependency "guid"
|
29
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tripod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
16
|
-
requirement: &
|
16
|
+
requirement: &70356011065320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70356011065320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activemodel
|
27
|
-
requirement: &
|
27
|
+
requirement: &70356011064380 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.1'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70356011064380
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: equivalent-xml
|
38
|
-
requirement: &
|
38
|
+
requirement: &70356011063560 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,21 +43,21 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70356011063560
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdf
|
49
|
-
requirement: &
|
49
|
+
requirement: &70356011079140 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0
|
54
|
+
version: '1.0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70356011079140
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rdf-rdfxml
|
60
|
-
requirement: &
|
60
|
+
requirement: &70356011078020 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70356011078020
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rdf-n3
|
71
|
-
requirement: &
|
71
|
+
requirement: &70356011076860 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70356011076860
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rdf-json
|
82
|
-
requirement: &
|
82
|
+
requirement: &70356011076360 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,21 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70356011076360
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: json-ld
|
93
|
+
requirement: &70356011075640 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70356011075640
|
91
102
|
- !ruby/object:Gem::Dependency
|
92
103
|
name: guid
|
93
|
-
requirement: &
|
104
|
+
requirement: &70356011074860 !ruby/object:Gem::Requirement
|
94
105
|
none: false
|
95
106
|
requirements:
|
96
107
|
- - ! '>='
|
@@ -98,7 +109,7 @@ dependencies:
|
|
98
109
|
version: '0'
|
99
110
|
type: :runtime
|
100
111
|
prerelease: false
|
101
|
-
version_requirements: *
|
112
|
+
version_requirements: *70356011074860
|
102
113
|
description: RDF ruby ORM
|
103
114
|
email:
|
104
115
|
- ric@swirrl.com
|
@@ -115,6 +126,7 @@ files:
|
|
115
126
|
- lib/tripod/attributes.rb
|
116
127
|
- lib/tripod/components.rb
|
117
128
|
- lib/tripod/errors.rb
|
129
|
+
- lib/tripod/errors/field_not_present.rb
|
118
130
|
- lib/tripod/errors/resource_not_found.rb
|
119
131
|
- lib/tripod/errors/uri_not_set.rb
|
120
132
|
- lib/tripod/errors/validations.rb
|
@@ -124,8 +136,10 @@ files:
|
|
124
136
|
- lib/tripod/fields/standard.rb
|
125
137
|
- lib/tripod/finders.rb
|
126
138
|
- lib/tripod/persistence.rb
|
139
|
+
- lib/tripod/predicates.rb
|
127
140
|
- lib/tripod/repository.rb
|
128
141
|
- lib/tripod/resource.rb
|
142
|
+
- lib/tripod/serialization.rb
|
129
143
|
- lib/tripod/sparql_client.rb
|
130
144
|
- lib/tripod/state.rb
|
131
145
|
- lib/tripod/version.rb
|
@@ -135,11 +149,13 @@ files:
|
|
135
149
|
- spec/tripod/fields_spec.rb
|
136
150
|
- spec/tripod/finders_spec.rb
|
137
151
|
- spec/tripod/persistence_spec.rb
|
152
|
+
- spec/tripod/predicates_spec.rb
|
138
153
|
- spec/tripod/repository_spec.rb
|
139
154
|
- spec/tripod/resource_spec.rb
|
155
|
+
- spec/tripod/serialization_spec.rb
|
140
156
|
- spec/tripod/state_spec.rb
|
141
157
|
- tripod.gemspec
|
142
|
-
homepage:
|
158
|
+
homepage: http://github.com/Swirrl/tripod
|
143
159
|
licenses: []
|
144
160
|
post_install_message:
|
145
161
|
rdoc_options: []
|
@@ -170,7 +186,9 @@ test_files:
|
|
170
186
|
- spec/tripod/fields_spec.rb
|
171
187
|
- spec/tripod/finders_spec.rb
|
172
188
|
- spec/tripod/persistence_spec.rb
|
189
|
+
- spec/tripod/predicates_spec.rb
|
173
190
|
- spec/tripod/repository_spec.rb
|
174
191
|
- spec/tripod/resource_spec.rb
|
192
|
+
- spec/tripod/serialization_spec.rb
|
175
193
|
- spec/tripod/state_spec.rb
|
176
194
|
has_rdoc:
|