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
@@ -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::SemanticTagBody' do
|
7
4
|
|
5
|
+
after do
|
6
|
+
ActiveTriples::Repositories.repositories[LD4L::OpenAnnotationRDF::CommentAnnotation.repository].clear!
|
7
|
+
end
|
8
|
+
|
8
9
|
subject { LD4L::OpenAnnotationRDF::SemanticTagBody.new }
|
9
10
|
|
10
11
|
describe 'rdf_subject' do
|
@@ -24,22 +25,22 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' 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,9 +63,9 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
62
63
|
describe 'type' do
|
63
64
|
it "should be set to text and astext 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 1
|
67
|
-
expect(expected_results).to include
|
68
|
+
expect(expected_results).to include RDF::Vocab::OA.SemanticTag
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
@@ -96,7 +97,7 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
96
97
|
end
|
97
98
|
|
98
99
|
context "when terms exist in the repository" do
|
99
|
-
before
|
100
|
+
before do
|
100
101
|
# Create inmemory repository
|
101
102
|
sta = LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new('http://example.org/sta1')
|
102
103
|
sta.setTerm(RDF::URI("http://example.org/EXISTING_term"))
|
@@ -107,11 +108,6 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
107
108
|
stb = LD4L::OpenAnnotationRDF::SemanticTagBody.new('http://example.org/UNUSED_term')
|
108
109
|
stb.persist!
|
109
110
|
end
|
110
|
-
after(:all) do
|
111
|
-
LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new('http://example.org/sta1').destroy!
|
112
|
-
LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new('http://example.org/sta2').destroy!
|
113
|
-
LD4L::OpenAnnotationRDF::SemanticTagBody.new('http://example.org/UNUSED_term').destroy!
|
114
|
-
end
|
115
111
|
|
116
112
|
context "and term is passed as string URI" do
|
117
113
|
it "should find annotations using the term" do
|
@@ -173,7 +169,7 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
173
169
|
end
|
174
170
|
|
175
171
|
context "when terms exist in the repository" do
|
176
|
-
before
|
172
|
+
before do
|
177
173
|
# Create inmemory repository
|
178
174
|
sta = LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new('http://example.org/sta1')
|
179
175
|
sta.setTerm(RDF::URI("http://example.org/EXISTING_term"))
|
@@ -184,11 +180,6 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
184
180
|
stb = LD4L::OpenAnnotationRDF::SemanticTagBody.new('http://example.org/UNUSED_term')
|
185
181
|
stb.persist!
|
186
182
|
end
|
187
|
-
after(:all) do
|
188
|
-
LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new('http://example.org/sta1').destroy!
|
189
|
-
LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new('http://example.org/sta2').destroy!
|
190
|
-
LD4L::OpenAnnotationRDF::SemanticTagBody.new('http://example.org/UNUSED_term').destroy!
|
191
|
-
end
|
192
183
|
|
193
184
|
context "and term is passed as string URI" do
|
194
185
|
it "should not destroy if used by any annotations" do
|
@@ -302,7 +293,7 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
302
293
|
|
303
294
|
describe '#destroy!' do
|
304
295
|
before do
|
305
|
-
subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
|
296
|
+
subject << RDF::Statement(RDF::Vocab::DC.LicenseDocument, RDF::Vocab::DC.title, 'LICENSE')
|
306
297
|
end
|
307
298
|
|
308
299
|
subject { LD4L::OpenAnnotationRDF::SemanticTagBody.new('456')}
|
@@ -341,18 +332,18 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
341
332
|
before do
|
342
333
|
class DummyPerson < ActiveTriples::Resource
|
343
334
|
configure :type => RDF::URI('http://example.org/Person')
|
344
|
-
property :foafname, :predicate => RDF::FOAF.name
|
345
|
-
property :publications, :predicate => RDF::FOAF.publications, :class_name => 'DummyDocument'
|
346
|
-
property :knows, :predicate => RDF::FOAF.knows, :class_name => DummyPerson
|
335
|
+
property :foafname, :predicate => RDF::Vocab::FOAF.name
|
336
|
+
property :publications, :predicate => RDF::Vocab::FOAF.publications, :class_name => 'DummyDocument'
|
337
|
+
property :knows, :predicate => RDF::Vocab::FOAF.knows, :class_name => DummyPerson
|
347
338
|
end
|
348
339
|
|
349
340
|
class DummyDocument < ActiveTriples::Resource
|
350
341
|
configure :type => RDF::URI('http://example.org/Document')
|
351
|
-
property :title, :predicate => RDF::DC.title
|
352
|
-
property :creator, :predicate => RDF::DC.creator, :class_name => 'DummyPerson'
|
342
|
+
property :title, :predicate => RDF::Vocab::DC.title
|
343
|
+
property :creator, :predicate => RDF::Vocab::DC.creator, :class_name => 'DummyPerson'
|
353
344
|
end
|
354
345
|
|
355
|
-
LD4L::OpenAnnotationRDF::SemanticTagBody.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument
|
346
|
+
LD4L::OpenAnnotationRDF::SemanticTagBody.property :item, :predicate => RDF::Vocab::DC.relation, :class_name => DummyDocument
|
356
347
|
end
|
357
348
|
|
358
349
|
subject { LD4L::OpenAnnotationRDF::SemanticTagBody.new }
|
@@ -405,8 +396,10 @@ END
|
|
405
396
|
document1.creator = [person1, person2]
|
406
397
|
document2.creator = person1
|
407
398
|
person1.knows = person2
|
399
|
+
person2.knows = person1
|
408
400
|
subject.item = [document1]
|
409
|
-
expect(subject.item.first.creator.first.knows.first.foafname)
|
401
|
+
expect(subject.item.first.creator.first.knows.first.foafname)
|
402
|
+
.to satisfy { |names| ['Alice', 'Bob'].include? names.first }
|
410
403
|
end
|
411
404
|
end
|
412
405
|
end
|
@@ -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::TagAnnotation' do
|
6
4
|
|
5
|
+
after do
|
6
|
+
ActiveTriples::Repositories.repositories[LD4L::OpenAnnotationRDF::CommentAnnotation.repository].clear!
|
7
|
+
end
|
8
|
+
|
7
9
|
subject { LD4L::OpenAnnotationRDF::TagAnnotation.new }
|
8
10
|
|
9
11
|
describe 'rdf_subject' do
|
@@ -23,22 +25,22 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' 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::TagAnnotation' 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
|
|
@@ -273,18 +275,18 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
273
275
|
|
274
276
|
describe 'motivatedBy' do
|
275
277
|
it "should be OA.tagging if we haven't set it" do
|
276
|
-
expect(subject.motivatedBy.first).to eq
|
278
|
+
expect(subject.motivatedBy.first).to eq RDF::Vocab::OA.tagging
|
277
279
|
end
|
278
280
|
|
279
281
|
it "should be settable" do
|
280
|
-
subject.motivatedBy =
|
281
|
-
expect(subject.motivatedBy.first).to eq
|
282
|
+
subject.motivatedBy = RDF::Vocab::OA.describing
|
283
|
+
expect(subject.motivatedBy.first).to eq RDF::Vocab::OA.describing
|
282
284
|
end
|
283
285
|
|
284
286
|
it "should be changeable" do
|
285
|
-
subject.motivatedBy =
|
286
|
-
subject.motivatedBy =
|
287
|
-
expect(subject.motivatedBy.first).to eq
|
287
|
+
subject.motivatedBy = RDF::Vocab::OA.describing
|
288
|
+
subject.motivatedBy = RDF::Vocab::OA.classifying
|
289
|
+
expect(subject.motivatedBy.first).to eq RDF::Vocab::OA.classifying
|
288
290
|
end
|
289
291
|
end
|
290
292
|
|
@@ -316,7 +318,7 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
316
318
|
|
317
319
|
context "when it is saved" do
|
318
320
|
before do
|
319
|
-
subject.motivatedBy =
|
321
|
+
subject.motivatedBy = RDF::Vocab::OA.commenting
|
320
322
|
subject.persist!
|
321
323
|
end
|
322
324
|
|
@@ -326,7 +328,7 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
326
328
|
|
327
329
|
context "and then modified" do
|
328
330
|
before do
|
329
|
-
subject.motivatedBy =
|
331
|
+
subject.motivatedBy = RDF::Vocab::OA.tagging
|
330
332
|
end
|
331
333
|
|
332
334
|
it "should return true" do
|
@@ -339,7 +341,7 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
339
341
|
end
|
340
342
|
|
341
343
|
it "should reset the motivatedBy" do
|
342
|
-
expect(subject.motivatedBy.first.to_s).to eq
|
344
|
+
expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.commenting.to_s
|
343
345
|
end
|
344
346
|
|
345
347
|
it "should be persisted" do
|
@@ -361,7 +363,7 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
361
363
|
# Create inmemory repository
|
362
364
|
@repo = RDF::Repository.new
|
363
365
|
ActiveTriples::Repositories.repositories[:default] = @repo
|
364
|
-
subject.motivatedBy =
|
366
|
+
subject.motivatedBy = RDF::Vocab::OA.commenting
|
365
367
|
result
|
366
368
|
end
|
367
369
|
|
@@ -375,7 +377,7 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
375
377
|
|
376
378
|
it "should delete from the repository" do
|
377
379
|
subject.reload
|
378
|
-
expect(subject.motivatedBy.first.to_s).to eq
|
380
|
+
expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.commenting.to_s
|
379
381
|
subject.motivatedBy = []
|
380
382
|
expect(subject.motivatedBy).to eq []
|
381
383
|
subject.persist!
|
@@ -403,7 +405,7 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
403
405
|
|
404
406
|
describe '#destroy!' do
|
405
407
|
before do
|
406
|
-
subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
|
408
|
+
subject << RDF::Statement(RDF::Vocab::DC.LicenseDocument, RDF::Vocab::DC.title, 'LICENSE')
|
407
409
|
end
|
408
410
|
|
409
411
|
subject { LD4L::OpenAnnotationRDF::TagAnnotation.new('123') }
|
@@ -494,29 +496,29 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
494
496
|
|
495
497
|
context 'with unmodeled data' do
|
496
498
|
before do
|
497
|
-
subject << RDF::Statement(subject.rdf_subject, RDF::DC.contributor, 'Tove Jansson')
|
498
|
-
subject << RDF::Statement(subject.rdf_subject, RDF::DC.relation, RDF::URI('http://example.org/moomi'))
|
499
|
+
subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.contributor, 'Tove Jansson')
|
500
|
+
subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.relation, RDF::URI('http://example.org/moomi'))
|
499
501
|
node = RDF::Node.new
|
500
|
-
subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::DC.relation, node)
|
501
|
-
subject << RDF::Statement(node, RDF::DC.title, 'bnode')
|
502
|
+
subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::Vocab::DC.relation, node)
|
503
|
+
subject << RDF::Statement(node, RDF::Vocab::DC.title, 'bnode')
|
502
504
|
end
|
503
505
|
|
504
506
|
it 'should include data with URIs as attribute names' do
|
505
|
-
expect(subject.attributes[RDF::DC.contributor.to_s]).to eq ['Tove Jansson']
|
507
|
+
expect(subject.attributes[RDF::Vocab::DC.contributor.to_s]).to eq ['Tove Jansson']
|
506
508
|
end
|
507
509
|
|
508
510
|
it 'should return generic Resources' do
|
509
|
-
expect(subject.attributes[RDF::DC.relation.to_s].first).to be_a ActiveTriples::Resource
|
511
|
+
expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first).to be_a ActiveTriples::Resource
|
510
512
|
end
|
511
513
|
|
512
514
|
it 'should build deep data for Resources' do
|
513
|
-
expect(subject.attributes[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation).
|
514
|
-
first.get_values(RDF::DC.title)).to eq ['bnode']
|
515
|
+
expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation).
|
516
|
+
first.get_values(RDF::Vocab::DC.title)).to eq ['bnode']
|
515
517
|
end
|
516
518
|
|
517
519
|
it 'should include deep data in serializable_hash' do
|
518
|
-
expect(subject.serializable_hash[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation).
|
519
|
-
first.get_values(RDF::DC.title)).to eq ['bnode']
|
520
|
+
expect(subject.serializable_hash[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation).
|
521
|
+
first.get_values(RDF::Vocab::DC.title)).to eq ['bnode']
|
520
522
|
end
|
521
523
|
end
|
522
524
|
|
@@ -593,13 +595,13 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
593
595
|
|
594
596
|
describe 'editing the graph' do
|
595
597
|
it 'should write properties when statements are added' do
|
596
|
-
subject << RDF::Statement.new(subject.rdf_subject,
|
598
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::OA.motivatedBy, 'commenting')
|
597
599
|
expect(subject.motivatedBy).to include 'commenting'
|
598
600
|
end
|
599
601
|
|
600
602
|
it 'should delete properties when statements are removed' do
|
601
|
-
subject << RDF::Statement.new(subject.rdf_subject,
|
602
|
-
subject.delete RDF::Statement.new(subject.rdf_subject,
|
603
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::OA.annotatedBy, 'John Smith')
|
604
|
+
subject.delete RDF::Statement.new(subject.rdf_subject, RDF::Vocab::OA.annotatedBy, 'John Smith')
|
603
605
|
expect(subject.annotatedBy).to eq []
|
604
606
|
end
|
605
607
|
end
|
@@ -608,18 +610,18 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
608
610
|
before do
|
609
611
|
class DummyPerson < ActiveTriples::Resource
|
610
612
|
configure :type => RDF::URI('http://example.org/Person')
|
611
|
-
property :foafname, :predicate => RDF::FOAF.name
|
612
|
-
property :publications, :predicate => RDF::FOAF.publications, :class_name => 'DummyDocument'
|
613
|
-
property :knows, :predicate => RDF::FOAF.knows, :class_name => DummyPerson
|
613
|
+
property :foafname, :predicate => RDF::Vocab::FOAF.name
|
614
|
+
property :publications, :predicate => RDF::Vocab::FOAF.publications, :class_name => 'DummyDocument'
|
615
|
+
property :knows, :predicate => RDF::Vocab::FOAF.knows, :class_name => DummyPerson
|
614
616
|
end
|
615
617
|
|
616
618
|
class DummyDocument < ActiveTriples::Resource
|
617
619
|
configure :type => RDF::URI('http://example.org/Document')
|
618
|
-
property :title, :predicate => RDF::DC.title
|
619
|
-
property :creator, :predicate => RDF::DC.creator, :class_name => 'DummyPerson'
|
620
|
+
property :title, :predicate => RDF::Vocab::DC.title
|
621
|
+
property :creator, :predicate => RDF::Vocab::DC.creator, :class_name => 'DummyPerson'
|
620
622
|
end
|
621
623
|
|
622
|
-
LD4L::OpenAnnotationRDF::TagAnnotation.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument
|
624
|
+
LD4L::OpenAnnotationRDF::TagAnnotation.property :item, :predicate => RDF::Vocab::DC.relation, :class_name => DummyDocument
|
623
625
|
end
|
624
626
|
|
625
627
|
subject { LD4L::OpenAnnotationRDF::TagAnnotation.new }
|
@@ -672,8 +674,10 @@ END
|
|
672
674
|
document1.creator = [person1, person2]
|
673
675
|
document2.creator = person1
|
674
676
|
person1.knows = person2
|
677
|
+
person2.knows = person1
|
675
678
|
subject.item = [document1]
|
676
|
-
expect(subject.item.first.creator.first.knows.first.foafname)
|
679
|
+
expect(subject.item.first.creator.first.knows.first.foafname)
|
680
|
+
.to satisfy { |names| ['Alice', 'Bob'].include? names.first }
|
677
681
|
end
|
678
682
|
end
|
679
683
|
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::TagBody' do
|
7
4
|
|
5
|
+
after do
|
6
|
+
ActiveTriples::Repositories.repositories[LD4L::OpenAnnotationRDF::CommentAnnotation.repository].clear!
|
7
|
+
end
|
8
|
+
|
8
9
|
subject { LD4L::OpenAnnotationRDF::TagBody.new }
|
9
10
|
|
10
11
|
describe 'rdf_subject' do
|
@@ -24,22 +25,22 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' 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,10 +63,10 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
62
63
|
describe 'type' do
|
63
64
|
it "should be set to text and astext 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::OA.Tag
|
69
|
+
expect(expected_results).to include RDF::Vocab::CNT.ContentAsText
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
@@ -107,7 +108,7 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
107
108
|
end
|
108
109
|
|
109
110
|
context "when tags exist in the repository" do
|
110
|
-
before
|
111
|
+
before do
|
111
112
|
# Create inmemory repository
|
112
113
|
ta = LD4L::OpenAnnotationRDF::TagAnnotation.new('http://example.org/ta1')
|
113
114
|
ta.setTag('EXISTING_tag')
|
@@ -119,11 +120,6 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
119
120
|
tb.tag = 'UNUSED_tag'
|
120
121
|
tb.persist!
|
121
122
|
end
|
122
|
-
after(:all) do
|
123
|
-
LD4L::OpenAnnotationRDF::TagAnnotation.new('http://example.org/ta1').destroy!
|
124
|
-
LD4L::OpenAnnotationRDF::TagAnnotation.new('http://example.org/ta2').destroy!
|
125
|
-
LD4L::OpenAnnotationRDF::TagBody.new('http://example.org/UNUSED_tag').destroy!
|
126
|
-
end
|
127
123
|
|
128
124
|
it "should find annotations using a tag" do
|
129
125
|
annotations = LD4L::OpenAnnotationRDF::TagBody.annotations_using('EXISTING_tag')
|
@@ -165,7 +161,7 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
165
161
|
end
|
166
162
|
|
167
163
|
context "when tags exist in the repository" do
|
168
|
-
before
|
164
|
+
before do
|
169
165
|
# Create inmemory repository
|
170
166
|
ta = LD4L::OpenAnnotationRDF::TagAnnotation.new('http://example.org/ta1')
|
171
167
|
ta.setTag('EXISTING_tag')
|
@@ -177,11 +173,6 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
177
173
|
tb.tag = 'UNUSED_tag'
|
178
174
|
tb.persist!
|
179
175
|
end
|
180
|
-
after(:all) do
|
181
|
-
LD4L::OpenAnnotationRDF::TagAnnotation.new('http://example.org/ta1').destroy!
|
182
|
-
LD4L::OpenAnnotationRDF::TagAnnotation.new('http://example.org/ta2').destroy!
|
183
|
-
LD4L::OpenAnnotationRDF::TagBody.new('http://example.org/UNUSED_tag').destroy!
|
184
|
-
end
|
185
176
|
|
186
177
|
it "should not find non-existent tag" do
|
187
178
|
expect( LD4L::OpenAnnotationRDF::TagBody.fetch_by_tag_value('NONEXISTING_tag') ).to be_nil
|
@@ -307,7 +298,7 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
307
298
|
|
308
299
|
describe '#destroy!' do
|
309
300
|
before do
|
310
|
-
subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
|
301
|
+
subject << RDF::Statement(RDF::Vocab::DC.LicenseDocument, RDF::Vocab::DC.title, 'LICENSE')
|
311
302
|
end
|
312
303
|
|
313
304
|
subject { LD4L::OpenAnnotationRDF::TagBody.new('456')}
|
@@ -344,13 +335,13 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
344
335
|
|
345
336
|
describe 'editing the graph' do
|
346
337
|
it 'should write properties when statements are added' do
|
347
|
-
subject << RDF::Statement.new(subject.rdf_subject,
|
338
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::CNT.chars, 'good')
|
348
339
|
expect(subject.tag).to include 'good'
|
349
340
|
end
|
350
341
|
|
351
342
|
it 'should delete properties when statements are removed' do
|
352
|
-
subject << RDF::Statement.new(subject.rdf_subject,
|
353
|
-
subject.delete RDF::Statement.new(subject.rdf_subject,
|
343
|
+
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::CNT.chars, 'good')
|
344
|
+
subject.delete RDF::Statement.new(subject.rdf_subject, RDF::Vocab::CNT.chars, 'good')
|
354
345
|
expect(subject.tag).to eq []
|
355
346
|
end
|
356
347
|
end
|
@@ -359,18 +350,18 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
359
350
|
before do
|
360
351
|
class DummyPerson < ActiveTriples::Resource
|
361
352
|
configure :type => RDF::URI('http://example.org/Person')
|
362
|
-
property :foafname, :predicate => RDF::FOAF.name
|
363
|
-
property :publications, :predicate => RDF::FOAF.publications, :class_name => 'DummyDocument'
|
364
|
-
property :knows, :predicate => RDF::FOAF.knows, :class_name => DummyPerson
|
353
|
+
property :foafname, :predicate => RDF::Vocab::FOAF.name
|
354
|
+
property :publications, :predicate => RDF::Vocab::FOAF.publications, :class_name => 'DummyDocument'
|
355
|
+
property :knows, :predicate => RDF::Vocab::FOAF.knows, :class_name => DummyPerson
|
365
356
|
end
|
366
357
|
|
367
358
|
class DummyDocument < ActiveTriples::Resource
|
368
359
|
configure :type => RDF::URI('http://example.org/Document')
|
369
|
-
property :title, :predicate => RDF::DC.title
|
370
|
-
property :creator, :predicate => RDF::DC.creator, :class_name => 'DummyPerson'
|
360
|
+
property :title, :predicate => RDF::Vocab::DC.title
|
361
|
+
property :creator, :predicate => RDF::Vocab::DC.creator, :class_name => 'DummyPerson'
|
371
362
|
end
|
372
363
|
|
373
|
-
LD4L::OpenAnnotationRDF::TagBody.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument
|
364
|
+
LD4L::OpenAnnotationRDF::TagBody.property :item, :predicate => RDF::Vocab::DC.relation, :class_name => DummyDocument
|
374
365
|
end
|
375
366
|
|
376
367
|
subject { LD4L::OpenAnnotationRDF::TagBody.new }
|
@@ -423,8 +414,10 @@ END
|
|
423
414
|
document1.creator = [person1, person2]
|
424
415
|
document2.creator = person1
|
425
416
|
person1.knows = person2
|
417
|
+
person2.knows = person1
|
426
418
|
subject.item = [document1]
|
427
|
-
expect(subject.item.first.creator.first.knows.first.foafname)
|
419
|
+
expect(subject.item.first.creator.first.knows.first.foafname)
|
420
|
+
.to satisfy { |names| ['Alice', 'Bob'].include? names.first }
|
428
421
|
end
|
429
422
|
end
|
430
423
|
end
|