ld4l-open_annotation_rdf 0.0.12 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +49 -0
- data/Gemfile +0 -1
- data/ld4l-open_annotation_rdf.gemspec +4 -8
- data/lib/ld4l/open_annotation_rdf/annotation.rb +3 -1
- data/lib/ld4l/open_annotation_rdf/comment_annotation.rb +17 -4
- data/lib/ld4l/open_annotation_rdf/semantic_tag_annotation.rb +10 -1
- data/lib/ld4l/open_annotation_rdf/tag_annotation.rb +30 -7
- data/lib/ld4l/open_annotation_rdf/tag_body.rb +3 -2
- data/lib/ld4l/open_annotation_rdf/version.rb +1 -1
- data/spec/ld4l/open_annotation_rdf/annotation_spec.rb +25 -27
- data/spec/ld4l/open_annotation_rdf/comment_annotation_spec.rb +34 -17
- data/spec/ld4l/open_annotation_rdf/comment_body_spec.rb +42 -31
- data/spec/ld4l/open_annotation_rdf/semantic_tag_annotation_spec.rb +27 -20
- data/spec/ld4l/open_annotation_rdf/semantic_tag_body_spec.rb +22 -22
- data/spec/ld4l/open_annotation_rdf/tag_annotation_spec.rb +28 -21
- data/spec/ld4l/open_annotation_rdf/tag_body_spec.rb +23 -23
- metadata +38 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88d80519b6716911be96e530e8d9d749fb164e21
|
4
|
+
data.tar.gz: e27c7e618cbdc975d45dee93aed8676614380831
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d17c5d27f63bd1ea4de5884cebef473438ff6fb853583ace7b4276b7cceda2bfaa0980546d9119b8fea137530664a23a9ef73408823d694c3a2831eae220f953
|
7
|
+
data.tar.gz: 6d8cdeaa648f3ff54dd0073add06286309c18b7331f514f62a5a860fee9a95c2833db944a65a17ec96b791ad72c03b4c1d099471f90117721e5218da2bf7c34d
|
data/CHANGES.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
0.1.0
|
2
|
+
-----
|
3
|
+
* Updated to work with ActiveTriples 0.5, 0.6, and 0.8.2
|
4
|
+
|
5
|
+
0.0.12 (pre-release)
|
6
|
+
------
|
7
|
+
* add convenience method SemanticTagAnnotation.getTerm
|
8
|
+
|
9
|
+
0.0.11 (pre-release)
|
10
|
+
------
|
11
|
+
* add convenience methods
|
12
|
+
* add Annotations.find_by_target
|
13
|
+
* add CommentAnnotation.getComment
|
14
|
+
* add TagAnnotation.getTag
|
15
|
+
|
16
|
+
0.0.10 (pre-release)
|
17
|
+
------
|
18
|
+
* Improve functioning of Annotation#resume
|
19
|
+
* add SemanticTagBody class to hasBody property in SemanticTag
|
20
|
+
* remove class validation of motivatedBy in the resume method because it can have multiple classes; validation of value is sufficient
|
21
|
+
* Add tests for body as blank node
|
22
|
+
* add tests for Annotation#resume where body as blank node was created using the gem models
|
23
|
+
* add tests for Annotation#resume where body as blank node was loaded from an RDF::Graph
|
24
|
+
|
25
|
+
0.0.9 (pre-release)
|
26
|
+
-----
|
27
|
+
* FIX: cast should set be to false not true
|
28
|
+
|
29
|
+
0.0.8 (pre-release)
|
30
|
+
-----
|
31
|
+
* Add casting restrictions
|
32
|
+
* Let Annotation.resume receive same parameters as .new
|
33
|
+
* Annotation.resume now accepts the following values for its parameter.
|
34
|
+
* RDF::URI - e.g. RDF::URI('http://example.org/t123') -- this is the only value accepted prior to this change
|
35
|
+
* string URI - e.g. 'http://example.org/t123'
|
36
|
+
* localname - e.g. 't123' -- This will be expanded by appending 't123' to the end of the configured base_uri
|
37
|
+
|
38
|
+
0.0.6 (pre-release)
|
39
|
+
-----
|
40
|
+
* Reduce required ruby to 1.9.3
|
41
|
+
|
42
|
+
0.0.4 (pre-release)
|
43
|
+
-----
|
44
|
+
* Initial release of gem
|
45
|
+
* Supports following annotation types:
|
46
|
+
* Comment Annotation - free form text
|
47
|
+
* Tag Annotation - one word or short phrase tag written by the user
|
48
|
+
* Semantic Tag Annotation - term from a controlled vocabulary
|
49
|
+
* See README for more information and usage examples.
|
data/Gemfile
CHANGED
@@ -17,19 +17,15 @@ Gem::Specification.new do |spec|
|
|
17
17
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0")
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
-
# spec.test_files = `git ls-files -- {spec}/*`.split("\n") # FROM ActiveTriples gemspec file
|
21
|
-
# spec.require_paths = ["lib"] # NOT IN ActiveTriples gemspec file
|
22
20
|
|
23
|
-
|
24
|
-
spec.add_dependency('rdf', '~> 1.1')
|
21
|
+
spec.add_dependency('rdf', '= 1.99.0')
|
25
22
|
|
26
|
-
spec.add_dependency('active-triples', '~> 0.5')
|
27
|
-
spec.add_dependency('active_triples-local_name'
|
23
|
+
spec.add_dependency('active-triples', '~> 0.5', '~> 0.6', '~>0.8.2')
|
24
|
+
spec.add_dependency('active_triples-local_name')
|
28
25
|
spec.add_dependency('ld4l-foaf_rdf', '~> 0.0')
|
29
26
|
|
30
27
|
spec.add_development_dependency('pry')
|
31
|
-
|
32
|
-
# spec.add_development_dependency('pry-debugger') # Works with ruby < 2
|
28
|
+
spec.add_development_dependency('pry-byebug')
|
33
29
|
spec.add_development_dependency('rdoc')
|
34
30
|
spec.add_development_dependency('rspec')
|
35
31
|
spec.add_development_dependency('coveralls')
|
@@ -23,6 +23,8 @@ module LD4L
|
|
23
23
|
|
24
24
|
# get motivatedBy
|
25
25
|
m = a.get_values(:motivatedBy)
|
26
|
+
m = m.to_a if Object.const_defined?("ActiveTriples::Relation") && m.kind_of?(ActiveTriples::Relation)
|
27
|
+
|
26
28
|
# TODO: Should m's class be validated? I've seen it be RDF::Vocabulary::Term and RDF::URI. For now, removing the validation.
|
27
29
|
return a unless m.kind_of?(Array) && m.size > 0
|
28
30
|
# return a unless m.kind_of?(Array) && m.size > 0 && (m.first.kind_of?(RDF::Vocabulary::Term) || m.first.kind_of?(RDF::URI)
|
@@ -36,7 +38,7 @@ module LD4L
|
|
36
38
|
# Tagging can be TagAnnotation or SemanticTagAnnotation. Only way to tell is by checking type of body.
|
37
39
|
sta = LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new(uri_or_str)
|
38
40
|
stb = sta.getBody
|
39
|
-
return sta
|
41
|
+
return sta unless stb.type.include?(RDFVocabularies::OA.Tag) || !stb.type.include?(RDFVocabularies::OA.SemanticTag)
|
40
42
|
|
41
43
|
ta = LD4L::OpenAnnotationRDF::TagAnnotation.new(uri_or_str)
|
42
44
|
tb = ta.getBody
|
@@ -4,6 +4,10 @@ module LD4L
|
|
4
4
|
|
5
5
|
@localname_prefix="ca"
|
6
6
|
|
7
|
+
configure :type => RDFVocabularies::OA.Annotation,
|
8
|
+
:base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri,
|
9
|
+
:repository => :default
|
10
|
+
|
7
11
|
property :hasBody, :predicate => RDFVocabularies::OA.hasBody, :class_name => LD4L::OpenAnnotationRDF::CommentBody
|
8
12
|
|
9
13
|
|
@@ -14,10 +18,18 @@ module LD4L
|
|
14
18
|
#
|
15
19
|
# @return instance of CommentAnnotation
|
16
20
|
def setComment(comment)
|
17
|
-
@body
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
@body ||= hasBody.first if hasBody.size > 0
|
22
|
+
if self.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
23
|
+
@body ||= LD4L::OpenAnnotationRDF::CommentBody.new(
|
24
|
+
ActiveTriples::LocalName::Minter.generate_local_name(
|
25
|
+
LD4L::OpenAnnotationRDF::CommentBody, 10, @localname_prefix,
|
26
|
+
LD4L::OpenAnnotationRDF.configuration.localname_minter),self)
|
27
|
+
else # < ActiveTriples 0.8
|
28
|
+
@body ||= LD4L::OpenAnnotationRDF::CommentBody.new(
|
29
|
+
ActiveTriples::LocalName::Minter.generate_local_name(
|
30
|
+
LD4L::OpenAnnotationRDF::CommentBody, 10, @localname_prefix,
|
31
|
+
LD4L::OpenAnnotationRDF.configuration.localname_minter))
|
32
|
+
end
|
21
33
|
@body.content = comment
|
22
34
|
@body.format = "text/plain"
|
23
35
|
set_value(:hasBody, @body)
|
@@ -41,6 +53,7 @@ module LD4L
|
|
41
53
|
|
42
54
|
# set motivatedBy
|
43
55
|
m = get_values(:motivatedBy)
|
56
|
+
m = m.to_a if Object.const_defined?("ActiveTriples::Relation") && m.kind_of?(ActiveTriples::Relation)
|
44
57
|
set_value(:motivatedBy, RDFVocabularies::OA.commenting) unless m.kind_of?(Array) && m.size > 0
|
45
58
|
|
46
59
|
# resume CommentBody if it exists
|
@@ -4,6 +4,10 @@ module LD4L
|
|
4
4
|
|
5
5
|
@localname_prefix = "sta"
|
6
6
|
|
7
|
+
configure :type => RDFVocabularies::OA.Annotation,
|
8
|
+
:base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri,
|
9
|
+
:repository => :default
|
10
|
+
|
7
11
|
property :hasBody, :predicate => RDFVocabularies::OA.hasBody, :class_name => LD4L::OpenAnnotationRDF::SemanticTagBody
|
8
12
|
|
9
13
|
|
@@ -38,7 +42,11 @@ module LD4L
|
|
38
42
|
term_uri = RDF::URI(term_uri) unless term_uri.kind_of?(RDF::URI)
|
39
43
|
return @body if old_term_uri && old_term_uri == term_uri.to_s
|
40
44
|
|
41
|
-
|
45
|
+
if self.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
46
|
+
@body = LD4L::OpenAnnotationRDF::SemanticTagBody.new(term_uri,self)
|
47
|
+
else # < ActiveTriples 0.8
|
48
|
+
@body = LD4L::OpenAnnotationRDF::SemanticTagBody.new(term_uri)
|
49
|
+
end
|
42
50
|
set_value(:hasBody, @body)
|
43
51
|
@body
|
44
52
|
end
|
@@ -51,6 +59,7 @@ module LD4L
|
|
51
59
|
|
52
60
|
# set motivatedBy
|
53
61
|
m = get_values(:motivatedBy)
|
62
|
+
m = m.to_a if Object.const_defined?("ActiveTriples::Relation") && m.kind_of?(ActiveTriples::Relation)
|
54
63
|
set_value(:motivatedBy, RDFVocabularies::OA.tagging) unless m.kind_of?(Array) && m.size > 0
|
55
64
|
|
56
65
|
# resume SemanticTagBody if it exists
|
@@ -4,6 +4,10 @@ module LD4L
|
|
4
4
|
|
5
5
|
@localname_prefix="ta"
|
6
6
|
|
7
|
+
configure :type => RDFVocabularies::OA.Annotation,
|
8
|
+
:base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri,
|
9
|
+
:repository => :default
|
10
|
+
|
7
11
|
property :hasBody, :predicate => RDFVocabularies::OA.hasBody, :class_name => LD4L::OpenAnnotationRDF::TagBody
|
8
12
|
|
9
13
|
# TODO: Should a tag be destroyed when the last annotation referencing the tag is destroyed?
|
@@ -40,12 +44,23 @@ module LD4L
|
|
40
44
|
# ** If one found, set @body to this TagBody
|
41
45
|
# ** If multiple found, use the first one found
|
42
46
|
# ### the same one may not be the first one found each time the query executes
|
43
|
-
|
47
|
+
if self.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
48
|
+
@body = LD4L::OpenAnnotationRDF.configuration.unique_tags ? LD4L::OpenAnnotationRDF::TagBody.fetch_by_tag_value(tag,self) : nil
|
49
|
+
else
|
50
|
+
@body = LD4L::OpenAnnotationRDF.configuration.unique_tags ? LD4L::OpenAnnotationRDF::TagBody.fetch_by_tag_value(tag) : nil
|
51
|
+
end
|
44
52
|
if @body == nil
|
45
|
-
|
53
|
+
if self.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
54
|
+
@body = LD4L::OpenAnnotationRDF::TagBody.new(
|
46
55
|
ActiveTriples::LocalName::Minter.generate_local_name(
|
47
56
|
LD4L::OpenAnnotationRDF::TagBody, 10, @localname_prefix,
|
48
|
-
LD4L::OpenAnnotationRDF.configuration.localname_minter ))
|
57
|
+
LD4L::OpenAnnotationRDF.configuration.localname_minter ),self)
|
58
|
+
else # < ActiveTriples 0.8
|
59
|
+
@body = LD4L::OpenAnnotationRDF::TagBody.new(
|
60
|
+
ActiveTriples::LocalName::Minter.generate_local_name(
|
61
|
+
LD4L::OpenAnnotationRDF::TagBody, 10, @localname_prefix,
|
62
|
+
LD4L::OpenAnnotationRDF.configuration.localname_minter ))
|
63
|
+
end
|
49
64
|
@body.tag = tag
|
50
65
|
end
|
51
66
|
else
|
@@ -62,10 +77,17 @@ module LD4L
|
|
62
77
|
# * [CURRENT] Always create a new TagBody each time setTag is called and update @body
|
63
78
|
# ### This last options has the potential for orphaned TagBodys that no TagAnnotation references.
|
64
79
|
# TODO Rethink the current behavior which is always to create a new TagBody potentially leaving around orphans.
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
80
|
+
if self.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
81
|
+
@body = LD4L::OpenAnnotationRDF::TagBody.new(
|
82
|
+
ActiveTriples::LocalName::Minter.generate_local_name(
|
83
|
+
LD4L::OpenAnnotationRDF::TagBody, 10, @localname_prefix,
|
84
|
+
LD4L::OpenAnnotationRDF.configuration.localname_minter ),self)
|
85
|
+
else # < ActiveTriples 0.8
|
86
|
+
@body = LD4L::OpenAnnotationRDF::TagBody.new(
|
87
|
+
ActiveTriples::LocalName::Minter.generate_local_name(
|
88
|
+
LD4L::OpenAnnotationRDF::TagBody, 10, @localname_prefix,
|
89
|
+
LD4L::OpenAnnotationRDF.configuration.localname_minter ))
|
90
|
+
end
|
69
91
|
@body.tag = tag
|
70
92
|
end
|
71
93
|
set_value(:hasBody, @body)
|
@@ -80,6 +102,7 @@ module LD4L
|
|
80
102
|
|
81
103
|
# set motivatedBy
|
82
104
|
m = get_values(:motivatedBy)
|
105
|
+
m = m.to_a if Object.const_defined?("ActiveTriples::Relation") && m.kind_of?(ActiveTriples::Relation)
|
83
106
|
set_value(:motivatedBy, RDFVocabularies::OA.tagging) unless m.kind_of?(Array) && m.size > 0
|
84
107
|
|
85
108
|
# resume TagBody if it exists
|
@@ -50,7 +50,7 @@ module LD4L
|
|
50
50
|
# @param [String] tag value
|
51
51
|
#
|
52
52
|
# @return instance of TagBody if found; otherwise, nil
|
53
|
-
def self::fetch_by_tag_value( tag_value )
|
53
|
+
def self::fetch_by_tag_value( tag_value, parent_annotation=nil )
|
54
54
|
raise ArgumentError, 'Argument must be a string with at least one character' unless
|
55
55
|
tag_value.kind_of?(String) && tag_value.size > 0
|
56
56
|
|
@@ -66,7 +66,8 @@ module LD4L
|
|
66
66
|
results = query.execute(repo)
|
67
67
|
unless( results.empty? )
|
68
68
|
tagbody_uri = results[0].to_hash[:tagbody]
|
69
|
-
tagbody = LD4L::OpenAnnotationRDF::TagBody.new(tagbody_uri)
|
69
|
+
tagbody = LD4L::OpenAnnotationRDF::TagBody.new(tagbody_uri) if parent_annotation.nil?
|
70
|
+
tagbody = LD4L::OpenAnnotationRDF::TagBody.new(tagbody_uri,parent_annotation) unless parent_annotation.nil?
|
70
71
|
end
|
71
72
|
tagbody
|
72
73
|
end
|
@@ -51,7 +51,7 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'should not be settable' do
|
54
|
-
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error
|
54
|
+
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error(RuntimeError, 'Refusing update URI when one is already assigned!')
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -368,14 +368,14 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
|
|
368
368
|
anno_uri = RDF::URI.new(@anno_url)
|
369
369
|
@comment_anno = LD4L::OpenAnnotationRDF::Annotation.resume(anno_uri)
|
370
370
|
end
|
371
|
-
it "populates LD4L::OpenAnnotationRDF::
|
371
|
+
it "populates LD4L::OpenAnnotationRDF::CommentAnnotation properly" do
|
372
372
|
expect(@comment_anno.rdf_subject.to_s).to eq @anno_url
|
373
373
|
expect(@comment_anno).to be_a LD4L::OpenAnnotationRDF::CommentAnnotation
|
374
374
|
expect(@comment_anno.type).to include(RDFVocabularies::OA.Annotation)
|
375
375
|
expect(@comment_anno.motivatedBy).to include(RDFVocabularies::OA.commenting)
|
376
376
|
expect(@comment_anno.hasTarget.first.rdf_subject).to eq RDF::URI.new("http://searchworks.stanford.edu/view/666")
|
377
377
|
end
|
378
|
-
it "populates
|
378
|
+
it "populates Comment bodies properly" do
|
379
379
|
body = @comment_anno.hasBody.first
|
380
380
|
expect(body).to be_a LD4L::OpenAnnotationRDF::CommentBody
|
381
381
|
expect(body.content.first).to eq @comment_value
|
@@ -515,14 +515,18 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
|
|
515
515
|
context "and the item is not a blank node" do
|
516
516
|
|
517
517
|
subject {LD4L::OpenAnnotationRDF::Annotation.new("123")}
|
518
|
+
let(:result) { subject.persist! }
|
518
519
|
|
519
520
|
before do
|
520
521
|
# Create inmemory repository
|
521
522
|
@repo = RDF::Repository.new
|
522
|
-
|
523
|
-
allow(subject).to receive(:repository).and_return(@repo)
|
523
|
+
ActiveTriples::Repositories.repositories[:default] = @repo
|
524
524
|
subject.motivatedBy = RDFVocabularies::OA.commenting
|
525
|
-
|
525
|
+
result
|
526
|
+
end
|
527
|
+
|
528
|
+
it "should return true" do
|
529
|
+
expect(result).to eq true
|
526
530
|
end
|
527
531
|
|
528
532
|
it "should persist to the repository" do
|
@@ -548,7 +552,7 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
|
|
548
552
|
subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
|
549
553
|
end
|
550
554
|
|
551
|
-
subject { LD4L::
|
555
|
+
subject { LD4L::OpenAnnotationRDF::Annotation.new('123') }
|
552
556
|
|
553
557
|
it 'should return true' do
|
554
558
|
expect(subject.destroy!).to be true
|
@@ -562,22 +566,26 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
|
|
562
566
|
|
563
567
|
context 'with a parent' do
|
564
568
|
before do
|
565
|
-
|
569
|
+
subject.annotatedBy = child
|
566
570
|
end
|
567
571
|
|
568
|
-
let(:
|
569
|
-
|
572
|
+
let(:child) do
|
573
|
+
if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
574
|
+
LD4L::FoafRDF::Person.new('456',subject)
|
575
|
+
else # < ActiveTriples 0.8
|
576
|
+
LD4L::FoafRDF::Person.new('456')
|
577
|
+
end
|
570
578
|
end
|
571
579
|
|
572
580
|
it 'should empty the graph and remove it from the parent' do
|
573
|
-
|
574
|
-
expect(
|
581
|
+
child.destroy
|
582
|
+
expect(subject.annotatedBy).to be_empty
|
575
583
|
end
|
576
584
|
|
577
585
|
it 'should remove its whole graph from the parent' do
|
578
|
-
|
579
|
-
|
580
|
-
expect(
|
586
|
+
child.destroy
|
587
|
+
child.each_statement do |s|
|
588
|
+
expect(subject.statements).not_to include s
|
581
589
|
end
|
582
590
|
end
|
583
591
|
end
|
@@ -674,7 +682,8 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
|
|
674
682
|
|
675
683
|
describe '#type' do
|
676
684
|
it 'should return the type configured on the parent class' do
|
677
|
-
|
685
|
+
expected_result = LD4L::OpenAnnotationRDF::Annotation.type.kind_of?(Array) ? LD4L::OpenAnnotationRDF::Annotation.type : [LD4L::OpenAnnotationRDF::Annotation.type]
|
686
|
+
expect(subject.type).to eq expected_result
|
678
687
|
end
|
679
688
|
|
680
689
|
it 'should set the type' do
|
@@ -708,17 +717,6 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
|
|
708
717
|
end
|
709
718
|
end
|
710
719
|
|
711
|
-
describe '#solrize' do
|
712
|
-
it 'should return a label for bnodes' do
|
713
|
-
expect(subject.solrize).to eq subject.rdf_label
|
714
|
-
end
|
715
|
-
|
716
|
-
it 'should return a string of the resource uri' do
|
717
|
-
subject.set_subject! 'http://example.org/moomin'
|
718
|
-
expect(subject.solrize).to eq 'http://example.org/moomin'
|
719
|
-
end
|
720
|
-
end
|
721
|
-
|
722
720
|
describe 'editing the graph' do
|
723
721
|
it 'should write properties when statements are added' do
|
724
722
|
subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::OA.motivatedBy, 'commenting')
|
@@ -46,7 +46,7 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'should not be settable' do
|
49
|
-
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error
|
49
|
+
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error(RuntimeError, 'Refusing update URI when one is already assigned!')
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -110,6 +110,24 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
110
110
|
expect(subject.getBody.rdf_subject.to_s).to match match /http:\/\/localhost\/[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}/
|
111
111
|
expect(subject.getBody).not_to be_persisted
|
112
112
|
end
|
113
|
+
|
114
|
+
it "should re-use body when changing the comment" do
|
115
|
+
subject.setComment('Initial comment value.')
|
116
|
+
expect(subject.getBody).to eq subject.hasBody.first
|
117
|
+
cb = subject.getBody
|
118
|
+
subject.setComment('Changed comment value.')
|
119
|
+
expect(subject.getBody).to eq subject.hasBody.first
|
120
|
+
expect(subject.getBody.object_id).to eq cb.object_id
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#getComment' do
|
125
|
+
before do
|
126
|
+
subject.setComment('Test getting a comment.')
|
127
|
+
end
|
128
|
+
it "should get the comment" do
|
129
|
+
expect(subject.getComment).to eq 'Test getting a comment.'
|
130
|
+
end
|
113
131
|
end
|
114
132
|
|
115
133
|
describe 'annotatedBy' do
|
@@ -236,14 +254,18 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
236
254
|
context "and the item is not a blank node" do
|
237
255
|
|
238
256
|
subject {LD4L::OpenAnnotationRDF::CommentAnnotation.new("123")}
|
257
|
+
let(:result) { subject.persist! }
|
239
258
|
|
240
259
|
before do
|
241
260
|
# Create inmemory repository
|
242
261
|
@repo = RDF::Repository.new
|
243
|
-
|
244
|
-
allow(subject).to receive(:repository).and_return(@repo)
|
262
|
+
ActiveTriples::Repositories.repositories[:default] = @repo
|
245
263
|
subject.motivatedBy = RDFVocabularies::OA.commenting
|
246
|
-
|
264
|
+
result
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should return true" do
|
268
|
+
expect(result).to eq true
|
247
269
|
end
|
248
270
|
|
249
271
|
it "should persist to the repository" do
|
@@ -268,6 +290,7 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
268
290
|
end
|
269
291
|
it "should persist body to the repository" do
|
270
292
|
cb = LD4L::OpenAnnotationRDF::CommentBody.new(subject.getBody.rdf_subject)
|
293
|
+
expect(cb.content).to eq ['I like this.']
|
271
294
|
expect(cb).to be_persisted
|
272
295
|
expect(subject.getBody.rdf_subject.to_s).to eq cb.rdf_subject.to_s
|
273
296
|
end
|
@@ -299,7 +322,11 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
299
322
|
end
|
300
323
|
|
301
324
|
let(:child) do
|
302
|
-
|
325
|
+
if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
326
|
+
LD4L::FoafRDF::Person.new('456',subject)
|
327
|
+
else # < ActiveTriples 0.8
|
328
|
+
LD4L::FoafRDF::Person.new('456')
|
329
|
+
end
|
303
330
|
end
|
304
331
|
|
305
332
|
it 'should empty the graph and remove it from the parent' do
|
@@ -426,7 +453,8 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
426
453
|
|
427
454
|
describe '#type' do
|
428
455
|
it 'should return the type configured on the parent class' do
|
429
|
-
|
456
|
+
expected_result = LD4L::OpenAnnotationRDF::CommentAnnotation.type.kind_of?(Array) ? LD4L::OpenAnnotationRDF::CommentAnnotation.type : [LD4L::OpenAnnotationRDF::CommentAnnotation.type]
|
457
|
+
expect(subject.type).to eq expected_result
|
430
458
|
end
|
431
459
|
|
432
460
|
it 'should set the type' do
|
@@ -460,17 +488,6 @@ describe 'LD4L::OpenAnnotationRDF::CommentAnnotation' do
|
|
460
488
|
end
|
461
489
|
end
|
462
490
|
|
463
|
-
describe '#solrize' do
|
464
|
-
it 'should return a label for bnodes' do
|
465
|
-
expect(subject.solrize).to eq subject.rdf_label
|
466
|
-
end
|
467
|
-
|
468
|
-
it 'should return a string of the resource uri' do
|
469
|
-
subject.set_subject! 'http://example.org/moomin'
|
470
|
-
expect(subject.solrize).to eq 'http://example.org/moomin'
|
471
|
-
end
|
472
|
-
end
|
473
|
-
|
474
491
|
describe 'editing the graph' do
|
475
492
|
it 'should write properties when statements are added' do
|
476
493
|
subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::OA.motivatedBy, 'commenting')
|
@@ -49,7 +49,7 @@ describe 'LD4L::OpenAnnotationRDF::CommentBody' do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should not be settable' do
|
52
|
-
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error
|
52
|
+
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error(RuntimeError, 'Refusing update URI when one is already assigned!')
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -61,45 +61,58 @@ describe 'LD4L::OpenAnnotationRDF::CommentBody' do
|
|
61
61
|
|
62
62
|
describe 'type' do
|
63
63
|
it "should be set to text and ContentAsText from new" do
|
64
|
-
|
65
|
-
|
66
|
-
expect(
|
64
|
+
expected_results = subject.type
|
65
|
+
expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation)
|
66
|
+
expect(expected_results.size).to eq 2
|
67
|
+
expect(expected_results).to include RDFVocabularies::DCTYPES.Text
|
68
|
+
expect(expected_results).to include RDFVocabularies::CNT.ContentAsText
|
67
69
|
end
|
68
70
|
|
69
71
|
it "should be settable" do
|
70
72
|
subject.type = RDFVocabularies::DCTYPES.Text
|
71
|
-
|
72
|
-
|
73
|
+
expected_results = subject.type
|
74
|
+
expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation)
|
75
|
+
expect(expected_results.size).to eq 1
|
76
|
+
expect(expected_results).to include RDFVocabularies::DCTYPES.Text
|
73
77
|
end
|
74
78
|
|
75
79
|
it "should be settable to multiple values" do
|
76
80
|
t = [RDFVocabularies::DCTYPES.Text, RDFVocabularies::CNT.ContentAsText]
|
77
81
|
subject.set_value(:type,t)
|
78
|
-
|
79
|
-
|
80
|
-
expect(
|
82
|
+
expected_results = subject.type
|
83
|
+
expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation)
|
84
|
+
expect(expected_results.size).to eq 2
|
85
|
+
expect(expected_results).to include RDFVocabularies::DCTYPES.Text
|
86
|
+
expect(expected_results).to include RDFVocabularies::CNT.ContentAsText
|
81
87
|
end
|
82
88
|
|
83
89
|
it "should be changeable" do
|
84
90
|
subject.type = RDFVocabularies::DCTYPES.Text
|
85
91
|
subject.type = RDFVocabularies::CNT.ContentAsText
|
86
|
-
|
87
|
-
|
92
|
+
expected_results = subject.type
|
93
|
+
expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation)
|
94
|
+
expect(expected_results.size).to eq 1
|
95
|
+
expect(expected_results).to include RDFVocabularies::CNT.ContentAsText
|
88
96
|
end
|
89
97
|
|
90
98
|
it "should be changeable for multiple values" do
|
91
99
|
t = [RDFVocabularies::DCTYPES.Text, RDFVocabularies::CNT.ContentAsText]
|
92
100
|
subject.set_value(:type,t)
|
93
|
-
|
94
|
-
|
95
|
-
expect(
|
96
|
-
|
101
|
+
expected_results = subject.type
|
102
|
+
expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation)
|
103
|
+
expect(expected_results.size).to eq 2
|
104
|
+
expect(expected_results).to include RDFVocabularies::DCTYPES.Text
|
105
|
+
expect(expected_results).to include RDFVocabularies::CNT.ContentAsText
|
106
|
+
|
107
|
+
t = subject.get_values(:type).to_a
|
97
108
|
t[0] = RDFVocabularies::OA.Tag # dummy type for testing
|
98
109
|
t[1] = RDFVocabularies::OA.SemanticTag # dummy type for testing
|
99
110
|
subject.set_value(:type,t)
|
100
|
-
|
101
|
-
|
102
|
-
expect(
|
111
|
+
expected_results = subject.type
|
112
|
+
expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation)
|
113
|
+
expect(expected_results.size).to eq 2
|
114
|
+
expect(expected_results).to include RDFVocabularies::OA.Tag
|
115
|
+
expect(expected_results).to include RDFVocabularies::OA.SemanticTag
|
103
116
|
end
|
104
117
|
end
|
105
118
|
|
@@ -207,14 +220,23 @@ describe 'LD4L::OpenAnnotationRDF::CommentBody' do
|
|
207
220
|
context "and the item is not a blank node" do
|
208
221
|
|
209
222
|
subject {LD4L::OpenAnnotationRDF::CommentBody.new("123")}
|
223
|
+
let(:result) { subject.persist! }
|
210
224
|
|
211
225
|
before do
|
212
226
|
# Create inmemory repository
|
213
227
|
@repo = RDF::Repository.new
|
214
228
|
allow(subject.class).to receive(:repository).and_return(nil)
|
215
|
-
|
229
|
+
if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
230
|
+
allow(subject.persistence_strategy).to receive(:repository).and_return(@repo)
|
231
|
+
else # < ActiveTriples 0.8
|
232
|
+
allow(subject).to receive(:repository).and_return(@repo)
|
233
|
+
end
|
216
234
|
subject.content = "bla"
|
217
|
-
|
235
|
+
result
|
236
|
+
end
|
237
|
+
|
238
|
+
it "should return true" do
|
239
|
+
expect(result).to eq true
|
218
240
|
end
|
219
241
|
|
220
242
|
it "should persist to the repository" do
|
@@ -272,17 +294,6 @@ describe 'LD4L::OpenAnnotationRDF::CommentBody' do
|
|
272
294
|
end
|
273
295
|
end
|
274
296
|
|
275
|
-
describe '#solrize' do
|
276
|
-
it 'should return a label for bnodes' do
|
277
|
-
expect(subject.solrize).to eq subject.rdf_label
|
278
|
-
end
|
279
|
-
|
280
|
-
it 'should return a string of the resource uri' do
|
281
|
-
subject.set_subject! 'http://example.org/moomin'
|
282
|
-
expect(subject.solrize).to eq 'http://example.org/moomin'
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
297
|
describe 'editing the graph' do
|
287
298
|
it 'should write properties when statements are added' do
|
288
299
|
subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::CNT.chars, 'Great book!')
|
@@ -48,7 +48,7 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'should not be settable' do
|
51
|
-
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error
|
51
|
+
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error(RuntimeError, 'Refusing update URI when one is already assigned!')
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -109,19 +109,19 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
109
109
|
|
110
110
|
context "when new value is nil" do
|
111
111
|
it "should throw invalid arguement exception" do
|
112
|
-
expect{ subject.setTerm(nil) }.to raise_error
|
112
|
+
expect{ subject.setTerm(nil) }.to raise_error(ArgumentError, 'Argument must be a uri string or an instance of RDF::URI')
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
116
|
context "when new value is a string of 0 length" do
|
117
117
|
it "should throw invalid arguement exception" do
|
118
|
-
expect{ subject.setTerm("") }.to raise_error
|
118
|
+
expect{ subject.setTerm("") }.to raise_error(ArgumentError, 'Argument must be a uri string or an instance of RDF::URI')
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
122
|
context "when new value is not a string or uri" do
|
123
123
|
it "should throw invalid arguement exception" do
|
124
|
-
expect{ subject.setTerm(3) }.to raise_error
|
124
|
+
expect{ subject.setTerm(3) }.to raise_error(ArgumentError, 'Argument must be a uri string or an instance of RDF::URI')
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -133,6 +133,15 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
+
describe '#getTerm' do
|
137
|
+
before do
|
138
|
+
subject.setTerm('TestTerm')
|
139
|
+
end
|
140
|
+
it "should get the tag" do
|
141
|
+
expect(subject.getTerm).to eq 'TestTerm'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
136
145
|
context "when term doesn't already exist as a SemanticTagBody" do
|
137
146
|
before do
|
138
147
|
stb = LD4L::OpenAnnotationRDF::SemanticTagBody.new('http://example.org/new_term')
|
@@ -294,14 +303,18 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
294
303
|
context "and the item is not a blank node" do
|
295
304
|
|
296
305
|
subject {LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new("123")}
|
306
|
+
let(:result) { subject.persist! }
|
297
307
|
|
298
308
|
before do
|
299
309
|
# Create inmemory repository
|
300
310
|
@repo = RDF::Repository.new
|
301
|
-
|
302
|
-
allow(subject).to receive(:repository).and_return(@repo)
|
311
|
+
ActiveTriples::Repositories.repositories[:default] = @repo
|
303
312
|
subject.motivatedBy = RDFVocabularies::OA.commenting
|
304
|
-
|
313
|
+
result
|
314
|
+
end
|
315
|
+
|
316
|
+
it "should return true" do
|
317
|
+
expect(result).to eq true
|
305
318
|
end
|
306
319
|
|
307
320
|
it "should persist to the repository" do
|
@@ -359,7 +372,11 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
359
372
|
end
|
360
373
|
|
361
374
|
let(:child) do
|
362
|
-
|
375
|
+
if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
376
|
+
LD4L::FoafRDF::Person.new('456',subject)
|
377
|
+
else # < ActiveTriples 0.8
|
378
|
+
LD4L::FoafRDF::Person.new('456')
|
379
|
+
end
|
363
380
|
end
|
364
381
|
|
365
382
|
it 'should empty the graph and remove it from the parent' do
|
@@ -486,7 +503,8 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
486
503
|
|
487
504
|
describe '#type' do
|
488
505
|
it 'should return the type configured on the parent class' do
|
489
|
-
|
506
|
+
expected_result = LD4L::OpenAnnotationRDF::SemanticTagAnnotation.type.kind_of?(Array) ? LD4L::OpenAnnotationRDF::SemanticTagAnnotation.type : [LD4L::OpenAnnotationRDF::SemanticTagAnnotation.type]
|
507
|
+
expect(subject.type).to eq expected_result
|
490
508
|
end
|
491
509
|
|
492
510
|
it 'should set the type' do
|
@@ -520,17 +538,6 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagAnnotation' do
|
|
520
538
|
end
|
521
539
|
end
|
522
540
|
|
523
|
-
describe '#solrize' do
|
524
|
-
it 'should return a label for bnodes' do
|
525
|
-
expect(subject.solrize).to eq subject.rdf_label
|
526
|
-
end
|
527
|
-
|
528
|
-
it 'should return a string of the resource uri' do
|
529
|
-
subject.set_subject! 'http://example.org/moomin'
|
530
|
-
expect(subject.solrize).to eq 'http://example.org/moomin'
|
531
|
-
end
|
532
|
-
end
|
533
|
-
|
534
541
|
describe 'editing the graph' do
|
535
542
|
it 'should write properties when statements are added' do
|
536
543
|
subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::OA.motivatedBy, 'commenting')
|
@@ -49,7 +49,7 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should not be settable' do
|
52
|
-
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error
|
52
|
+
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error(RuntimeError, 'Refusing update URI when one is already assigned!')
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -61,8 +61,10 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
61
61
|
|
62
62
|
describe 'type' do
|
63
63
|
it "should be set to text and astext from new" do
|
64
|
-
|
65
|
-
|
64
|
+
expected_results = subject.type
|
65
|
+
expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation)
|
66
|
+
expect(expected_results.size).to eq 1
|
67
|
+
expect(expected_results).to include RDFVocabularies::OA.SemanticTag
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
@@ -77,19 +79,19 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
77
79
|
|
78
80
|
context "when term value is nil" do
|
79
81
|
it "should throw invalid arguement exception" do
|
80
|
-
expect{ LD4L::OpenAnnotationRDF::SemanticTagBody.annotations_using(nil) }.to raise_error
|
82
|
+
expect{ LD4L::OpenAnnotationRDF::SemanticTagBody.annotations_using(nil) }.to raise_error(ArgumentError, 'Argument must be a uri string or an instance of RDF::URI')
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
84
86
|
context "when term value is a string of 0 length" do
|
85
87
|
it "should throw invalid arguement exception" do
|
86
|
-
expect{ LD4L::OpenAnnotationRDF::SemanticTagBody.annotations_using("") }.to raise_error
|
88
|
+
expect{ LD4L::OpenAnnotationRDF::SemanticTagBody.annotations_using("") }.to raise_error(ArgumentError, 'Argument must be a uri string or an instance of RDF::URI')
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
90
92
|
context "when term is not a string or uri" do
|
91
93
|
it "should throw invalid arguement exception" do
|
92
|
-
expect{ LD4L::OpenAnnotationRDF::SemanticTagBody.annotations_using(3) }.to raise_error
|
94
|
+
expect{ LD4L::OpenAnnotationRDF::SemanticTagBody.annotations_using(3) }.to raise_error(ArgumentError, 'Argument must be a uri string or an instance of RDF::URI')
|
93
95
|
end
|
94
96
|
end
|
95
97
|
|
@@ -154,19 +156,19 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
154
156
|
describe "#destroy_if_unused" do
|
155
157
|
context "when term is nil" do
|
156
158
|
it "should throw invalid arguement exception" do
|
157
|
-
expect{ LD4L::OpenAnnotationRDF::SemanticTagBody.destroy_if_unused(nil) }.to raise_error
|
159
|
+
expect{ LD4L::OpenAnnotationRDF::SemanticTagBody.destroy_if_unused(nil) }.to raise_error(ArgumentError, 'Argument must be a uri string or an instance of RDF::URI')
|
158
160
|
end
|
159
161
|
end
|
160
162
|
|
161
163
|
context "when term is a string of 0 length" do
|
162
164
|
it "should throw invalid arguement exception" do
|
163
|
-
expect{ LD4L::OpenAnnotationRDF::SemanticTagBody.destroy_if_unused("") }.to raise_error
|
165
|
+
expect{ LD4L::OpenAnnotationRDF::SemanticTagBody.destroy_if_unused("") }.to raise_error(ArgumentError, 'Argument must be a uri string or an instance of RDF::URI')
|
164
166
|
end
|
165
167
|
end
|
166
168
|
|
167
169
|
context "when term is not a string or uri" do
|
168
170
|
it "should throw invalid arguement exception" do
|
169
|
-
expect{ LD4L::OpenAnnotationRDF::SemanticTagBody.destroy_if_unused(3) }.to raise_error
|
171
|
+
expect{ LD4L::OpenAnnotationRDF::SemanticTagBody.destroy_if_unused(3) }.to raise_error(ArgumentError, 'Argument must be a uri string or an instance of RDF::URI')
|
170
172
|
end
|
171
173
|
end
|
172
174
|
|
@@ -266,13 +268,22 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
266
268
|
context "and the item is not a blank node" do
|
267
269
|
|
268
270
|
subject {LD4L::OpenAnnotationRDF::SemanticTagBody.new("123")}
|
271
|
+
let(:result) { subject.persist! }
|
269
272
|
|
270
273
|
before do
|
271
274
|
# Create inmemory repository
|
272
275
|
@repo = RDF::Repository.new
|
273
276
|
allow(subject.class).to receive(:repository).and_return(nil)
|
274
|
-
|
275
|
-
|
277
|
+
if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
278
|
+
allow(subject.persistence_strategy).to receive(:repository).and_return(@repo)
|
279
|
+
else # < ActiveTriples 0.8
|
280
|
+
allow(subject).to receive(:repository).and_return(@repo)
|
281
|
+
end
|
282
|
+
result
|
283
|
+
end
|
284
|
+
|
285
|
+
it "should return true" do
|
286
|
+
expect(result).to eq true
|
276
287
|
end
|
277
288
|
|
278
289
|
it "should persist to the repository" do
|
@@ -326,17 +337,6 @@ describe 'LD4L::OpenAnnotationRDF::SemanticTagBody' do
|
|
326
337
|
end
|
327
338
|
end
|
328
339
|
|
329
|
-
describe '#solrize' do
|
330
|
-
it 'should return a label for bnodes' do
|
331
|
-
expect(subject.solrize).to eq subject.rdf_label
|
332
|
-
end
|
333
|
-
|
334
|
-
it 'should return a string of the resource uri' do
|
335
|
-
subject.set_subject! 'http://example.org/moomin'
|
336
|
-
expect(subject.solrize).to eq 'http://example.org/moomin'
|
337
|
-
end
|
338
|
-
end
|
339
|
-
|
340
340
|
describe 'big complex graphs' do
|
341
341
|
before do
|
342
342
|
class DummyPerson < ActiveTriples::Resource
|
@@ -48,7 +48,7 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'should not be settable' do
|
51
|
-
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error
|
51
|
+
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error(RuntimeError, 'Refusing update URI when one is already assigned!')
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -113,19 +113,19 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
113
113
|
|
114
114
|
context "when new value is nil" do
|
115
115
|
it "should throw invalid arguement exception" do
|
116
|
-
expect{ subject.setTag(nil) }.to raise_error
|
116
|
+
expect{ subject.setTag(nil) }.to raise_error(ArgumentError, 'Argument must be a string with at least one character')
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
context "when new value is a string of 0 length" do
|
121
121
|
it "should throw invalid arguement exception" do
|
122
|
-
expect{ subject.setTag("") }.to raise_error
|
122
|
+
expect{ subject.setTag("") }.to raise_error(ArgumentError, 'Argument must be a string with at least one character')
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
126
|
context "when new value is not a string" do
|
127
127
|
it "should throw invalid arguement exception" do
|
128
|
-
expect{ subject.setTag(3) }.to raise_error
|
128
|
+
expect{ subject.setTag(3) }.to raise_error(ArgumentError, 'Argument must be a string with at least one character')
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -133,7 +133,7 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
133
133
|
it "should return the existing TagBody unchanged" do
|
134
134
|
tb1 = subject.setTag('foo')
|
135
135
|
tb2 = subject.setTag('foo')
|
136
|
-
expect(tb2).to eq tb1
|
136
|
+
expect(tb2.object_id).to eq tb1.object_id
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -222,6 +222,15 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
222
222
|
end
|
223
223
|
end
|
224
224
|
|
225
|
+
describe '#getTag' do
|
226
|
+
before do
|
227
|
+
subject.setTag('TestTag')
|
228
|
+
end
|
229
|
+
it "should get the tag" do
|
230
|
+
expect(subject.getTag).to eq 'TestTag'
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
225
234
|
describe 'annotatedBy' do
|
226
235
|
it "should be empty array if we haven't set it" do
|
227
236
|
expect(subject.annotatedBy).to match_array([])
|
@@ -346,14 +355,18 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
346
355
|
context "and the annotation is not a blank node" do
|
347
356
|
|
348
357
|
subject {LD4L::OpenAnnotationRDF::TagAnnotation.new("123")}
|
358
|
+
let(:result) { subject.persist! }
|
349
359
|
|
350
360
|
before do
|
351
361
|
# Create inmemory repository
|
352
362
|
@repo = RDF::Repository.new
|
353
|
-
|
354
|
-
allow(subject).to receive(:repository).and_return(@repo)
|
363
|
+
ActiveTriples::Repositories.repositories[:default] = @repo
|
355
364
|
subject.motivatedBy = RDFVocabularies::OA.commenting
|
356
|
-
|
365
|
+
result
|
366
|
+
end
|
367
|
+
|
368
|
+
it "should return true" do
|
369
|
+
expect(result).to eq true
|
357
370
|
end
|
358
371
|
|
359
372
|
it "should persist to the repository" do
|
@@ -411,7 +424,11 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
411
424
|
end
|
412
425
|
|
413
426
|
let(:child) do
|
414
|
-
|
427
|
+
if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
428
|
+
LD4L::FoafRDF::Person.new('456',subject)
|
429
|
+
else # < ActiveTriples 0.8
|
430
|
+
LD4L::FoafRDF::Person.new('456')
|
431
|
+
end
|
415
432
|
end
|
416
433
|
|
417
434
|
it 'should empty the graph and remove it from the parent' do
|
@@ -539,7 +556,8 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
539
556
|
|
540
557
|
describe '#type' do
|
541
558
|
it 'should return the type configured on the parent class' do
|
542
|
-
|
559
|
+
expected_result = LD4L::OpenAnnotationRDF::TagAnnotation.type.kind_of?(Array) ? LD4L::OpenAnnotationRDF::TagAnnotation.type : [LD4L::OpenAnnotationRDF::TagAnnotation.type]
|
560
|
+
expect(subject.type).to eq expected_result
|
543
561
|
end
|
544
562
|
|
545
563
|
it 'should set the type' do
|
@@ -573,17 +591,6 @@ describe 'LD4L::OpenAnnotationRDF::TagAnnotation' do
|
|
573
591
|
end
|
574
592
|
end
|
575
593
|
|
576
|
-
describe '#solrize' do
|
577
|
-
it 'should return a label for bnodes' do
|
578
|
-
expect(subject.solrize).to eq subject.rdf_label
|
579
|
-
end
|
580
|
-
|
581
|
-
it 'should return a string of the resource uri' do
|
582
|
-
subject.set_subject! 'http://example.org/moomin'
|
583
|
-
expect(subject.solrize).to eq 'http://example.org/moomin'
|
584
|
-
end
|
585
|
-
end
|
586
|
-
|
587
594
|
describe 'editing the graph' do
|
588
595
|
it 'should write properties when statements are added' do
|
589
596
|
subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::OA.motivatedBy, 'commenting')
|
@@ -49,7 +49,7 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should not be settable' do
|
52
|
-
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error
|
52
|
+
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error(RuntimeError, 'Refusing update URI when one is already assigned!')
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -61,9 +61,11 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
61
61
|
|
62
62
|
describe 'type' do
|
63
63
|
it "should be set to text and astext from new" do
|
64
|
-
|
65
|
-
|
66
|
-
expect(
|
64
|
+
expected_results = subject.type
|
65
|
+
expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation)
|
66
|
+
expect(expected_results.size).to eq 2
|
67
|
+
expect(expected_results).to include RDFVocabularies::OA.Tag
|
68
|
+
expect(expected_results).to include RDFVocabularies::CNT.ContentAsText
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
@@ -88,19 +90,19 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
88
90
|
|
89
91
|
context "when tag value is nil" do
|
90
92
|
it "should throw invalid arguement exception" do
|
91
|
-
expect{ LD4L::OpenAnnotationRDF::TagBody.annotations_using(nil) }.to raise_error
|
93
|
+
expect{ LD4L::OpenAnnotationRDF::TagBody.annotations_using(nil) }.to raise_error(ArgumentError, 'Argument must be a string with at least one character')
|
92
94
|
end
|
93
95
|
end
|
94
96
|
|
95
97
|
context "when tag value is a string of 0 length" do
|
96
98
|
it "should throw invalid arguement exception" do
|
97
|
-
expect{ LD4L::OpenAnnotationRDF::TagBody.annotations_using("") }.to raise_error
|
99
|
+
expect{ LD4L::OpenAnnotationRDF::TagBody.annotations_using("") }.to raise_error(ArgumentError, 'Argument must be a string with at least one character')
|
98
100
|
end
|
99
101
|
end
|
100
102
|
|
101
103
|
context "when tag value is not a string" do
|
102
104
|
it "should throw invalid arguement exception" do
|
103
|
-
expect{ LD4L::OpenAnnotationRDF::TagBody.annotations_using(3) }.to raise_error
|
105
|
+
expect{ LD4L::OpenAnnotationRDF::TagBody.annotations_using(3) }.to raise_error(ArgumentError, 'Argument must be a string with at least one character')
|
104
106
|
end
|
105
107
|
end
|
106
108
|
|
@@ -146,19 +148,19 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
146
148
|
|
147
149
|
context "when new value is nil" do
|
148
150
|
it "should throw invalid arguement exception" do
|
149
|
-
expect{ LD4L::OpenAnnotationRDF::TagBody.fetch_by_tag_value(nil) }.to raise_error
|
151
|
+
expect{ LD4L::OpenAnnotationRDF::TagBody.fetch_by_tag_value(nil) }.to raise_error(ArgumentError, 'Argument must be a string with at least one character')
|
150
152
|
end
|
151
153
|
end
|
152
154
|
|
153
155
|
context "when new value is a string of 0 length" do
|
154
156
|
it "should throw invalid arguement exception" do
|
155
|
-
expect{ LD4L::OpenAnnotationRDF::TagBody.fetch_by_tag_value("") }.to raise_error
|
157
|
+
expect{ LD4L::OpenAnnotationRDF::TagBody.fetch_by_tag_value("") }.to raise_error(ArgumentError, 'Argument must be a string with at least one character')
|
156
158
|
end
|
157
159
|
end
|
158
160
|
|
159
161
|
context "when new value is not a string" do
|
160
162
|
it "should throw invalid arguement exception" do
|
161
|
-
expect{ LD4L::OpenAnnotationRDF::TagBody.fetch_by_tag_value(3) }.to raise_error
|
163
|
+
expect{ LD4L::OpenAnnotationRDF::TagBody.fetch_by_tag_value(3) }.to raise_error(ArgumentError, 'Argument must be a string with at least one character')
|
162
164
|
end
|
163
165
|
end
|
164
166
|
|
@@ -266,14 +268,23 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
266
268
|
context "and the item is not a blank node" do
|
267
269
|
|
268
270
|
subject {LD4L::OpenAnnotationRDF::TagBody.new("123")}
|
271
|
+
let(:result) { subject.persist! }
|
269
272
|
|
270
273
|
before do
|
271
274
|
# Create inmemory repository
|
272
275
|
@repo = RDF::Repository.new
|
273
276
|
allow(subject.class).to receive(:repository).and_return(nil)
|
274
|
-
|
277
|
+
if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
|
278
|
+
allow(subject.persistence_strategy).to receive(:repository).and_return(@repo)
|
279
|
+
else # < ActiveTriples 0.8
|
280
|
+
allow(subject).to receive(:repository).and_return(@repo)
|
281
|
+
end
|
275
282
|
subject.tag = "bla"
|
276
|
-
|
283
|
+
result
|
284
|
+
end
|
285
|
+
|
286
|
+
it "should return true" do
|
287
|
+
expect(result).to eq true
|
277
288
|
end
|
278
289
|
|
279
290
|
it "should persist to the repository" do
|
@@ -331,17 +342,6 @@ describe 'LD4L::OpenAnnotationRDF::TagBody' do
|
|
331
342
|
end
|
332
343
|
end
|
333
344
|
|
334
|
-
describe '#solrize' do
|
335
|
-
it 'should return a label for bnodes' do
|
336
|
-
expect(subject.solrize).to eq subject.rdf_label
|
337
|
-
end
|
338
|
-
|
339
|
-
it 'should return a string of the resource uri' do
|
340
|
-
subject.set_subject! 'http://example.org/moomin'
|
341
|
-
expect(subject.solrize).to eq 'http://example.org/moomin'
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
345
|
describe 'editing the graph' do
|
346
346
|
it 'should write properties when statements are added' do
|
347
347
|
subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::CNT.chars, 'good')
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ld4l-open_annotation_rdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- E. Lynette Rayle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.99.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.99.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: active-triples
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,6 +31,12 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.5'
|
34
|
+
- - "~>"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0.6'
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.8.2
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,20 +44,26 @@ dependencies:
|
|
38
44
|
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
46
|
version: '0.5'
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.6'
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.8.2
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: active_triples-local_name
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
44
56
|
requirements:
|
45
|
-
- - "
|
57
|
+
- - ">="
|
46
58
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0
|
59
|
+
version: '0'
|
48
60
|
type: :runtime
|
49
61
|
prerelease: false
|
50
62
|
version_requirements: !ruby/object:Gem::Requirement
|
51
63
|
requirements:
|
52
|
-
- - "
|
64
|
+
- - ">="
|
53
65
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0
|
66
|
+
version: '0'
|
55
67
|
- !ruby/object:Gem::Dependency
|
56
68
|
name: ld4l-foaf_rdf
|
57
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +92,20 @@ dependencies:
|
|
80
92
|
- - ">="
|
81
93
|
- !ruby/object:Gem::Version
|
82
94
|
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: pry-byebug
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
83
109
|
- !ruby/object:Gem::Dependency
|
84
110
|
name: rdoc
|
85
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,6 +189,7 @@ files:
|
|
163
189
|
- ".coveralls.yml"
|
164
190
|
- ".gitignore"
|
165
191
|
- ".travis.yml"
|
192
|
+
- CHANGES.md
|
166
193
|
- Gemfile
|
167
194
|
- LICENSE.txt
|
168
195
|
- README.md
|
@@ -211,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
238
|
version: '0'
|
212
239
|
requirements: []
|
213
240
|
rubyforge_project:
|
214
|
-
rubygems_version: 2.4.
|
241
|
+
rubygems_version: 2.4.5
|
215
242
|
signing_key:
|
216
243
|
specification_version: 4
|
217
244
|
summary: OpenAnnotation RDF models.
|