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.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -6
  3. data/Gemfile +3 -0
  4. data/README.md +5 -0
  5. data/ld4l-open_annotation_rdf.gemspec +4 -8
  6. data/lib/ld4l/open_annotation_rdf.rb +1 -26
  7. data/lib/ld4l/open_annotation_rdf/annotation.rb +28 -30
  8. data/lib/ld4l/open_annotation_rdf/annotation_generic_body.rb +12 -0
  9. data/lib/ld4l/open_annotation_rdf/comment_annotation.rb +3 -6
  10. data/lib/ld4l/open_annotation_rdf/comment_body.rb +4 -4
  11. data/lib/ld4l/open_annotation_rdf/semantic_tag_annotation.rb +3 -6
  12. data/lib/ld4l/open_annotation_rdf/semantic_tag_body.rb +3 -3
  13. data/lib/ld4l/open_annotation_rdf/tag_annotation.rb +3 -5
  14. data/lib/ld4l/open_annotation_rdf/tag_body.rb +7 -7
  15. data/lib/ld4l/open_annotation_rdf/version.rb +1 -1
  16. data/spec/ld4l/open_annotation_rdf/annotation_spec.rb +79 -70
  17. data/spec/ld4l/open_annotation_rdf/comment_annotation_spec.rb +46 -40
  18. data/spec/ld4l/open_annotation_rdf/comment_body_spec.rb +46 -43
  19. data/spec/ld4l/open_annotation_rdf/configuration_spec.rb +5 -5
  20. data/spec/ld4l/open_annotation_rdf/semantic_tag_annotation_spec.rb +46 -42
  21. data/spec/ld4l/open_annotation_rdf/semantic_tag_body_spec.rb +24 -31
  22. data/spec/ld4l/open_annotation_rdf/tag_annotation_spec.rb +46 -42
  23. data/spec/ld4l/open_annotation_rdf/tag_body_spec.rb +28 -35
  24. data/spec/ld4l/open_annotation_rdf_spec.rb +1 -1
  25. data/spec/spec_helper.rb +1 -2
  26. metadata +13 -69
  27. data/lib/ld4l/open_annotation_rdf/vocab/cnt.rb +0 -6
  28. data/lib/ld4l/open_annotation_rdf/vocab/dctypes.rb +0 -5
  29. data/lib/ld4l/open_annotation_rdf/vocab/oa.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88d80519b6716911be96e530e8d9d749fb164e21
4
- data.tar.gz: e27c7e618cbdc975d45dee93aed8676614380831
3
+ metadata.gz: 4aa0556da41076b2f34c5e42dba07eae18293ab9
4
+ data.tar.gz: 602276cae0e89de7fb57d8c37ba15b9194d678b2
5
5
  SHA512:
6
- metadata.gz: d17c5d27f63bd1ea4de5884cebef473438ff6fb853583ace7b4276b7cceda2bfaa0980546d9119b8fea137530664a23a9ef73408823d694c3a2831eae220f953
7
- data.tar.gz: 6d8cdeaa648f3ff54dd0073add06286309c18b7331f514f62a5a860fee9a95c2833db944a65a17ec96b791ad72c03b4c1d099471f90117721e5218da2bf7c34d
6
+ metadata.gz: 4386b653e3aaa928613de1373228e541bb49d0aaee20681561eb367ec9c85e01a5e23616e1fea7d27f7389320b4f01b575dc4c25e431a92d3e66f0979c0eec62
7
+ data.tar.gz: 6728d645af71a8b61d67a574d413fc2fd2f377060b69bf1f992ed2b0bfe419f880fd4714da1a46c95bff0560a6ffe363906b1cef4ebc8b99c6ad13d7bacaaca0
data/.travis.yml CHANGED
@@ -1,12 +1,16 @@
1
1
  language: ruby
2
2
  bundler_args: --without debug
3
3
  script: "bundle exec rspec spec"
4
+ sudo: false
5
+ cache: bundler
4
6
  rvm:
5
- - 1.9.3
6
- - 2.0.0
7
- - 2.1.0
8
- - 2.1.1
9
- - jruby-19mode
7
+ - 2.1
8
+ - 2.2.2
9
+ - 2.2.4
10
+ - 2.3.1
11
+ - jruby-9.0.4.0
12
+ - rbx
10
13
  matrix:
11
14
  allow_failures:
12
- - rvm: jruby-19mode
15
+ - rvm: jruby-9.0.4.0
16
+ - rvm: rbx
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem 'activesupport', '< 5.0.0' if RUBY_VERSION =~ /2\.1\..*/
6
+ gem 'pry-byebug' unless ENV["CI"]
data/README.md CHANGED
@@ -25,6 +25,11 @@ Or install it yourself as:
25
25
  $ gem install ld4l-open_annotation_rdf
26
26
 
27
27
 
