active_annotations 0.2.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 52ae7a0a34d21abfc1295d7a5311ed47a6482369
4
- data.tar.gz: 4656eff871f1a2e24b3ebf9088565ab24e6c7b06
2
+ SHA256:
3
+ metadata.gz: 184151d6e940971dc9fcf814c85ee9c96af6b494f21f709922d896dc9e37b5eb
4
+ data.tar.gz: 99ac263b086301ba4c92b8f7eb2e0cec1aa5b68ea12881ca23a191ecd99b5762
5
5
  SHA512:
6
- metadata.gz: 3940874d99c750eab2c7831c5c28c6704afb2ace6eb97ed1ad8204520e3616ab26da0bae6e8c7a37fcc58cbe1244f7190b274155c00a3e09f92f980417fa5ac7
7
- data.tar.gz: 86368778105c204ca48fb0b99c84c65cad01e45587630b12b738f59b7269f516ac5f467b642fc6bf9ea9a1ad2d13798273cd9671fb97fbf093b07b67eaf5c787
6
+ metadata.gz: 4ec95f754d4b8a9f8a42bf520a02e186e19a8863480c21060aa68b9f039365289efaa91ffb099a421e79f4fda0b2300726ae25a506f3785f285ff9876c1b99ed
7
+ data.tar.gz: ec8b26dd0766c3184e001a045427f842c3deca5ee05e84a6227d76bd05424f856c119e3603132b19a38c77c900e04e1cdf65cb5629038e7a1dbe258b2e5d0df3
@@ -0,0 +1,66 @@
1
+ version: 2.1
2
+ orbs:
3
+ samvera: samvera/circleci-orb@1.0.0
4
+ jobs:
5
+ bundle_lint_test:
6
+ parameters:
7
+ ruby_version:
8
+ type: string
9
+ bundler_version:
10
+ type: string
11
+ default: 2.0.1
12
+ rails_version:
13
+ type: string
14
+ executor:
15
+ name: 'samvera/ruby'
16
+ ruby_version: << parameters.ruby_version >>
17
+ environment:
18
+ RAILS_VERSION: << parameters.rails_version >>
19
+ steps:
20
+ - samvera/cached_checkout
21
+ - run:
22
+ name: Check for 'master' branch
23
+ command: |
24
+ git fetch --all --quiet --prune --prune-tags
25
+ if [[ -n "$(git branch --all --list master */master)" ]]; then
26
+ echo "A branch named 'master' was found. Please remove it."
27
+ echo "$(git branch --all --list master */master)"
28
+ fi
29
+ [[ -z "$(git branch --all --list master */master)" ]]
30
+
31
+ - samvera/bundle:
32
+ ruby_version: << parameters.ruby_version >>
33
+ bundler_version: << parameters.bundler_version >>
34
+
35
+ - samvera/engine_cart_generate:
36
+ cache_key: v1-internal-test-app-{{ checksum "active_annotations.gemspec" }}-{{ checksum "spec/test_app_templates/lib/generators/test_app_generator.rb" }}-<< parameters.rails_version >>-<< parameters.ruby_version >>
37
+
38
+ - samvera/bundle:
39
+ ruby_version: << parameters.ruby_version >>
40
+ bundler_version: << parameters.bundler_version >>
41
+
42
+ - samvera/parallel_rspec
43
+
44
+ workflows:
45
+ ci:
46
+ jobs:
47
+ - bundle_lint_test:
48
+ name: ruby2-7_rails7-0
49
+ ruby_version: 2.7.5
50
+ rails_version: 7.0.2.2
51
+ - bundle_lint_test:
52
+ name: ruby2-7_rails6-1
53
+ ruby_version: 2.7.5
54
+ rails_version: 6.1.4.6
55
+ - bundle_lint_test:
56
+ name: ruby2-7_rails6-0
57
+ ruby_version: 2.7.5
58
+ rails_version: 6.0.4.6
59
+ - bundle_lint_test:
60
+ name: ruby2-7_rails5-2
61
+ ruby_version: 2.7.5
62
+ rails_version: 5.2.6
63
+ - bundle_lint_test:
64
+ name: ruby2-6_rails5-2
65
+ ruby_version: 2.6.9
66
+ rails_version: 5.2.6
data/Gemfile CHANGED
@@ -2,6 +2,10 @@ source 'https://rubygems.org'
2
2
  # Specify your gem's dependencies in active_annotations.gemspec
