ld4l-open_annotation_rdf 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -6
- data/Gemfile +3 -0
- data/README.md +5 -0
- data/ld4l-open_annotation_rdf.gemspec +4 -8
- data/lib/ld4l/open_annotation_rdf.rb +1 -26
- data/lib/ld4l/open_annotation_rdf/annotation.rb +28 -30
- data/lib/ld4l/open_annotation_rdf/annotation_generic_body.rb +12 -0
- data/lib/ld4l/open_annotation_rdf/comment_annotation.rb +3 -6
- data/lib/ld4l/open_annotation_rdf/comment_body.rb +4 -4
- data/lib/ld4l/open_annotation_rdf/semantic_tag_annotation.rb +3 -6
- data/lib/ld4l/open_annotation_rdf/semantic_tag_body.rb +3 -3
- data/lib/ld4l/open_annotation_rdf/tag_annotation.rb +3 -5
- data/lib/ld4l/open_annotation_rdf/tag_body.rb +7 -7
- data/lib/ld4l/open_annotation_rdf/version.rb +1 -1
- data/spec/ld4l/open_annotation_rdf/annotation_spec.rb +79 -70
- data/spec/ld4l/open_annotation_rdf/comment_annotation_spec.rb +46 -40
- data/spec/ld4l/open_annotation_rdf/comment_body_spec.rb +46 -43
- data/spec/ld4l/open_annotation_rdf/configuration_spec.rb +5 -5
- data/spec/ld4l/open_annotation_rdf/semantic_tag_annotation_spec.rb +46 -42
- data/spec/ld4l/open_annotation_rdf/semantic_tag_body_spec.rb +24 -31
- data/spec/ld4l/open_annotation_rdf/tag_annotation_spec.rb +46 -42
- data/spec/ld4l/open_annotation_rdf/tag_body_spec.rb +28 -35
- data/spec/ld4l/open_annotation_rdf_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -2
- metadata +13 -69
- data/lib/ld4l/open_annotation_rdf/vocab/cnt.rb +0 -6
- data/lib/ld4l/open_annotation_rdf/vocab/dctypes.rb +0 -5
- data/lib/ld4l/open_annotation_rdf/vocab/oa.rb +0 -23
@@ -2,6 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
4
4
|
|
5
|
+
after do
|
6
|
+
ActiveTriples::Repositories.repositories[LD4L::OpenAnnotationRDF::CommentAnnotation.repository].clear!
|
7
|
+
end
|
8
|
+
|
5
9
|
subject { LD4L::OpenAnnotationRDF::CommentAnnotation.new }
|
6
10
|
|
7
11
|
describe 'rdf_subject' do
|
@@ -21,22 +25,22 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
21
25
|
|
22
26
|
describe 'when changing subject' do
|
23
27
|
before do
|
24
|
-
subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland'))
|
25
|
-
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject)
|
26
|
-
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land')
|
28
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland'))
|
29
|
+
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject)
|
30
|
+
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.relation, 'http://example.org/moomin_land')
|
27
31
|
subject.set_subject! RDF::URI('http://example.org/moomin')
|
28
32
|
end
|
29
33
|
|
30
34
|
it 'should update graph subjects' do
|
31
|
-
expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland')))).to be true
|
35
|
+
expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland')))).to be true
|
32
36
|
end
|
33
37
|
|
34
38
|
it 'should update graph objects' do
|
35
|
-
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject))).to be true
|
39
|
+
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject))).to be true
|
36
40
|
end
|
37
41
|
|
38
42
|
it 'should leave other uris alone' do
|
39
|
-
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land'))).to be true
|
43
|
+
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.relation, 'http://example.org/moomin_land'))).to be true
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
@@ -57,8 +61,8 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
57
61
|
# -------------------------------------------------
|
58
62
|
|
59
63
|
describe 'type' do
|
60
|
-
it "should be an
|
61
|
-
expect(subject.type.first.value).to eq
|
64
|
+
it "should be an RDF::Vocab::OA.Annotation" do
|
65
|
+
expect(subject.type.first.value).to eq RDF::Vocab::OA.Annotation.value
|
62
66
|
end
|
63
67
|
end
|
64
68
|
|
@@ -172,18 +176,18 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
172
176
|
|
173
177
|
describe 'motivatedBy' do
|
174
178
|
it "should be OA.commenting if we haven't set it" do
|
175
|
-
expect(subject.motivatedBy.first.to_s).to eq
|
179
|
+
expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.commenting
|
176
180
|
end
|
177
181
|
|
178
182
|
it "should be settable" do
|
179
|
-
subject.motivatedBy =
|
180
|
-
expect(subject.motivatedBy.first.to_s).to eq
|
183
|
+
subject.motivatedBy = RDF::Vocab::OA.describing
|
184
|
+
expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.describing
|
181
185
|
end
|
182
186
|
|
183
187
|
it "should be changeable" do
|
184
|
-
subject.motivatedBy =
|
185
|
-
subject.motivatedBy =
|
186
|
-
expect(subject.motivatedBy.first.to_s).to eq
|
188
|
+
subject.motivatedBy = RDF::Vocab::OA.describing
|
189
|
+
subject.motivatedBy = RDF::Vocab::OA.classifying
|
190
|
+
expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.classifying
|
187
191
|
end
|
188
192
|
end
|
189
193
|
|
@@ -215,7 +219,7 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
215
219
|
|
216
220
|
context "when it is saved" do
|
217
221
|
before do
|
218
|
-
subject.motivatedBy =
|
222
|
+
subject.motivatedBy = RDF::Vocab::OA.commenting
|
219
223
|
subject.persist!
|
220
224
|
end
|
221
225
|
|
@@ -225,7 +229,7 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
225
229
|
|
226
230
|
context "and then modified" do
|
227
231
|
before do
|
228
|
-
subject.motivatedBy =
|
232
|
+
subject.motivatedBy = RDF::Vocab::OA.tagging
|
229
233
|
end
|
230
234
|
|
231
235
|
it "should return true" do
|
@@ -238,7 +242,7 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
238
242
|
end
|
239
243
|
|
240
244
|
it "should reset the motivatedBy" do
|
241
|
-
expect(subject.motivatedBy.first.to_s).to eq
|
245
|
+
expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.commenting.to_s
|
242
246
|
end
|
243
247
|
|
244
248
|
it "should be persisted" do
|
@@ -260,7 +264,7 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
260
264
|
# Create inmemory repository
|
261
265
|
@repo = RDF::Repository.new
|
262
266
|
ActiveTriples::Repositories.repositories[:default] = @repo
|
263
|
-
subject.motivatedBy =
|
267
|
+
subject.motivatedBy = RDF::Vocab::OA.commenting
|
264
268
|
result
|
265
269
|
end
|
266
270
|
|
@@ -274,7 +278,7 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
274
278
|
|
275
279
|
it "should delete from the repository" do
|
276
280
|
subject.reload
|
277
|
-
expect(subject.motivatedBy.first.to_s).to eq
|
281
|
+
expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.commenting.to_s
|
278
282
|
subject.motivatedBy = []
|
279
283
|
expect(subject.motivatedBy).to eq []
|
280
284
|
subject.persist!
|
@@ -301,7 +305,7 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
301
305
|
|
302
306
|
describe '#destroy!' do
|
303
307
|
before do
|
304
|
-
subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
|
308
|
+
subject << RDF::Statement(RDF::Vocab::DC.LicenseDocument, RDF::Vocab::DC.title, 'LICENSE')
|
305
309
|
end
|
306
310
|
|
307
311
|
subject { LD4L::OpenAnnotationRDF::CommentAnnotation.new('123') }
|
@@ -391,29 +395,29 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
391
395
|
|
392
396
|
context 'with unmodeled data' do
|
393
397
|
before do
|
394
|
-
subject << RDF::Statement(subject.rdf_subject, RDF::DC.contributor, 'Tove Jansson')
|
395
|
-
subject << RDF::Statement(subject.rdf_subject, RDF::DC.relation, RDF::URI('http://example.org/moomi'))
|
398
|
+
subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.contributor, 'Tove Jansson')
|
399
|
+
subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.relation, RDF::URI('http://example.org/moomi'))
|
396
400
|
node = RDF::Node.new
|
397
|
-
subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::DC.relation, node)
|
398
|
-
subject << RDF::Statement(node, RDF::DC.title, 'bnode')
|
401
|
+
subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::Vocab::DC.relation, node)
|
402
|
+
subject << RDF::Statement(node, RDF::Vocab::DC.title, 'bnode')
|
399
403
|
end
|
400
404
|
|
401
405
|
it 'should include data with URIs as attribute names' do
|
402
|
-
expect(subject.attributes[RDF::DC.contributor.to_s]).to eq ['Tove Jansson']
|
406
|
+
expect(subject.attributes[RDF::Vocab::DC.contributor.to_s]).to eq ['Tove Jansson']
|
403
407
|
end
|
404
408
|
|
405
409
|
it 'should return generic Resources' do
|
406
|
-
expect(subject.attributes[RDF::DC.relation.to_s].first).to be_a ActiveTriples::Resource
|
410
|
+
expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first).to be_a ActiveTriples::Resource
|
407
411
|
end
|
408
412
|
|
409
413
|
it 'should build deep data for Resources' do
|
410
|
-
expect(subject.attributes[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation).
|
411
|
-
first.get_values(RDF::DC.title)).to eq ['bnode']
|
414
|
+
expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation).
|
415
|
+
first.get_values(RDF::Vocab::DC.title)).to eq ['bnode']
|
412
416
|
end
|
413
417
|
|
414
418
|
it 'should include deep data in serializable_hash' do
|
415
|
-
expect(subject.serializable_hash[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation).
|
416
|
-
first.get_values(RDF::DC.title)).to eq ['bnode']
|
419
|
+
expect(subject.serializable_hash[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation).
|
420
|
+
first.get_values(RDF::Vocab::DC.title)).to eq ['bnode']
|
417
421
|
end
|
418
422
|
end
|
419
423
|
|
@@ -490,13 +494,13 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
490
494
|
|
491
495
|
describe 'editing the graph' do
|
492
496
|
it 'should write properties when statements are added' do
|
493
|
-
subject << RDF::Statement.new(subject.rdf_subject,
|
497
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::OA.motivatedBy, 'commenting')
|
494
498
|
expect(subject.motivatedBy).to include 'commenting'
|
495
499
|
end
|
496
500
|
|
497
501
|
it 'should delete properties when statements are removed' do
|
498
|
-
subject << RDF::Statement.new(subject.rdf_subject,
|
499
|
-
subject.delete RDF::Statement.new(subject.rdf_subject,
|
502
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::OA.annotatedBy, 'John Smith')
|
503
|
+
subject.delete RDF::Statement.new(subject.rdf_subject, RDF::Vocab::OA.annotatedBy, 'John Smith')
|
500
504
|
expect(subject.annotatedBy).to eq []
|
501
505
|
end
|
502
506
|
end
|
@@ -505,18 +509,18 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
505
509
|
before do
|
506
510
|
class DummyPerson < ActiveTriples::Resource
|
507
511
|
configure :type => RDF::URI('http://example.org/Person')
|
508
|
-
property :foafname, :predicate => RDF::FOAF.name
|
509
|
-
property :publications, :predicate => RDF::FOAF.publications, :class_name => 'DummyDocument'
|
510
|
-
property :knows, :predicate => RDF::FOAF.knows, :class_name => DummyPerson
|
512
|
+
property :foafname, :predicate => RDF::Vocab::FOAF.name
|
513
|
+
property :publications, :predicate => RDF::Vocab::FOAF.publications, :class_name => 'DummyDocument'
|
514
|
+
property :knows, :predicate => RDF::Vocab::FOAF.knows, :class_name => DummyPerson
|
511
515
|
end
|
512
516
|
|
513
517
|
class DummyDocument < ActiveTriples::Resource
|
514
518
|
configure :type => RDF::URI('http://example.org/Document')
|
515
|
-
property :title, :predicate => RDF::DC.title
|
516
|
-
property :creator, :predicate => RDF::DC.creator, :class_name => 'DummyPerson'
|
519
|
+
property :title, :predicate => RDF::Vocab::DC.title
|
520
|
+
property :creator, :predicate => RDF::Vocab::DC.creator, :class_name => 'DummyPerson'
|
517
521
|
end
|
518
522
|
|
519
|
-
LD4L::OpenAnnotationRDF::CommentAnnotation.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument
|
523
|
+
LD4L::OpenAnnotationRDF::CommentAnnotation.property :item, :predicate => RDF::Vocab::DC.relation, :class_name => DummyDocument
|
520
524
|
end
|
521
525
|
|
522
526
|
subject { LD4L::OpenAnnotationRDF::CommentAnnotation.new }
|
@@ -569,8 +573,10 @@ END
|
|
569
573
|
document1.creator = [person1, person2]
|
570
574
|
document2.creator = person1
|
571
575
|
person1.knows = person2
|
576
|
+
person2.knows = person1
|
572
577
|
subject.item = [document1]
|
573
|
-
expect(subject.item.first.creator.first.knows.first.foafname)
|
578
|
+
expect(subject.item.first.creator.first.knows.first.foafname)
|
579
|
+
.to satisfy { |names| ['Alice', 'Bob'].include? names.first }
|
574
580
|
end
|
575
581
|
end
|
576
582
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'ld4l/open_annotation_rdf/vocab/dctypes'
|
3
|
-
require 'ld4l/open_annotation_rdf/vocab/oa'
|
4
|
-
|
5
2
|
|
6
3
|
describe 'LD4L::OpenAnnotationRDF::CommentBody' do
|
7
4
|
|
5
|
+
after do
|
6
|
+
ActiveTriples::Repositories.repositories[LD4L::OpenAnnotationRDF::CommentAnnotation.repository].clear!
|
7
|
+
end
|
8
|
+
|
8
9
|
subject { LD4L::OpenAnnotationRDF::CommentBody.new }
|
9
10
|
|
10
11
|
describe 'rdf_subject' do
|
@@ -24,22 +25,22 @@ describe 'LD4L::OpenAnnotationRDF::CommentBody' do
|
|
24
25
|
|
25
26
|
describe 'when changing subject' do
|
26
27
|
before do
|
27
|
-
subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland'))
|
28
|
-
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject)
|
29
|
-
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land')
|
28
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland'))
|
29
|
+
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject)
|
30
|
+
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.relation, 'http://example.org/moomin_land')
|
30
31
|
subject.set_subject! RDF::URI('http://example.org/moomin')
|
31
32
|
end
|
32
33
|
|
33
34
|
it 'should update graph subjects' do
|
34
|
-
expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland')))).to be true
|
35
|
+
expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland')))).to be true
|
35
36
|
end
|
36
37
|
|
37
38
|
it 'should update graph objects' do
|
38
|
-
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject))).to be true
|
39
|
+
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject))).to be true
|
39
40
|
end
|
40
41
|
|
41
42
|
it 'should leave other uris alone' do
|
42
|
-
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land'))).to be true
|
43
|
+
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.relation, 'http://example.org/moomin_land'))).to be true
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
@@ -62,57 +63,57 @@ describe 'LD4L::OpenAnnotationRDF::CommentBody' do
|
|
62
63
|
describe 'type' do
|
63
64
|
it "should be set to text and ContentAsText from new" do
|
64
65
|
expected_results = subject.type
|
65
|
-
expected_results = expected_results.to_a if
|
66
|
+
expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
66
67
|
expect(expected_results.size).to eq 2
|
67
|
-
expect(expected_results).to include
|
68
|
-
expect(expected_results).to include
|
68
|
+
expect(expected_results).to include RDF::Vocab::DCMIType.Text
|
69
|
+
expect(expected_results).to include RDF::Vocab::CNT.ContentAsText
|
69
70
|
end
|
70
71
|
|
71
72
|
it "should be settable" do
|
72
|
-
subject.type =
|
73
|
+
subject.type = RDF::Vocab::DCMIType.Text
|
73
74
|
expected_results = subject.type
|
74
|
-
expected_results = expected_results.to_a if
|
75
|
+
expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
75
76
|
expect(expected_results.size).to eq 1
|
76
|
-
expect(expected_results).to include
|
77
|
+
expect(expected_results).to include RDF::Vocab::DCMIType.Text
|
77
78
|
end
|
78
79
|
|
79
80
|
it "should be settable to multiple values" do
|
80
|
-
t = [
|
81
|
+
t = [RDF::Vocab::DCMIType.Text, RDF::Vocab::CNT.ContentAsText]
|
81
82
|
subject.set_value(:type,t)
|
82
83
|
expected_results = subject.type
|
83
|
-
expected_results = expected_results.to_a if
|
84
|
+
expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
84
85
|
expect(expected_results.size).to eq 2
|
85
|
-
expect(expected_results).to include
|
86
|
-
expect(expected_results).to include
|
86
|
+
expect(expected_results).to include RDF::Vocab::DCMIType.Text
|
87
|
+
expect(expected_results).to include RDF::Vocab::CNT.ContentAsText
|
87
88
|
end
|
88
89
|
|
89
90
|
it "should be changeable" do
|
90
|
-
subject.type =
|
91
|
-
subject.type =
|
91
|
+
subject.type = RDF::Vocab::DCMIType.Text
|
92
|
+
subject.type = RDF::Vocab::CNT.ContentAsText
|
92
93
|
expected_results = subject.type
|
93
|
-
expected_results = expected_results.to_a if
|
94
|
+
expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
94
95
|
expect(expected_results.size).to eq 1
|
95
|
-
expect(expected_results).to include
|
96
|
+
expect(expected_results).to include RDF::Vocab::CNT.ContentAsText
|
96
97
|
end
|
97
98
|
|
98
99
|
it "should be changeable for multiple values" do
|
99
|
-
t = [
|
100
|
+
t = [RDF::Vocab::DCMIType.Text, RDF::Vocab::CNT.ContentAsText]
|
100
101
|
subject.set_value(:type,t)
|
101
102
|
expected_results = subject.type
|
102
|
-
expected_results = expected_results.to_a if
|
103
|
+
expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
103
104
|
expect(expected_results.size).to eq 2
|
104
|
-
expect(expected_results).to include
|
105
|
-
expect(expected_results).to include
|
105
|
+
expect(expected_results).to include RDF::Vocab::DCMIType.Text
|
106
|
+
expect(expected_results).to include RDF::Vocab::CNT.ContentAsText
|
106
107
|
|
107
108
|
t = subject.get_values(:type).to_a
|
108
|
-
t[0] =
|
109
|
-
t[1] =
|
109
|
+
t[0] = RDF::Vocab::OA.Tag # dummy type for testing
|
110
|
+
t[1] = RDF::Vocab::OA.SemanticTag # dummy type for testing
|
110
111
|
subject.set_value(:type,t)
|
111
112
|
expected_results = subject.type
|
112
|
-
expected_results = expected_results.to_a if
|
113
|
+
expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
113
114
|
expect(expected_results.size).to eq 2
|
114
|
-
expect(expected_results).to include
|
115
|
-
expect(expected_results).to include
|
115
|
+
expect(expected_results).to include RDF::Vocab::OA.Tag
|
116
|
+
expect(expected_results).to include RDF::Vocab::OA.SemanticTag
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
@@ -259,7 +260,7 @@ describe 'LD4L::OpenAnnotationRDF::CommentBody' do
|
|
259
260
|
|
260
261
|
describe '#destroy!' do
|
261
262
|
before do
|
262
|
-
subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
|
263
|
+
subject << RDF::Statement(RDF::Vocab::DC.LicenseDocument, RDF::Vocab::DC.title, 'LICENSE')
|
263
264
|
end
|
264
265
|
|
265
266
|
subject { LD4L::OpenAnnotationRDF::CommentBody.new('456')}
|
@@ -296,13 +297,13 @@ describe 'LD4L::OpenAnnotationRDF::CommentBody' do
|
|
296
297
|
|
297
298
|
describe 'editing the graph' do
|
298
299
|
it 'should write properties when statements are added' do
|
299
|
-
subject << RDF::Statement.new(subject.rdf_subject,
|
300
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::CNT.chars, 'Great book!')
|
300
301
|
expect(subject.content).to include 'Great book!'
|
301
302
|
end
|
302
303
|
|
303
304
|
it 'should delete properties when statements are removed' do
|
304
|
-
subject << RDF::Statement.new(subject.rdf_subject,
|
305
|
-
subject.delete RDF::Statement.new(subject.rdf_subject,
|
305
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::CNT.chars, 'Great book!')
|
306
|
+
subject.delete RDF::Statement.new(subject.rdf_subject, RDF::Vocab::CNT.chars, 'Great book!')
|
306
307
|
expect(subject.content).to eq []
|
307
308
|
end
|
308
309
|
end
|
@@ -311,18 +312,18 @@ describe 'LD4L::OpenAnnotationRDF::CommentBody' do
|
|
311
312
|
before do
|
312
313
|
class DummyPerson < ActiveTriples::Resource
|
313
314
|
configure :type => RDF::URI('http://example.org/Person')
|
314
|
-
property :foafname, :predicate => RDF::FOAF.name
|
315
|
-
property :publications, :predicate => RDF::FOAF.publications, :class_name => 'DummyDocument'
|
316
|
-
property :knows, :predicate => RDF::FOAF.knows, :class_name => DummyPerson
|
315
|
+
property :foafname, :predicate => RDF::Vocab::FOAF.name
|
316
|
+
property :publications, :predicate => RDF::Vocab::FOAF.publications, :class_name => 'DummyDocument'
|
317
|
+
property :knows, :predicate => RDF::Vocab::FOAF.knows, :class_name => DummyPerson
|
317
318
|
end
|
318
319
|
|
319
320
|
class DummyDocument < ActiveTriples::Resource
|
320
321
|
configure :type => RDF::URI('http://example.org/Document')
|
321
|
-
property :title, :predicate => RDF::DC.title
|
322
|
-
property :creator, :predicate => RDF::DC.creator, :class_name => 'DummyPerson'
|
322
|
+
property :title, :predicate => RDF::Vocab::DC.title
|
323
|
+
property :creator, :predicate => RDF::Vocab::DC.creator, :class_name => 'DummyPerson'
|
323
324
|
end
|
324
325
|
|
325
|
-
LD4L::OpenAnnotationRDF::CommentBody.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument
|
326
|
+
LD4L::OpenAnnotationRDF::CommentBody.property :item, :predicate => RDF::Vocab::DC.relation, :class_name => DummyDocument
|
326
327
|
end
|
327
328
|
|
328
329
|
subject { LD4L::OpenAnnotationRDF::CommentBody.new }
|
@@ -375,8 +376,10 @@ END
|
|
375
376
|
document1.creator = [person1, person2]
|
376
377
|
document2.creator = person1
|
377
378
|
person1.knows = person2
|
379
|
+
person2.knows = person1
|
378
380
|
subject.item = [document1]
|
379
|
-
expect(subject.item.first.creator.first.knows.first.foafname)
|
381
|
+
expect(subject.item.first.creator.first.knows.first.foafname)
|
382
|
+
.to satisfy { |names| ['Alice', 'Bob'].include? names.first }
|
380
383
|
end
|
381
384
|
end
|
382
385
|
end
|
@@ -7,7 +7,7 @@ describe 'LD4L::OpenAnnotationRDF' do
|
|
7
7
|
context "when base_uri is not configured" do
|
8
8
|
before do
|
9
9
|
class DummyAnnotation < LD4L::OpenAnnotationRDF::Annotation
|
10
|
-
configure :type =>
|
10
|
+
configure :type => RDF::Vocab::OA.Annotation, :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri, :repository => :default
|
11
11
|
end
|
12
12
|
end
|
13
13
|
after do
|
@@ -24,7 +24,7 @@ describe 'LD4L::OpenAnnotationRDF' do
|
|
24
24
|
config.base_uri = "http://localhost/test_slash/"
|
25
25
|
end
|
26
26
|
class DummyAnnotation < LD4L::OpenAnnotationRDF::Annotation
|
27
|
-
configure :type =>
|
27
|
+
configure :type => RDF::Vocab::OA.Annotation, :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri, :repository => :default
|
28
28
|
end
|
29
29
|
end
|
30
30
|
after do
|
@@ -43,7 +43,7 @@ describe 'LD4L::OpenAnnotationRDF' do
|
|
43
43
|
config.base_uri = "http://localhost/test_no_slash"
|
44
44
|
end
|
45
45
|
class DummyAnnotation < LD4L::OpenAnnotationRDF::Annotation
|
46
|
-
configure :type =>
|
46
|
+
configure :type => RDF::Vocab::OA.Annotation, :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri, :repository => :default
|
47
47
|
end
|
48
48
|
end
|
49
49
|
after do
|
@@ -86,7 +86,7 @@ describe 'LD4L::OpenAnnotationRDF' do
|
|
86
86
|
context "when minter is nil" do
|
87
87
|
before do
|
88
88
|
class DummyAnnotation < LD4L::OpenAnnotationRDF::Annotation
|
89
|
-
configure :type =>
|
89
|
+
configure :type => RDF::Vocab::OA.Annotation, :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri, :repository => :default
|
90
90
|
end
|
91
91
|
end
|
92
92
|
after do
|
@@ -108,7 +108,7 @@ describe 'LD4L::OpenAnnotationRDF' do
|
|
108
108
|
config.localname_minter = lambda { |prefix=""| prefix+'_configured_'+SecureRandom.uuid }
|
109
109
|
end
|
110
110
|
class DummyAnnotation < LD4L::OpenAnnotationRDF::Annotation
|
111
|
-
configure :type =>
|
111
|
+
configure :type => RDF::Vocab::OA.Annotation, :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri, :repository => :default
|
112
112
|
end
|
113
113
|
end
|
114
114
|
after do
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
# TODO: Uses CommentBody as the annotation body, which is wrong. Should be URI into controlled vocabulary.
|
4
|
-
|
5
3
|
describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
6
4
|
|
5
|
+
after do
|
6
|
+
ActiveTriples::Repositories.repositories[LD4L::OpenAnnotationRDF::CommentAnnotation.repository].clear!
|
7
|
+
end
|
8
|
+
|
7
9
|
subject { LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new }
|
8
10
|
|
9
11
|
describe 'rdf_subject' do
|
@@ -23,22 +25,22 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
23
25
|
|
24
26
|
describe 'when changing subject' do
|
25
27
|
before do
|
26
|
-
subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland'))
|
27
|
-
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject)
|
28
|
-
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land')
|
28
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland'))
|
29
|
+
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject)
|
30
|
+
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.relation, 'http://example.org/moomin_land')
|
29
31
|
subject.set_subject! RDF::URI('http://example.org/moomin')
|
30
32
|
end
|
31
33
|
|
32
34
|
it 'should update graph subjects' do
|
33
|
-
expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland')))).to be true
|
35
|
+
expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland')))).to be true
|
34
36
|
end
|
35
37
|
|
36
38
|
it 'should update graph objects' do
|
37
|
-
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject))).to be true
|
39
|
+
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject))).to be true
|
38
40
|
end
|
39
41
|
|
40
42
|
it 'should leave other uris alone' do
|
41
|
-
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land'))).to be true
|
43
|
+
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.relation, 'http://example.org/moomin_land'))).to be true
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
@@ -59,8 +61,8 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
59
61
|
# -------------------------------------------------
|
60
62
|
|
61
63
|
describe 'type' do
|
62
|
-
it "should be an
|
63
|
-
expect(subject.type.first.value).to eq
|
64
|
+
it "should be an RDF::Vocab::OA.Annotation" do
|
65
|
+
expect(subject.type.first.value).to eq RDF::Vocab::OA.Annotation.value
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
@@ -221,18 +223,18 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
221
223
|
|
222
224
|
describe 'motivatedBy' do
|
223
225
|
it "should be OA.tagging if we haven't set it" do
|
224
|
-
expect(subject.motivatedBy.first.to_s).to eq
|
226
|
+
expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.tagging
|
225
227
|
end
|
226
228
|
|
227
229
|
it "should be settable" do
|
228
|
-
subject.motivatedBy =
|
229
|
-
expect(subject.motivatedBy.first.to_s).to eq
|
230
|
+
subject.motivatedBy = RDF::Vocab::OA.describing
|
231
|
+
expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.describing
|
230
232
|
end
|
231
233
|
|
232
234
|
it "should be changeable" do
|
233
|
-
subject.motivatedBy =
|
234
|
-
subject.motivatedBy =
|
235
|
-
expect(subject.motivatedBy.first.to_s).to eq
|
235
|
+
subject.motivatedBy = RDF::Vocab::OA.describing
|
236
|
+
subject.motivatedBy = RDF::Vocab::OA.classifying
|
237
|
+
expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.classifying
|
236
238
|
end
|
237
239
|
end
|
238
240
|
|
@@ -264,7 +266,7 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
264
266
|
|
265
267
|
context "when it is saved" do
|
266
268
|
before do
|
267
|
-
subject.motivatedBy =
|
269
|
+
subject.motivatedBy = RDF::Vocab::OA.commenting
|
268
270
|
subject.persist!
|
269
271
|
end
|
270
272
|
|
@@ -274,7 +276,7 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
274
276
|
|
275
277
|
context "and then modified" do
|
276
278
|
before do
|
277
|
-
subject.motivatedBy =
|
279
|
+
subject.motivatedBy = RDF::Vocab::OA.tagging
|
278
280
|
end
|
279
281
|
|
280
282
|
it "should return true" do
|
@@ -287,7 +289,7 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
287
289
|
end
|
288
290
|
|
289
291
|
it "should reset the motivatedBy" do
|
290
|
-
expect(subject.motivatedBy.first.to_s).to eq
|
292
|
+
expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.commenting.to_s
|
291
293
|
end
|
292
294
|
|
293
295
|
it "should be persisted" do
|
@@ -309,7 +311,7 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
309
311
|
# Create inmemory repository
|
310
312
|
@repo = RDF::Repository.new
|
311
313
|
ActiveTriples::Repositories.repositories[:default] = @repo
|
312
|
-
subject.motivatedBy =
|
314
|
+
subject.motivatedBy = RDF::Vocab::OA.commenting
|
313
315
|
result
|
314
316
|
end
|
315
317
|
|
@@ -323,7 +325,7 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
323
325
|
|
324
326
|
it "should delete from the repository" do
|
325
327
|
subject.reload
|
326
|
-
expect(subject.motivatedBy.first.to_s).to eq
|
328
|
+
expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.commenting.to_s
|
327
329
|
subject.motivatedBy = []
|
328
330
|
expect(subject.motivatedBy).to eq []
|
329
331
|
subject.persist!
|
@@ -351,7 +353,7 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
351
353
|
|
352
354
|
describe '#destroy!' do
|
353
355
|
before do
|
354
|
-
subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
|
356
|
+
subject << RDF::Statement(RDF::Vocab::DC.LicenseDocument, RDF::Vocab::DC.title, 'LICENSE')
|
355
357
|
end
|
356
358
|
|
357
359
|
subject { LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new('123') }
|
@@ -441,29 +443,29 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
441
443
|
|
442
444
|
context 'with unmodeled data' do
|
443
445
|
before do
|
444
|
-
subject << RDF::Statement(subject.rdf_subject, RDF::DC.contributor, 'Tove Jansson')
|
445
|
-
subject << RDF::Statement(subject.rdf_subject, RDF::DC.relation, RDF::URI('http://example.org/moomi'))
|
446
|
+
subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.contributor, 'Tove Jansson')
|
447
|
+
subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.relation, RDF::URI('http://example.org/moomi'))
|
446
448
|
node = RDF::Node.new
|
447
|
-
subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::DC.relation, node)
|
448
|
-
subject << RDF::Statement(node, RDF::DC.title, 'bnode')
|
449
|
+
subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::Vocab::DC.relation, node)
|
450
|
+
subject << RDF::Statement(node, RDF::Vocab::DC.title, 'bnode')
|
449
451
|
end
|
450
452
|
|
451
453
|
it 'should include data with URIs as attribute names' do
|
452
|
-
expect(subject.attributes[RDF::DC.contributor.to_s]).to eq ['Tove Jansson']
|
454
|
+
expect(subject.attributes[RDF::Vocab::DC.contributor.to_s]).to eq ['Tove Jansson']
|
453
455
|
end
|
454
456
|
|
455
457
|
it 'should return generic Resources' do
|
456
|
-
expect(subject.attributes[RDF::DC.relation.to_s].first).to be_a ActiveTriples::Resource
|
458
|
+
expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first).to be_a ActiveTriples::Resource
|
457
459
|
end
|
458
460
|
|
459
461
|
it 'should build deep data for Resources' do
|
460
|
-
expect(subject.attributes[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation).
|
461
|
-
first.get_values(RDF::DC.title)).to eq ['bnode']
|
462
|
+
expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation).
|
463
|
+
first.get_values(RDF::Vocab::DC.title)).to eq ['bnode']
|
462
464
|
end
|
463
465
|
|
464
466
|
it 'should include deep data in serializable_hash' do
|
465
|
-
expect(subject.serializable_hash[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation).
|
466
|
-
first.get_values(RDF::DC.title)).to eq ['bnode']
|
467
|
+
expect(subject.serializable_hash[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation).
|
468
|
+
first.get_values(RDF::Vocab::DC.title)).to eq ['bnode']
|
467
469
|
end
|
468
470
|
end
|
469
471
|
|
@@ -540,13 +542,13 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
540
542
|
|
541
543
|
describe 'editing the graph' do
|
542
544
|
it 'should write properties when statements are added' do
|
543
|
-
subject << RDF::Statement.new(subject.rdf_subject,
|
545
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::OA.motivatedBy, 'commenting')
|
544
546
|
expect(subject.motivatedBy).to include 'commenting'
|
545
547
|
end
|
546
548
|
|
547
549
|
it 'should delete properties when statements are removed' do
|
548
|
-
subject << RDF::Statement.new(subject.rdf_subject,
|
549
|
-
subject.delete RDF::Statement.new(subject.rdf_subject,
|
550
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::OA.annotatedBy, 'John Smith')
|
551
|
+
subject.delete RDF::Statement.new(subject.rdf_subject, RDF::Vocab::OA.annotatedBy, 'John Smith')
|
550
552
|
expect(subject.annotatedBy).to eq []
|
551
553
|
end
|
552
554
|
end
|
@@ -555,18 +557,18 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
555
557
|
before do
|
556
558
|
class DummyPerson < ActiveTriples::Resource
|
557
559
|
configure :type => RDF::URI('http://example.org/Person')
|
558
|
-
property :foafname, :predicate => RDF::FOAF.name
|
559
|
-
property :publications, :predicate => RDF::FOAF.publications, :class_name => 'DummyDocument'
|
560
|
-
property :knows, :predicate => RDF::FOAF.knows, :class_name => DummyPerson
|
560
|
+
property :foafname, :predicate => RDF::Vocab::FOAF.name
|
561
|
+
property :publications, :predicate => RDF::Vocab::FOAF.publications, :class_name => 'DummyDocument'
|
562
|
+
property :knows, :predicate => RDF::Vocab::FOAF.knows, :class_name => DummyPerson
|
561
563
|
end
|
562
564
|
|
563
565
|
class DummyDocument < ActiveTriples::Resource
|
564
566
|
configure :type => RDF::URI('http://example.org/Document')
|
565
|
-
property :title, :predicate => RDF::DC.title
|
566
|
-
property :creator, :predicate => RDF::DC.creator, :class_name => 'DummyPerson'
|
567
|
+
property :title, :predicate => RDF::Vocab::DC.title
|
568
|
+
property :creator, :predicate => RDF::Vocab::DC.creator, :class_name => 'DummyPerson'
|
567
569
|
end
|
568
570
|
|
569
|
-
LD4L::OpenAnnotationRDF::SemanticTagAnnotation.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument
|
571
|
+
LD4L::OpenAnnotationRDF::SemanticTagAnnotation.property :item, :predicate => RDF::Vocab::DC.relation, :class_name => DummyDocument
|
570
572
|
end
|
571
573
|
|
572
574
|
subject { LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new }
|
@@ -619,8 +621,10 @@ END
|
|
619
621
|
document1.creator = [person1, person2]
|
620
622
|
document2.creator = person1
|
621
623
|
person1.knows = person2
|
624
|
+
person2.knows = person1
|
622
625
|
subject.item = [document1]
|
623
|
-
expect(subject.item.first.creator.first.knows.first.foafname)
|
626
|
+
expect(subject.item.first.creator.first.knows.first.foafname)
|
627
|
+
.to satisfy { |names| ['Alice', 'Bob'].include? names.first }
|
624
628
|
end
|
625
629
|
end
|
626
630
|
end
|