28
+ ## Primary Dependencies
29
+
30
+ * [ActiveTriples 0.10.0](https://github.com/ActiveTriples/ActiveTriples/tree/v0.10.0)
31
+ * [RDF 2.0.2](https://github.com/ruby-rdf/rdf/tree/2.0.2)
32
+
28
33
  ## Usage
29
34
 
30
35
  **Caveat:** This gem is part of the LD4L Project and is being used in that context. There is no guarantee that the
@@ -13,23 +13,19 @@ Gem::Specification.new do |spec|
13
13
  spec.description = %q{LD4L Open Annotation RDF provides tools for modeling a annotations based on the Open Annotation ontology and persisting to a triplestore.}
14
14
  spec.homepage = "https://github.com/ld4l/open_annotation_rdf"
15
15
  spec.license = "APACHE2"
16
- spec.required_ruby_version = '>= 1.9.3'
16
+ spec.required_ruby_version = '>= 2.1'
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
20
 
21
- spec.add_dependency('rdf', '= 1.99.0')
22
-
23
- spec.add_dependency('active-triples', '~> 0.5', '~> 0.6', '~>0.8.2')
21
+ spec.add_dependency('rdf')
22
+ spec.add_dependency('active-triples')
24
23
  spec.add_dependency('active_triples-local_name')
25
- spec.add_dependency('ld4l-foaf_rdf', '~> 0.0')
24
+ spec.add_dependency('ld4l-foaf_rdf')
26
25
 
27
- spec.add_development_dependency('pry')
28
- spec.add_development_dependency('pry-byebug')
29
26
  spec.add_development_dependency('rdoc')
30
27
  spec.add_development_dependency('rspec')
31
28
  spec.add_development_dependency('coveralls')
32
- spec.add_development_dependency('guard-rspec')
33
29
  spec.add_development_dependency('webmock')
34
30
 
35
31
  spec.extra_rdoc_files = [
@@ -4,9 +4,6 @@ require 'active_triples/local_name'
4
4
  require 'linkeddata'
5
5
  require 'ld4l/foaf_rdf'
6
6
  require 'ld4l/open_annotation_rdf/version'
7
- require 'ld4l/open_annotation_rdf/vocab/oa'
8
- require 'ld4l/open_annotation_rdf/vocab/cnt'
9
- require 'ld4l/open_annotation_rdf/vocab/dctypes'
10
7
 
11
8
 
12
9
  module LD4L
@@ -29,38 +26,16 @@ module LD4L
29
26
  yield(configuration)
30
27
  end
31
28
 
32
-
33
- # RDF vocabularies
34
- autoload :OA, 'ld4l/open_annotation_rdf/vocab/oa'
35
- autoload :CNT, 'ld4l/open_annotation_rdf/vocab/cnt'
36
- autoload :DCTYPES, 'ld4l/open_annotation_rdf/vocab/dctypes'
37
-
38
-
39
29
  # autoload classes
40
30
  autoload :Configuration, 'ld4l/open_annotation_rdf/configuration'
41
31
  autoload :Annotation, 'ld4l/open_annotation_rdf/annotation'
32
+ autoload :AnnotationGenericBody, 'ld4l/open_annotation_rdf/annotation_generic_body'
42
33
  autoload :CommentAnnotation, 'ld4l/open_annotation_rdf/comment_annotation'
43
34
  autoload :CommentBody, 'ld4l/open_annotation_rdf/comment_body'
44
35
  autoload :TagAnnotation, 'ld4l/open_annotation_rdf/tag_annotation'
45
36
  autoload :TagBody, 'ld4l/open_annotation_rdf/tag_body'
46
37
  autoload :SemanticTagAnnotation, 'ld4l/open_annotation_rdf/semantic_tag_annotation'
47
38
  autoload :SemanticTagBody, 'ld4l/open_annotation_rdf/semantic_tag_body'
48
-
49
- def self.class_from_string(class_name, container_class=Kernel)
50
- container_class = container_class.name if container_class.is_a? Module
51
- container_parts = container_class.split('::')
52
- (container_parts + class_name.split('::')).flatten.inject(Kernel) do |mod, class_name|
53
- if mod == Kernel
54
- Object.const_get(class_name)
55
- elsif mod.const_defined? class_name.to_sym
56
- mod.const_get(class_name)
57
- else
58
- container_parts.pop
59
- class_from_string(class_name, container_parts.join('::'))
60
- end
61
- end
62
- end
63
-
64
39
  end
65
40
  end
66
41
 
@@ -7,45 +7,30 @@ module LD4L
7
7
 
8
8
  @body = nil
9
9
 
10
- configure :type => RDFVocabularies::OA.Annotation,
10
+ configure :type => RDF::Vocab::OA.Annotation,
11
11
  :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri,
12
12
  :repository => :default
13
13
 
14
- property :hasTarget, :predicate => RDFVocabularies::OA.hasTarget # :type => URI
15
- property :hasBody, :predicate => RDFVocabularies::OA.hasBody
16
- property :annotatedBy, :predicate => RDFVocabularies::OA.annotatedBy, :class_name => LD4L::FoafRDF::Person
17
- property :annotatedAt, :predicate => RDFVocabularies::OA.annotatedAt, :cast => false # :type => xsd:dateTime # the time Annotation was created
18
- property :motivatedBy, :predicate => RDFVocabularies::OA.motivatedBy, :cast => false # comes from RDFVocabularies::OA ontology
14
+ property :hasTarget, :predicate => RDF::Vocab::OA.hasTarget # :type => URI
15
+ property :hasBody, :predicate => RDF::Vocab::OA.hasBody
16
+ property :annotatedBy, :predicate => RDF::Vocab::OA.annotatedBy, :class_name => LD4L::FoafRDF::Person
17
+ property :annotatedAt, :predicate => RDF::Vocab::OA.annotatedAt, :cast => false # :type => xsd:dateTime # the time Annotation was created
18
+ property :motivatedBy, :predicate => RDF::Vocab::OA.motivatedBy, :cast => false # comes from RDF::Vocab::OA ontology
19
19
 
20
20
  def self.resume(uri_or_str)
21
21
  # Let ActiveTriples::Resource validate uri_or_str when creating new Annotation
22
22
  a = new(uri_or_str)
23
+ return nil if a.nil?
23
24
 
24
- # get motivatedBy
25
- m = a.get_values(:motivatedBy)
26
- m = m.to_a if Object.const_defined?("ActiveTriples::Relation") && m.kind_of?(ActiveTriples::Relation)
27
-
28
- # TODO: Should m's class be validated? I've seen it be RDF::Vocabulary::Term and RDF::URI. For now, removing the validation.
29
- return a unless m.kind_of?(Array) && m.size > 0
30
- # return a unless m.kind_of?(Array) && m.size > 0 && (m.first.kind_of?(RDF::Vocabulary::Term) || m.first.kind_of?(RDF::URI)
31
-
32
- # motivatedBy is set
33
- m_uri = m.first
34
25
  # currently only support commenting and tagging
35
- return LD4L::OpenAnnotationRDF::CommentAnnotation.new(uri_or_str) if m_uri == RDFVocabularies::OA.commenting
36
- return a unless m_uri == RDFVocabularies::OA.tagging
26
+ m = motivated_by a
27
+ return LD4L::OpenAnnotationRDF::CommentAnnotation.new(uri_or_str) if m.include? RDF::Vocab::OA.commenting
37
28
 
38
29
  # Tagging can be TagAnnotation or SemanticTagAnnotation. Only way to tell is by checking type of body.
39
- sta = LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new(uri_or_str)
40
- stb = sta.getBody
41
- return sta unless stb.type.include?(RDFVocabularies::OA.Tag) || !stb.type.include?(RDFVocabularies::OA.SemanticTag)
42
-
43
- ta = LD4L::OpenAnnotationRDF::TagAnnotation.new(uri_or_str)
44
- tb = ta.getBody
45
- return ta if tb.type.include?(RDFVocabularies::OA.Tag)
46
-
47
- # can't match to a known annotation type, so return as generic annotation
48
- return a
30
+ return a unless m.include? RDF::Vocab::OA.tagging
31
+ b = body_resource a
32
+ return LD4L::OpenAnnotationRDF::TagAnnotation.new(uri_or_str) if b.type.include? RDF::Vocab::OA.Tag
33
+ LD4L::OpenAnnotationRDF::SemanticTagAnnotation.new(uri_or_str)
49
34
  end
50
35
 
51
36
  ##
@@ -98,8 +83,8 @@ module LD4L
98
83
  repo = ActiveTriples::Repositories.repositories[repository]
99
84
  query = RDF::Query.new({
100
85
  :annotation => {
101
- RDF.type => RDFVocabularies::OA.Annotation,
102
- RDFVocabularies::OA.hasTarget => target_uri,
86
+ RDF.type => RDF::Vocab::OA.Annotation,
87
+ RDF::Vocab::OA.hasTarget => target_uri,
103
88
  }
104
89
  })
105
90
  annotations = []
@@ -107,6 +92,19 @@ module LD4L
107
92
  results.each { |r| annotations << r.to_hash[:annotation] }
108
93
  annotations
109
94
  end
95
+
96
+ private
97
+ def self::motivated_by annotation
98
+ m = annotation.get_values(:motivatedBy).to_a
99
+ return nil unless m.kind_of?(Array) && (m.size > 0)
100
+ m
101
+ end
102
+
103
+ def self::body_resource annotation
104
+ body_uris = annotation.hasBody
105
+ return nil if body_uris.nil? || body_uris.size < 1
106
+ AnnotationGenericBody.new(body_uris.first) # TODO: a full implementation of OA could have multiple bodies
107
+ end
110
108
  end
111
109
  end
112
110
  end
@@ -0,0 +1,12 @@
1
+ module LD4L
2
+ module OpenAnnotationRDF
3
+ class AnnotationGenericBody < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="a"
7
+
8
+ configure :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri,
9
+ :repository => :default
10
+ end
11
+ end
12
+ end
@@ -4,13 +4,10 @@ module LD4L
4
4
 
5
5
  @localname_prefix="ca"
6
6
 
7
- configure :type => RDFVocabularies::OA.Annotation,
7
+ configure :type => RDF::Vocab::OA.Annotation,
8
8
  :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri,
9
9
  :repository => :default
10
10
 
11
- property :hasBody, :predicate => RDFVocabularies::OA.hasBody, :class_name => LD4L::OpenAnnotationRDF::CommentBody
12
-
13
-
14
11
  ##
15
12
  # Create a comment annotation body and set the hasBody property to it.
16
13
  #
@@ -53,8 +50,8 @@ module LD4L
53
50
 
54
51
  # set motivatedBy
55
52
  m = get_values(:motivatedBy)
56
- m = m.to_a if Object.const_defined?("ActiveTriples::Relation") && m.kind_of?(ActiveTriples::Relation)
57
- set_value(:motivatedBy, RDFVocabularies::OA.commenting) unless m.kind_of?(Array) && m.size > 0
53
+ m = m.to_a if Object::ActiveTriples.const_defined?("Relation") && m.kind_of?(ActiveTriples::Relation)
54
+ set_value(:motivatedBy, RDF::Vocab::OA.commenting) unless m.kind_of?(Array) && m.size > 0
58
55
 
59
56
  # resume CommentBody if it exists
60
57
  comment_uri = get_values(:hasBody).first
@@ -5,18 +5,18 @@ module LD4L
5
5
  class << self; attr_reader :localname_prefix end
6
6
  @localname_prefix="cb"
7
7
 
8
- configure :type => RDFVocabularies::CNT.ContentAsText,
8
+ configure :type => RDF::Vocab::CNT.ContentAsText,
9
9
  :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri,
10
10
  :repository => :default
11
11
 
12
- property :content, :predicate => RDFVocabularies::CNT.chars, :cast => false # :type => XSD.string
13
- property :format, :predicate => RDF::DC.format, :cast => false # :type => XSD.string
12
+ property :content, :predicate => RDF::Vocab::CNT.chars, :cast => false # :type => XSD.string
13
+ property :format, :predicate => RDF::Vocab::DC.format, :cast => false # :type => XSD.string
14
14
 
15
15
  def initialize(*args)
16
16
  super(*args)
17
17
 
18
18
  t = get_values(:type)
19
- t << RDFVocabularies::DCTYPES.Text
19
+ t << RDF::Vocab::DCMIType.Text
20
20
  set_value(:type,t)
21
21
  end
22
22
  end
@@ -4,13 +4,10 @@ module LD4L
4
4
 
5
5
  @localname_prefix = "sta"
6
6
 
7
- configure :type => RDFVocabularies::OA.Annotation,
7
+ configure :type => RDF::Vocab::OA.Annotation,
8
8
  :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri,
9
9
  :repository => :default
10
10
 
11
- property :hasBody, :predicate => RDFVocabularies::OA.hasBody, :class_name => LD4L::OpenAnnotationRDF::SemanticTagBody
12
-
13
-
14
11
  # USAGE: Use setTerm to set the hasBody property to be the URI of the controlled vocabulary term that
15
12
  # is the annotation.
16
13
 
@@ -59,8 +56,8 @@ module LD4L
59
56
 
60
57
  # set motivatedBy
61
58
  m = get_values(:motivatedBy)
62
- m = m.to_a if Object.const_defined?("ActiveTriples::Relation") && m.kind_of?(ActiveTriples::Relation)
63
- set_value(:motivatedBy, RDFVocabularies::OA.tagging) unless m.kind_of?(Array) && m.size > 0
59
+ m = m.to_a if Object::ActiveTriples.const_defined?("Relation") && m.kind_of?(ActiveTriples::Relation)
60
+ set_value(:motivatedBy, RDF::Vocab::OA.tagging) unless m.kind_of?(Array) && m.size > 0
64
61
 
65
62
  # resume SemanticTagBody if it exists
66
63
  term_uri = get_values(:hasBody).first
@@ -8,7 +8,7 @@ module LD4L
8
8
  # USAGE: When creating a semantic tag body, use the URI of the controlled vocabulary term as the RDF Subject URI
9
9
  # for an instance of this class.
10
10
 
11
- configure :type => RDFVocabularies::OA.SemanticTag,
11
+ configure :type => RDF::Vocab::OA.SemanticTag,
12
12
  :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri,
13
13
  :repository => :default
14
14
 
@@ -30,8 +30,8 @@ module LD4L
30
30
  repo = ActiveTriples::Repositories.repositories[repository]
31
31
  query = RDF::Query.new({
32
32
  :annotation => {
33
- RDF.type => RDFVocabularies::OA.Annotation,
34
- RDFVocabularies::OA.hasBody => term_uri,
33
+ RDF.type => RDF::Vocab::OA.Annotation,
34
+ RDF::Vocab::OA.hasBody => term_uri,
35
35
  }
36
36
  })
37
37
  annotations = []
@@ -4,12 +4,10 @@ module LD4L
4
4
 
5
5
  @localname_prefix="ta"
6
6
 
7
- configure :type => RDFVocabularies::OA.Annotation,
7
+ configure :type => RDF::Vocab::OA.Annotation,
8
8
  :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri,
9
9
  :repository => :default
10
10
 
11
- property :hasBody, :predicate => RDFVocabularies::OA.hasBody, :class_name => LD4L::OpenAnnotationRDF::TagBody
12
-
13
11
  # TODO: Should a tag be destroyed when the last annotation referencing the tag is destroyed?
14
12
 
15
13
  ##
@@ -102,8 +100,8 @@ module LD4L
102
100
 
103
101
  # set motivatedBy
104
102
  m = get_values(:motivatedBy)
105
- m = m.to_a if Object.const_defined?("ActiveTriples::Relation") && m.kind_of?(ActiveTriples::Relation)
106
- set_value(:motivatedBy, RDFVocabularies::OA.tagging) unless m.kind_of?(Array) && m.size > 0
103
+ m = m.to_a if Object::ActiveTriples.const_defined?("Relation") && m.kind_of?(ActiveTriples::Relation)
104
+ set_value(:motivatedBy, RDF::Vocab::OA.tagging) unless m.kind_of?(Array) && m.size > 0
107
105
 
108
106
  # resume TagBody if it exists
109
107
  tag_uri = get_values(:hasBody).first
@@ -5,11 +5,11 @@ module LD4L
5
5
  class << self; attr_reader :localname_prefix end
6
6
  @localname_prefix="tb"
7
7
 
8
- configure :type => RDFVocabularies::OA.Tag,
8
+ configure :type => RDF::Vocab::OA.Tag,
9
9
  :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri,
10
10
  :repository => :default
11
11
 
12
- property :tag, :predicate => RDFVocabularies::CNT.chars, :cast => false # :type => XSD.string
12
+ property :tag, :predicate => RDF::Vocab::CNT.chars, :cast => false # :type => XSD.string
13
13
 
14
14
  ##
15
15
  # Get a list of annotations using the tag value.
@@ -31,8 +31,8 @@ module LD4L
31
31
  repo = ActiveTriples::Repositories.repositories[repository]
32
32
  query = RDF::Query.new({
33
33
  :annotation => {
34
- RDF.type => RDFVocabularies::OA.Annotation,
35
- RDFVocabularies::OA.hasBody => tag_uri,
34
+ RDF.type => RDF::Vocab::OA.Annotation,
35
+ RDF::Vocab::OA.hasBody => tag_uri,
36
36
  }
37
37
  })
38
38
  results = query.execute(repo)
@@ -57,8 +57,8 @@ module LD4L
57
57
  repo = ActiveTriples::Repositories.repositories[repository]
58
58
  query = RDF::Query.new({
59
59
  :tagbody => {
60
- RDF.type => RDFVocabularies::OA.Tag,
61
- RDFVocabularies::CNT.chars => tag_value,
60
+ RDF.type => RDF::Vocab::OA.Tag,
61
+ RDF::Vocab::CNT.chars => tag_value,
62
62
  }
63
63
  })
64
64
 
@@ -76,7 +76,7 @@ module LD4L
76
76
  super(*args)
77
77
 
78
78
  t = get_values(:type)
79
- t << RDFVocabularies::CNT.ContentAsText
79
+ t << RDF::Vocab::CNT.ContentAsText
80
80
  set_value(:type,t)
81
81
  end
82
82
  end
@@ -1,5 +1,5 @@
1
1
  module LD4L
2
2
  module OpenAnnotationRDF
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -2,6 +2,10 @@ require 'spec_helper'
2
2
 
3
3
  describe 'LD4L::OpenAnnotationRDF::Annotation' do
4
4
 
5
+ after do
6
+ ActiveTriples::Repositories.repositories[LD4L::OpenAnnotationRDF::CommentAnnotation.repository].clear!
7
+ end
8
+
5
9
  subject { LD4L::OpenAnnotationRDF::Annotation.new }
6
10
 
7
11
  describe 'rdf_subject' do
@@ -21,9 +25,9 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' 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
 
@@ -33,15 +37,15 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
33
37
  end
34
38
 
35
39
  it 'should update graph subjects' do
36
- expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland')))).to be true
40
+ expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland')))).to be true
37
41
  end
38
42
 
39
43
  it 'should update graph objects' do
40
- expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject))).to be true
44
+ expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject))).to be true
41
45
  end