3
3
  gemspec
4
4
 
5
+ group :test do
6
+ gem 'rspec_junit_formatter'
7
+ end
8
+
5
9
  # BEGIN ENGINE_CART BLOCK
6
10
  # engine_cart: 1.0.1
7
11
  # engine_cart stanza: 0.10.0
@@ -20,19 +24,20 @@ else
20
24
  if ENV['RAILS_VERSION']
21
25
  if ENV['RAILS_VERSION'] == 'edge'
22
26
  gem 'rails', github: 'rails/rails'
23
- ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks'
27
+ ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks --skip-javascript'
24
28
  else
25
29
  gem 'rails', ENV['RAILS_VERSION']
30
+ ENV['ENGINE_CART_RAILS_OPTIONS'] = '--skip-turbolinks --skip-javascript'
31
+ end
32
+ case ENV['RAILS_VERSION']
33
+ when /^6.0/
34
+ gem 'sass-rails', '>= 6'
35
+ gem 'webpacker', '~> 4.0'
36
+ when /^5.[12]/
37
+ gem 'sass-rails', '~> 5.0'
38
+ gem 'sprockets', '~> 3.7'
39
+ gem 'thor', '~> 0.20'
26
40
  end
27
- end
28
-
29
- case ENV['RAILS_VERSION']
30
- when /^4.2/
31
- gem 'responders', '~> 2.0'
32
- gem 'sass-rails', '>= 5.0'
33
- gem 'coffee-rails', '~> 4.1.0'
34
- when /^4.[01]/
35
- gem 'sass-rails', '< 5.0'
36
41
  end
37
42
  end