42
46
 
43
47
  it 'should leave other uris alone' do
44
- 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
48
+ 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
45
49
  end
46
50
  end
47
51
 
@@ -62,8 +66,8 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
62
66
  # -------------------------------------------------
63
67
 
64
68
  describe 'type' do
65
- it "should be an RDFVocabularies::OA.Annotation" do
66
- expect(subject.type.first.value).to eq RDFVocabularies::OA.Annotation.value
69
+ it "should be an RDF::Vocab::OA.Annotation" do
70
+ expect(subject.type.first.value).to eq RDF::Vocab::OA.Annotation.value
67
71
  end
68
72
  end
69
73
 
@@ -150,14 +154,14 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
150
154
  end
151
155
 
152
156
  it "should be settable" do
153
- subject.motivatedBy = RDFVocabularies::OA.describing
154
- expect(subject.motivatedBy.first).to eq RDFVocabularies::OA.describing
157
+ subject.motivatedBy = RDF::Vocab::OA.describing
158
+ expect(subject.motivatedBy.first).to eq RDF::Vocab::OA.describing
155
159
  end
156
160
 
157
161
  it "should be changeable" do
158
- subject.motivatedBy = RDFVocabularies::OA.describing
159
- subject.motivatedBy = RDFVocabularies::OA.classifying
160
- expect(subject.motivatedBy.first).to eq RDFVocabularies::OA.classifying
162
+ subject.motivatedBy = RDF::Vocab::OA.describing
163
+ subject.motivatedBy = RDF::Vocab::OA.classifying
164
+ expect(subject.motivatedBy.first).to eq RDF::Vocab::OA.classifying
161
165
  end
162
166
  end
163
167
 
@@ -190,12 +194,12 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
190
194
  expect(a.hasTarget.first.rdf_subject.to_s).to eq "http://example.org/bibref/br3"
191
195
  expect(a.annotatedBy.first).to eq a_person
192
196
  expect(a.annotatedAt.first).to eq a_time
193
- expect(a.motivatedBy.first).to eq RDFVocabularies::OA.commenting
197
+ expect(a.motivatedBy.first).to eq RDF::Vocab::OA.commenting
194
198
 
195
199
  b = a.getBody
196
200
  expect(b).to be_a_kind_of(LD4L::OpenAnnotationRDF::CommentBody)
197
- expect(b.type).to include RDFVocabularies::DCTYPES.Text
198
- expect(b.type).to include RDFVocabularies::CNT.ContentAsText
201
+ expect(b.type).to include RDF::Vocab::DCMIType.Text
202
+ expect(b.type).to include RDF::Vocab::CNT.ContentAsText
199
203
  expect(b.content).to eq ["This is a comment."]
200
204
  expect(b.format.first).to eq "text/plain"
201
205
  end
@@ -216,12 +220,12 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
216
220
  expect(a.hasTarget.first.rdf_subject.to_s).to eq "http://example.org/bibref/br3"
217
221
  expect(a.annotatedBy.first).to eq a_person