38
43
  # END ENGINE_CART BLOCK
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # ActiveAnnotations
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/active_annotations.png)](http://badge.fury.io/rb/active_annotations)
4
- [![Build Status](https://travis-ci.org/avalonmediasystem/active_annotations.svg?branch=master)](https://travis-ci.org/avalonmediasystem/active_annotations)
4
+ [![Build Status](https://circleci.com/gh/avalonmediasystem/active_annotations.svg?style=svg)](https://circleci.com/gh/avalonmediasystem/active_annotations)
5
5
  [![Coverage Status](https://coveralls.io/repos/avalonmediasystem/active_annotations/badge.svg?branch=master&service=github)](https://coveralls.io/github/avalonmediasystem/active_annotations?branch=master)
6
6
 
7
7
  ActiveAnnotations is a gem for modeling simple [OpenAnnotation](http://www.openannotation.org/)-compatible annotations to Rails. It is ActiveRecord compatible, but is backed by an RDF graph that serializes (by default) to [JSON-LD](http://json-ld.org/).
@@ -19,13 +19,13 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
+ spec.add_dependency 'rails', '>= 5.2', '< 7.1'
22
23
  spec.add_dependency "json-ld"
23
- spec.add_dependency "rdf-vocab", "~> 2.1.0"
24
- spec.add_development_dependency "bundler", "~> 1.11"
25
- spec.add_development_dependency "rake", "~> 11.0"
26
- spec.add_development_dependency "rspec", "~> 3.0"
27
- spec.add_development_dependency "engine_cart", "~> 1.0.1"
24
+ spec.add_dependency "rdf-vocab", ">= 2.1.0"
25
+ spec.add_development_dependency "bundler"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency "engine_cart"
28
29
  spec.add_development_dependency "faker"
29
- spec.add_development_dependency "coveralls"
30
30
  spec.add_development_dependency "simplecov"
31
31
  end
@@ -1,4 +1,4 @@
1
- class CreateAnnotations < ActiveRecord::Migration
1
+ class CreateAnnotations < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :annotations do |t|
4
4
  t.string :uuid
@@ -3,7 +3,7 @@ module ActiveAnnotations
3
3
  class << self
4
4
  def local_document_loader(url, options={}, &block)
5
5
  if RDF::URI(url) == RDF::URI(RDFAnnotation::CONTEXT_URI)
6
- remote_document = JSON::LD::API::RemoteDocument.new(url, File.read(File.expand_path('../oa.jsonld',__FILE__)))
6
+ remote_document = JSON::LD::API::RemoteDocument.new(File.read(File.expand_path('../oa.jsonld',__FILE__)), base: url)
7
7
  block_given? ? yield(remote_document) : remote_document
8
8
  else
9
9
  # :nocov:
@@ -1,9 +1,5 @@
1
- if defined?(Rails)
2
- module ActiveAnnotations
3
- class Engine < Rails::Engine
4
- config.autoload_paths += Dir["#{config.root}/app/models/**/"]
5
-
6
- engine_name 'active_annotations'
7
- end
1
+ module ActiveAnnotations
2
+ class Engine < Rails::Engine
3
+ engine_name 'active_annotations'
8
4
  end
9
5
  end
@@ -8,28 +8,29 @@ require 'rdf/vocab/cnt'
8
8
  require 'rdf/vocab/dcmitype'
9
9
  require 'rdf/vocab/foaf'
10
10
 
11
- module ActiveAnnotations
11
+ module ActiveAnnotations
12
12
  class RDFAnnotation
13
13
  RDF::Vocab::DC = RDF::DC unless defined?(RDF::Vocab::DC)
14
14
  RDF::Vocab::FOAF = RDF::FOAF unless defined?(RDF::Vocab::FOAF)
15
-
15
+
16
16
  # Support reading legacy properties
17
17
  RDF::Vocab::OA.property 'annotatedAt'
18
18
  RDF::Vocab::OA.property 'annotatedBy'
19
-
19
+
20
20
  attr_reader :graph
21
21
  CONTEXT_URI = 'http://www.w3.org/ns/oa.jsonld'
22
-
22
+
23
23
  def self.from_jsonld(json)
24
24
  content = JSON.parse(json)
25
25
  self.new(JSON::LD::API.toRDF(content, documentLoader: DocumentLoader.document_loader))
26
26
  end
27
-
27
+
28
28
  def to_jsonld(opts={})
29
29
  input = JSON.parse(graph.dump :jsonld, standard_prefixes: true, prefixes: { oa: RDF::Vocab::OA.to_iri.value })
30
30
  frame = YAML.load(File.read(File.expand_path('../frame.yml',__FILE__)))
31
- output = JSON::LD::API.frame(input, frame, omitDefault: true, documentLoader: DocumentLoader.document_loader)
32
- output.merge!(output.delete('@graph')[0])
31
+ output = JSON::LD::API.frame(input, frame, validate: false, omitDefault: true, documentLoader: DocumentLoader.document_loader)
32
+ graph = output.delete('@graph').try(:first)
33
+ output.merge!(graph) if graph
33
34
  if opts[:pretty_json]
34
35
  JSON.pretty_generate output
35
36
  else
@@ -45,7 +46,7 @@ module ActiveAnnotations
45
46
  @graph << content
46
47
  end
47
48
  end
48
-
49
+
49
50
  def get_value(s, p)
50
51
  return nil if s.nil?
51
52
  statement = graph.first(subject: s, predicate: p)
@@ -57,17 +58,17 @@ module ActiveAnnotations
57
58
  statement.object.value
58
59
  end
59
60
  end
60
-
61
+
61
62
  def set_value(s, p, value)
62
63
  return nil if s.nil?
63
64
  @graph.delete({ subject: s, predicate: p })
64
65
  @graph << RDF::Statement.new(s, p, value) unless value.nil?
65
66
  end
66
-
67
+
67
68
  def add_statements(*statements)
68
69
  statements.each { |statement| @graph << statement }
69
70
  end
70
-
71
+
71
72
  def add_default_content!
72
73
  aid = new_id
73
74
  add_statements(
@@ -86,7 +87,7 @@ module ActiveAnnotations
86
87
  )
87
88
  end
88
89
  end
89
-
90
+
90
91
  def ensure_target!
91
92
  if target_id.nil?
92
93
  tid = new_id
@@ -108,7 +109,7 @@ module ActiveAnnotations
108
109
  )
109
110
  end
110
111
  end
111
-
112
+
112
113
  def new_id
113
114
  RDF::URI.new("urn:uuid:#{SecureRandom.uuid}")
114
115
  end
@@ -117,68 +118,68 @@ module ActiveAnnotations
117
118
  statement = @graph.first(predicate: RDF.type, object: type)
118
119
  statement.nil? ? nil : statement.subject
119
120
  end
120
-
121
+
121
122
  def annotation_id
122
123
  find_id(RDF::Vocab::OA.Annotation)
123
124
  end
124
-
125
+
125
126
  def body_id
126
127
  statement = @graph.first(subject: annotation_id, predicate: RDF::Vocab::OA.hasBody)
127
128
  statement.nil? ? nil : statement.object
128
129
  end
129
-
130
+
130
131
  def target_id
131
132
  find_id(RDF::Vocab::OA.SpecificResource)
132
133
  end
133
-
134
+
134
135
  def selector_id
135
136
  find_id(RDF::Vocab::OA.FragmentSelector)
136
137
  end
137
-
138
+
138
139
  def fragment_value
139
140
  graph.first(subject: selector_id, predicate: RDF.value)
140
141
  end
141
-
142
+
142
143
  def fragment_value=(value)
143
144
  ensure_selector!
144
145
  set_value(selector_id, RDF.value, value)
145
146
  end
146
-
147
+
147
148
  def start_time
148
149
  value = fragment_value.nil? ? nil : fragment_value.object.value.scan(/^t=(.*)$/).flatten.first.split(/,/)[0]
149
150
  Float(value)
150
151
  rescue
151
152
  value
152
153
  end
153
-
154
+
154
155
  def start_time=(value)
155
156
  self.fragment_value = "t=#{[value, end_time].join(',')}"
156
157
  end
157
-
158
+
158
159
  def end_time
159
160
  value = fragment_value.nil? ? nil : fragment_value.object.value.scan(/^t=(.*)$/).flatten.first.split(/,/)[1]
160
161
  Float(value)
161
162
  rescue
162
163
  value
163
164
  end
164
-
165
+
165
166
  def end_time=(value)
166
167
  self.fragment_value = "t=#{[start_time, value].join(',')}"
167
168
  end
168
-
169
+
169
170
  def content
170
171
  get_value(body_id, RDF::Vocab::CNT.chars)
171
172
  end
172
-
173
+
173
174
  def content=(value)
174
175
  ensure_body!
175
176
  set_value(body_id, RDF::Vocab::CNT.chars, value)
176
177
  end
177
-
178
+
178
179
  def annotated_by
179
180
  get_value(annotation_id, RDF::Vocab::DC.creator) || get_value(annotation_id, RDF::Vocab::OA.annotatedBy)
180
181
  end
181
-
182
+
182
183
  def annotated_by=(value)
183
184
  unless annotated_by.nil?
184
185
  @graph.delete({ subject: RDF::URI(annotated_by) })
@@ -188,20 +189,20 @@ module ActiveAnnotations
188
189
  set_value(annotation_id, RDF::Vocab::DC.creator, value)
189
190
  set_value(value, RDF.type, RDF::Vocab::FOAF.Person)
190
191
  end
191
-
192
+
192
193
  def annotated_at
193
194
  get_value(annotation_id, RDF::Vocab::DC.modified) || get_value(annotation_id, RDF::Vocab::OA.annotatedAt)
194
195
  end
195
-
196
+
196
197
  def annotated_at=(value)
197
198
  set_value(annotation_id, RDF::Vocab::DC.modified, value)
198
199
  end
199
-
200
+
200
201
  def source
201
202
  # TODO: Replace this with some way of retrieving the actual source
202
203
  get_value(target_id, RDF::Vocab::OA.hasSource)
203
204
  end
204
-
205
+
205
206
  def source=(value)
206
207
  unless target_id.nil?
207
208
  statement = @graph.first(subject: target_id, predicate: RDF::Vocab::OA.hasSource)
@@ -216,11 +217,11 @@ module ActiveAnnotations
216
217
  )
217
218
  end
218
219
  end
219
-
220
+
220
221
  def label
221
222
  get_value(annotation_id, RDF::RDFS.label)
222
223
  end
223
-
224
+
224
225
  def label=(value)
225
226
  set_value(annotation_id, RDF::RDFS.label, value)
226
227
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveAnnotations
2
- VERSION = "0.2.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -5,8 +5,6 @@ RSpec::Core::RakeTask.new(:spec) do |t|
5
5
  t.pattern = 'spec/**/*_spec.rb'
6
6
  end
7
7
 
8
- EngineCart.fingerprint_proc = EngineCart.rails_fingerprint_proc
9
-
10
8
  desc "Run test suite"
11
9
  task :ci => ['engine_cart:generate'] do
12
10
  Rake::Task['spec'].invoke
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_annotations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael B. Klein
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-14 00:00:00.000000000 Z
11
+ date: 2022-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '5.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.1'
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: json-ld
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -28,74 +48,60 @@ dependencies:
28
48
  name: rdf-vocab
29
49
  requirement: !ruby/object:Gem::Requirement
30
50
  requirements:
31
- - - "~>"
51
+ - - ">="
32
52
  - !ruby/object:Gem::Version
33
53
  version: 2.1.0
34
54
  type: :runtime
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
37
57
  requirements:
38
- - - "~>"
58
+ - - ">="
39
59
  - !ruby/object:Gem::Version
40
60
  version: 2.1.0
41
61
  - !ruby/object:Gem::Dependency
42
62
  name: bundler
43
63
  requirement: !ruby/object:Gem::Requirement
44
64
  requirements:
45
- - - "~>"
65
+ - - ">="
46
66
  - !ruby/object:Gem::Version
47
- version: '1.11'
67
+ version: '0'
48
68
  type: :development
49
69
  prerelease: false
50
70
  version_requirements: !ruby/object:Gem::Requirement
51
71
  requirements:
52
- - - "~>"
72
+ - - ">="
53
73
  - !ruby/object:Gem::Version
54
- version: '1.11'
74
+ version: '0'
55
75
  - !ruby/object:Gem::Dependency
56
76
  name: rake
57
77
  requirement: !ruby/object:Gem::Requirement
58
78
  requirements:
59
- - - "~>"
79
+ - - ">="
60
80
  - !ruby/object:Gem::Version
61
- version: '11.0'
81
+ version: '0'
62
82
  type: :development
63
83
  prerelease: false
64
84
  version_requirements: !ruby/object:Gem::Requirement
65
85
  requirements:
66
- - - "~>"
86
+ - - ">="
67
87
  - !ruby/object:Gem::Version
68
- version: '11.0'
88
+ version: '0'
69
89
  - !ruby/object:Gem::Dependency
70
90
  name: rspec
71
91
  requirement: !ruby/object:Gem::Requirement
72
92
  requirements:
73
- - - "~>"
93
+ - - ">="
74
94
  - !ruby/object:Gem::Version
75
- version: '3.0'
95
+ version: '0'
76
96
  type: :development
77
97
  prerelease: false
78
98
  version_requirements: !ruby/object:Gem::Requirement
79
99
  requirements:
80
- - - "~>"
100
+ - - ">="
81
101
  - !ruby/object:Gem::Version
82
- version: '3.0'
102
+ version: '0'
83
103
  - !ruby/object:Gem::Dependency
84
104
  name: engine_cart
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 1.0.1
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 1.0.1
97
- - !ruby/object:Gem::Dependency
98
- name: faker
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
107
  - - ">="
@@ -109,7 +115,7 @@ dependencies:
109
115
  - !ruby/object:Gem::Version
110
116
  version: '0'
111
117
  - !ruby/object:Gem::Dependency
112
- name: coveralls
118
+ name: faker
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
115
121
  - - ">="
@@ -143,10 +149,9 @@ executables: []
143
149
  extensions: []
144
150
  extra_rdoc_files: []
145
151
  files:
146
- - ".coveralls.yml"
152
+ - ".circleci/config.yml"
147
153
  - ".gitignore"
148
154
  - ".rspec"
149
- - ".travis.yml"
150
155
  - Gemfile
151
156
  - LICENSE
152
157
  - README.md
@@ -182,8 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
187
  - !ruby/object:Gem::Version
183
188
  version: '0'
184
189
  requirements: []
185
- rubyforge_project:
186
- rubygems_version: 2.5.1
190
+ rubygems_version: 3.1.6
187
191
  signing_key:
188
192
  specification_version: 4
189
193
  summary: OpenAnnontations + JSON-LD + ActiveRecord
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- repo_token: W7waugqQH8STNmsf9kX0CldGQPeB0A4wM
data/.travis.yml DELETED
@@ -1,17 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- rvm:
4
- - 2.2.5
5
- - 2.3.1
6
- env:
7
- global:
8
- - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
9
- matrix:
10
- - RAILS_VERSION='~>4.1.10'
11
- - RAILS_VERSION='~>4.2.5'
12
-
13
- before_install:
14
- - gem install bundler
15
-
16
- notifications:
17
- irc: "irc.freenode.org#projectvov"