218
222
  expect(a.annotatedAt.first).to eq a_time
219
- expect(a.motivatedBy.first).to eq RDFVocabularies::OA.tagging
223
+ expect(a.motivatedBy.first).to eq RDF::Vocab::OA.tagging
220
224
 
221
225
  b = a.getBody
222
226
  expect(b).to be_a_kind_of(LD4L::OpenAnnotationRDF::TagBody)
223
- expect(b.type).to include RDFVocabularies::OA.Tag
224
- expect(b.type).to include RDFVocabularies::CNT.ContentAsText
227
+ expect(b.type).to include RDF::Vocab::OA.Tag
228
+ expect(b.type).to include RDF::Vocab::CNT.ContentAsText
225
229
  expect(b.tag).to eq ["good"]
226
230
  end
227
231
 
@@ -241,11 +245,11 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
241
245
  expect(a.hasTarget.first.rdf_subject.to_s).to eq "http://example.org/bibref/br3"
242
246
  expect(a.annotatedBy.first).to eq a_person
243
247
  expect(a.annotatedAt.first).to eq a_time
244
- expect(a.motivatedBy.first).to eq RDFVocabularies::OA.tagging
248
+ expect(a.motivatedBy.first).to eq RDF::Vocab::OA.tagging
245
249
 
246
250
  b = a.getBody
247
251
  expect(b).to be_a_kind_of(LD4L::OpenAnnotationRDF::SemanticTagBody)
248
- expect(b.type).to include RDFVocabularies::OA.SemanticTag
252
+ expect(b.type).to include RDF::Vocab::OA.SemanticTag
249
253
  expect(b.rdf_subject.to_s).to eq('http://example.org/term/3')
250
254
  end
251
255
  end
@@ -274,12 +278,12 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
274
278
  expect(a.hasTarget.first.rdf_subject.to_s).to eq "http://example.org/bibref/br3"
275
279
  expect(a.annotatedBy.first).to eq a_person
276
280
  expect(a.annotatedAt.first).to eq a_time
277
- expect(a.motivatedBy.first).to eq RDFVocabularies::OA.commenting
281
+ expect(a.motivatedBy.first).to eq RDF::Vocab::OA.commenting
278
282
 
279
283
  b = a.getBody
280
284
  expect(b).to be_a_kind_of(LD4L::OpenAnnotationRDF::CommentBody)
281
- expect(b.type).to include RDFVocabularies::DCTYPES.Text
282
- expect(b.type).to include RDFVocabularies::CNT.ContentAsText
285
+ expect(b.type).to include RDF::Vocab::DCMIType.Text
286
+ expect(b.type).to include RDF::Vocab::CNT.ContentAsText
283
287
  expect(b.content).to eq ["BLANK NODE COMMENT"]
284
288
  expect(b.format.first).to eq "text/plain"
285
289
  end
@@ -306,12 +310,12 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
306
310
  expect(a.hasTarget.first.rdf_subject.to_s).to eq "http://example.org/bibref/br3"
307
311
  expect(a.annotatedBy.first).to eq a_person
308
312
  expect(a.annotatedAt.first).to eq a_time
309
- expect(a.motivatedBy.first).to eq RDFVocabularies::OA.tagging
313
+ expect(a.motivatedBy.first).to eq RDF::Vocab::OA.tagging
310
314
 
311
315
  b = a.getBody
312
316
  expect(b).to be_a_kind_of(LD4L::OpenAnnotationRDF::TagBody)
313
- expect(b.type).to include RDFVocabularies::OA.Tag
314
- expect(b.type).to include RDFVocabularies::CNT.ContentAsText
317
+ expect(b.type).to include RDF::Vocab::OA.Tag
318
+ expect(b.type).to include RDF::Vocab::CNT.ContentAsText
315
319
  expect(b.tag).to eq ["BLANK_NODE_TAG"]
316
320
  end
317
321
 
@@ -337,11 +341,11 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
337
341
  expect(a.hasTarget.first.rdf_subject.to_s).to eq "http://example.org/bibref/br3"
338
342
  expect(a.annotatedBy.first).to eq a_person
339
343
  expect(a.annotatedAt.first).to eq a_time
340
- expect(a.motivatedBy.first).to eq RDFVocabularies::OA.tagging
344
+ expect(a.motivatedBy.first).to eq RDF::Vocab::OA.tagging
341
345
 
342
346
  b = a.getBody
343
347
  expect(b).to be_a_kind_of(LD4L::OpenAnnotationRDF::SemanticTagBody)
344
- expect(b.type).to include RDFVocabularies::OA.SemanticTag
348
+ expect(b.type).to include RDF::Vocab::OA.SemanticTag
345
349
  expect(b.rdf_subject.to_s).to eq('http://example.org/term/3')
346
350
  end
347
351
  end
@@ -371,16 +375,17 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
371
375
  it "populates LD4L::OpenAnnotationRDF::CommentAnnotation properly" do
372
376
  expect(@comment_anno.rdf_subject.to_s).to eq @anno_url
373
377
  expect(@comment_anno).to be_a LD4L::OpenAnnotationRDF::CommentAnnotation
374
- expect(@comment_anno.type).to include(RDFVocabularies::OA.Annotation)
375
- expect(@comment_anno.motivatedBy).to include(RDFVocabularies::OA.commenting)
378
+ expect(@comment_anno.type).to include(RDF::Vocab::OA.Annotation)
379
+ expect(@comment_anno.motivatedBy).to include(RDF::Vocab::OA.commenting)
376
380
  expect(@comment_anno.hasTarget.first.rdf_subject).to eq RDF::URI.new("http://searchworks.stanford.edu/view/666")
377
381
  end
378
382
  it "populates Comment bodies properly" do
379
- body = @comment_anno.hasBody.first
383
+ # body = @comment_anno.hasBody.first
384
+ body = @comment_anno.getBody
380
385
  expect(body).to be_a LD4L::OpenAnnotationRDF::CommentBody
381
386
  expect(body.content.first).to eq @comment_value
382
- expect(body.type).to include(RDFVocabularies::CNT.ContentAsText)
383
- expect(body.type).to include(RDFVocabularies::DCTYPES.Text)
387
+ expect(body.type).to include(RDF::Vocab::CNT.ContentAsText)
388
+ expect(body.type).to include(RDF::Vocab::DCMIType.Text)
384
389
  end
385
390
  end
386
391
 
@@ -408,17 +413,18 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
408
413
  it "populates LD4L::OpenAnnotationRDF::TagAnnotation properly" do
409
414
  expect(@tag_anno.rdf_subject.to_s).to eq @anno_url
410
415
  expect(@tag_anno).to be_a LD4L::OpenAnnotationRDF::TagAnnotation
411
- expect(@tag_anno.type).to include(RDFVocabularies::OA.Annotation)
412
- expect(@tag_anno.motivatedBy).to include(RDFVocabularies::OA.tagging)
416
+ expect(@tag_anno.type).to include(RDF::Vocab::OA.Annotation)
417
+ expect(@tag_anno.motivatedBy).to include(RDF::Vocab::OA.tagging)
413
418
  expect(@tag_anno.hasTarget.first.rdf_subject).to eq RDF::URI.new("http://searchworks.stanford.edu/view/666")
414
419
  end
415
420
  it "populates Tag bodies properly" do
416
- body = @tag_anno.hasBody.first
421
+ # body = @tag_anno.hasBody.first
422
+ body = @tag_anno.getBody
417
423
  expect(body).to be_a LD4L::OpenAnnotationRDF::TagBody
418
424
  expect(body.tag.first).to eq @tag_value
419
- expect(body.type).to include(RDFVocabularies::OA.Tag)
420
- expect(body.type).to include(RDFVocabularies::CNT.ContentAsText)
421
- expect(body.type).to include(RDFVocabularies::DCTYPES.Text)
425
+ expect(body.type).to include(RDF::Vocab::OA.Tag)
426
+ expect(body.type).to include(RDF::Vocab::CNT.ContentAsText)
427
+ expect(body.type).to include(RDF::Vocab::DCMIType.Text)
422
428
  end
423
429
  end
424
430
 
@@ -440,15 +446,16 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
440
446
  it "populates LD4L::OpenAnnotationRDF::TagAnnotation properly" do
441
447
  expect(@semantic_tag_anno.rdf_subject.to_s).to eq @anno_url
442
448
  expect(@semantic_tag_anno).to be_a LD4L::OpenAnnotationRDF::SemanticTagAnnotation
443
- expect(@semantic_tag_anno.type).to include(RDFVocabularies::OA.Annotation)
444
- expect(@semantic_tag_anno.motivatedBy).to include(RDFVocabularies::OA.tagging)
449
+ expect(@semantic_tag_anno.type).to include(RDF::Vocab::OA.Annotation)
450
+ expect(@semantic_tag_anno.motivatedBy).to include(RDF::Vocab::OA.tagging)
445
451
  expect(@semantic_tag_anno.hasTarget.first.rdf_subject).to eq RDF::URI.new("http://searchworks.stanford.edu/view/666")
446
452
  end
447
453
  it "populates Tag bodies properly" do
448
- body = @semantic_tag_anno.hasBody.first
454
+ # body = @semantic_tag_anno.hasBody.first
455
+ body = @semantic_tag_anno.getBody
449
456
  expect(body.rdf_subject.to_s).to eq @term_url
450
457
  expect(body).to be_a LD4L::OpenAnnotationRDF::SemanticTagBody
451
- expect(body.type).to include(RDFVocabularies::OA.SemanticTag)
458
+ expect(body.type).to include(RDF::Vocab::OA.SemanticTag)
452
459
  end
453
460
  end
454
461
  end
@@ -476,7 +483,7 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
476
483
 
477
484
  context "when it is saved" do
478
485
  before do
479
- subject.motivatedBy = RDFVocabularies::OA.commenting
486
+ subject.motivatedBy = RDF::Vocab::OA.commenting
480
487
  subject.persist!
481
488
  end
482
489
 
@@ -486,7 +493,7 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
486
493
 
487
494
  context "and then modified" do
488
495
  before do
489
- subject.motivatedBy = RDFVocabularies::OA.tagging
496
+ subject.motivatedBy = RDF::Vocab::OA.tagging
490
497
  end
491
498
 
492
499
  it "should return true" do
@@ -499,7 +506,7 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
499
506
  end
500
507
 
501
508
  it "should reset the motivatedBy" do
502
- expect(subject.motivatedBy.first.to_s).to eq RDFVocabularies::OA.commenting.to_s
509
+ expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.commenting.to_s
503
510
  end
504
511
 
505
512
  it "should be persisted" do
@@ -521,7 +528,7 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
521
528
  # Create inmemory repository
522
529
  @repo = RDF::Repository.new
523
530
  ActiveTriples::Repositories.repositories[:default] = @repo
524
- subject.motivatedBy = RDFVocabularies::OA.commenting
531
+ subject.motivatedBy = RDF::Vocab::OA.commenting
525
532
  result
526
533
  end
527
534
 
@@ -535,7 +542,7 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
535
542
 
536
543
  it "should delete from the repository" do
537
544
  subject.reload
538
- expect(subject.motivatedBy.first.to_s).to eq RDFVocabularies::OA.commenting.to_s
545
+ expect(subject.motivatedBy.first.to_s).to eq RDF::Vocab::OA.commenting.to_s
539
546
  subject.motivatedBy = []
540
547
  expect(subject.motivatedBy).to eq []
541
548
  subject.persist!
@@ -549,7 +556,7 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
549
556
 
550
557
  describe '#destroy!' do
551
558
  before do
552
- subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
559
+ subject << RDF::Statement(RDF::Vocab::DC.LicenseDocument, RDF::Vocab::DC.title, 'LICENSE')
553
560
  end
554
561
 
555
562
  subject { LD4L::OpenAnnotationRDF::Annotation.new('123') }
@@ -615,11 +622,11 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
615
622
 
616
623
  context 'with unmodeled data' do
617
624
  before do
618
- subject << RDF::Statement(subject.rdf_subject, RDF::DC.contributor, 'Tove Jansson')
619
- subject << RDF::Statement(subject.rdf_subject, RDF::DC.relation, RDF::URI('http://example.org/moomi'))
625
+ subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.contributor, 'Tove Jansson')
626
+ subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.relation, RDF::URI('http://example.org/moomi'))
620
627
  node = RDF::Node.new
621
- subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::DC.relation, node)
622
- subject << RDF::Statement(node, RDF::DC.title, 'bnode')
628
+ subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::Vocab::DC.relation, node)
629
+ subject << RDF::Statement(node, RDF::Vocab::DC.title, 'bnode')
623
630
  end
624
631
 
625
632
  after do
@@ -628,21 +635,21 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
628
635
  end
629
636
 
630
637
  it 'should include data with URIs as attribute names' do
631
- expect(subject.attributes[RDF::DC.contributor.to_s]).to eq ['Tove Jansson']
638
+ expect(subject.attributes[RDF::Vocab::DC.contributor.to_s]).to eq ['Tove Jansson']
632
639
  end
633
640
 
634
641
  it 'should return generic Resources' do
635
- expect(subject.attributes[RDF::DC.relation.to_s].first).to be_a ActiveTriples::Resource
642
+ expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first).to be_a ActiveTriples::Resource
636
643
  end
637
644
 
638
645
  it 'should build deep data for Resources' do
639
- expect(subject.attributes[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation).
640
- first.get_values(RDF::DC.title)).to eq ['bnode']
646
+ expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation).
647
+ first.get_values(RDF::Vocab::DC.title)).to eq ['bnode']
641
648
  end
642
649
 
643
650
  it 'should include deep data in serializable_hash' do
644
- expect(subject.serializable_hash[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation).
645
- first.get_values(RDF::DC.title)).to eq ['bnode']
651
+ expect(subject.serializable_hash[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation).
652
+ first.get_values(RDF::Vocab::DC.title)).to eq ['bnode']
646
653
  end
647
654
  end
648
655
 
@@ -719,13 +726,13 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
719
726
 
720
727
  describe 'editing the graph' do
721
728
  it 'should write properties when statements are added' do
722
- subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::OA.motivatedBy, 'commenting')
729
+ subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::OA.motivatedBy, 'commenting')
723
730
  expect(subject.motivatedBy).to include 'commenting'
724
731
  end
725
732
 
726
733
  it 'should delete properties when statements are removed' do
727
- subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::OA.motivatedBy, 'commenting')
728
- subject.delete RDF::Statement.new(subject.rdf_subject, RDFVocabularies::OA.motivatedBy, 'commenting')
734
+ subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::OA.motivatedBy, 'commenting')
735
+ subject.delete RDF::Statement.new(subject.rdf_subject, RDF::Vocab::OA.motivatedBy, 'commenting')
729
736
  expect(subject.motivatedBy).to eq []
730
737
  end
731
738
  end
@@ -734,18 +741,18 @@ describe 'LD4L::OpenAnnotationRDF::Annotation' do
734
741
  before do
735
742
  class DummyPerson < ActiveTriples::Resource
736
743
  configure :type => RDF::URI('http://example.org/Person')
737
- property :foafname, :predicate => RDF::FOAF.name
738
- property :publications, :predicate => RDF::FOAF.publications, :class_name => 'DummyDocument'
739
- property :knows, :predicate => RDF::FOAF.knows, :class_name => DummyPerson
744
+ property :foafname, :predicate => RDF::Vocab::FOAF.name
745
+ property :publications, :predicate => RDF::Vocab::FOAF.publications, :class_name => 'DummyDocument'
746
+ property :knows, :predicate => RDF::Vocab::FOAF.knows, :class_name => DummyPerson
740
747
  end
741
748
 
742
749
  class DummyDocument < ActiveTriples::Resource
743
750
  configure :type => RDF::URI('http://example.org/Document')
744
- property :title, :predicate => RDF::DC.title
745
- property :creator, :predicate => RDF::DC.creator, :class_name => 'DummyPerson'
751
+ property :title, :predicate => RDF::Vocab::DC.title
752
+ property :creator, :predicate => RDF::Vocab::DC.creator, :class_name => 'DummyPerson'
746
753
  end
747
754
 
748
- LD4L::OpenAnnotationRDF::Annotation.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument
755
+ LD4L::OpenAnnotationRDF::Annotation.property :item, :predicate => RDF::Vocab::DC.relation, :class_name => DummyDocument
749
756
  end
750
757
 
751
758
  subject { LD4L::OpenAnnotationRDF::Annotation.new }
@@ -800,8 +807,10 @@ END
800
807
  document1.creator = [person1, person2]
801
808
  document2.creator = person1
802
809
  person1.knows = person2
810
+ person2.knows = person1
803
811
  subject.item = [document1]
804
- expect(subject.item.first.creator.first.knows.first.foafname).to eq ['Bob']
812
+ expect(subject.item.first.creator.first.knows.first.foafname)
813
+ .to satisfy { |names| ['Alice', 'Bob'].include? names.first }
805
814
  end
806
815
  end
807
816
  end