qa 5.9.0 → 5.11.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/README.md +15 -8
- data/lib/qa/authorities/getty/aat2.rb +62 -0
- data/lib/qa/data/TGN_LANGUAGES.xml +1 -1
- data/lib/qa/engine.rb +16 -0
- data/lib/qa/version.rb +1 -1
- data/spec/lib/authorities/discogs/generic_authority_spec.rb +1 -1
- data/spec/lib/services/rdf_authority_parser_spec.rb +1 -1
- data/spec/spec_helper.rb +7 -1
- data/spec/test_app_templates/Gemfile.extra +12 -6
- metadata +56 -12
- /data/{app/services → lib}/qa/linked_data/authority_service.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b356b770cbc77b1d67024f2a73be01b579943e75d9bda64e7f7dad04f66342b
|
4
|
+
data.tar.gz: a3f6a66764724811209c8616e00f260cab0d371f340117f335d384c1f84d1bd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 798c03132eac1750d15b0db93e2c6009925b1ebd3773619df77cd11f3f0cd661b6645d5e54122842efdc3e86d221356fb38aca6705943c35a5dc03d0a7010d2d
|
7
|
+
data.tar.gz: f1a3e23f4f3eb3197c3f8e39e2a9663ae7329a7e1e46e100f60d91f3b01b55e46a19ded39ac4b88520ec29189adc1e3d948bbfca7422044a92dc2c26d6eb3367
|
data/README.md
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
# Questioning Authority
|
2
2
|
|
3
|
-
Code:
|
3
|
+
Code:
|
4
|
+
[](http://badge.fury.io/rb/qa)
|
5
|
+
[](https://circleci.com/gh/samvera/questioning_authority)
|
6
|
+
[](https://coveralls.io/github/samvera/questioning_authority?branch=main)
|
4
7
|
|
5
|
-
Docs:
|
8
|
+
Docs:
|
9
|
+
[](./CONTRIBUTING.md)
|
10
|
+
[](./LICENSE)
|
6
11
|
|
7
|
-
|
12
|
+
Community Support: [](http://slack.samvera.org/)
|
8
13
|
|
9
14
|
You should question your authorities.
|
10
15
|
|
@@ -145,14 +150,14 @@ rake ci
|
|
145
150
|
|
146
151
|
Commit your features into a new branch and submit a pull request.
|
147
152
|
|
148
|
-
## Contributing
|
153
|
+
## Contributing
|
149
154
|
|
150
|
-
If you're working on PR for this project, create a feature branch off of `main`.
|
155
|
+
If you're working on PR for this project, create a feature branch off of `main`.
|
151
156
|
|
152
157
|
This repository follows the [Samvera Community Code of Conduct](https://samvera.atlassian.net/wiki/spaces/samvera/pages/405212316/Code+of+Conduct) and [language recommendations](https://github.com/samvera/maintenance/blob/main/templates/CONTRIBUTING.md#language). Please ***do not*** create a branch called `master` for this repository or as part of your pull request; the branch will either need to be removed or renamed before it can be considered for inclusion in the code base and history of this repository.
|
153
158
|
|
154
159
|
## Compatibility
|
155
|
-
This gem works with Rails 5.0-
|
160
|
+
This gem works with Rails 5.0-7.0 and Ruby 2.5-3.1, provided the version of Rails supports the version of Ruby.
|
156
161
|
- Consult `.circleci/config.yml` for a list of supported combinations.
|
157
162
|
- The combination of Ruby 3.1 and Rails 6.0 comes with three caveats:
|
158
163
|
- your app will not be able to use `psych 4` (which ordinarily comes with 3.1). See https://bugs.ruby-lang.org/issues/17866 and https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias/71192990#71192990 for an explanation. One workaround is to modify your app's `Gemfile` to hold back `psych`: `gem 'psych', '< 4'`.
|
@@ -163,11 +168,13 @@ See also `.circleci/config.yml` and `spec/test_app_templates/Gemfile.extra`.
|
|
163
168
|
|
164
169
|
## Product Owner & Maintenance
|
165
170
|
|
166
|
-
|
171
|
+
`qa` was a Core Component of the Samvera Community. Given a decline in available labor required for maintenance, this project no longer has a dedicated Product Owner. The documentation for what this means can be found [here](http://samvera.github.io/core_components.html#requirements-for-a-core-component).
|
167
172
|
|
168
173
|
### Product Owner
|
169
174
|
|
170
|
-
|
175
|
+
**Vacant**
|
176
|
+
|
177
|
+
_Until a Product Owner has been identified, we ask that you please direct all requests for support, bug reports, and general questions to the [`#dev` Channel on the Samvera Slack](https://samvera.slack.com/app_redirect?channel=dev)._
|
171
178
|
|
172
179
|
## Releasing
|
173
180
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Qa::Authorities
|
2
|
+
class Getty::AAT2 < Base
|
3
|
+
include WebServiceBase
|
4
|
+
|
5
|
+
def search(q)
|
6
|
+
parse_authority_response(json(build_query_url(q)))
|
7
|
+
end
|
8
|
+
|
9
|
+
def build_query_url(q)
|
10
|
+
"http://vocab.getty.edu/sparql.json?query=#{ERB::Util.url_encode(sparql(q))}&_implicit=false&implicit=true&_equivalent=false&_form=%2Fsparql"
|
11
|
+
end
|
12
|
+
|
13
|
+
def sparql(q) # rubocop:disable Metrics/MethodLength
|
14
|
+
search = untaint(q)
|
15
|
+
if search.include?(' ')
|
16
|
+
clauses = search.split(' ').collect do |i|
|
17
|
+
%((regex(?name, "#{i}", "i")))
|
18
|
+
end
|
19
|
+
ex = "(#{clauses.join(' && ')})"
|
20
|
+
else
|
21
|
+
ex = %(regex(?name, "#{search}", "i"))
|
22
|
+
end
|
23
|
+
# The full text index matches on fields besides the term, so we filter to ensure the match is in the term.
|
24
|
+
%(SELECT ?s ?name {
|
25
|
+
?s a skos:Concept; luc:term "#{search}";
|
26
|
+
skos:inScheme <http://vocab.getty.edu/aat/> ;
|
27
|
+
gvp:prefLabelGVP [skosxl:literalForm ?name].
|
28
|
+
FILTER #{ex} .
|
29
|
+
} ORDER BY ?name).gsub(/[\s\n]+/, " ")
|
30
|
+
end
|
31
|
+
|
32
|
+
def untaint(q)
|
33
|
+
q.gsub(/[^\w\s-]/, '')
|
34
|
+
end
|
35
|
+
|
36
|
+
def find(id)
|
37
|
+
json(find_url(id))
|
38
|
+
end
|
39
|
+
|
40
|
+
def find_url(id)
|
41
|
+
"http://vocab.getty.edu/download/json?uri=http://vocab.getty.edu/aat/#{id}.json"
|
42
|
+
end
|
43
|
+
|
44
|
+
def request_options
|
45
|
+
{ accept: 'application/sparql-results+json' }
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
# Reformats the data received from the Getty service
|
51
|
+
def parse_authority_response(response)
|
52
|
+
response['results']['bindings'].map do |result|
|
53
|
+
{ 'id' => result['s']['value'], 'label' => result['name']['value'] }
|
54
|
+
end
|
55
|
+
rescue StandardError => e
|
56
|
+
cause = response.fetch('error', {}).fetch('cause', 'UNKNOWN')
|
57
|
+
cause = cause.present? ? cause : 'UNKNOWN'
|
58
|
+
Rails.logger.warn " ERROR fetching Getty response: #{e.message}; cause: #{cause}"
|
59
|
+
{}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<?xml version="1.0" encoding="
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
2
|
<Vocabulary xmlns="http://localhost/namespace" xmlns:vp="http://localhost/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost/namespace Getty_Vocab_Export_Languages.xsd" Title="Thesaurus of Geographic Names" Part="Languages" Date="2011-04-11">
|
3
3
|
<Language>
|
4
4
|
<Language_Code>70115</Language_Code>
|
data/lib/qa/engine.rb
CHANGED
@@ -1,5 +1,21 @@
|
|
1
|
+
# used in initializer where autoload is unavailable, must be required here:
|
2
|
+
require 'qa/linked_data/authority_service'
|
3
|
+
|
1
4
|
module Qa
|
2
5
|
class Engine < ::Rails::Engine
|
3
6
|
isolate_namespace Qa
|
7
|
+
|
8
|
+
config.before_configuration do
|
9
|
+
# rubocop:disable Style/IfUnlessModifier
|
10
|
+
|
11
|
+
# see https://github.com/fxn/zeitwerk#for_gem
|
12
|
+
# Blacklight puts a generator into LOCAL APP lib/generators, so tell
|
13
|
+
# zeitwerk to ignore the whole directory? If we're using zeitwerk
|
14
|
+
#
|
15
|
+
# See: https://github.com/cbeer/engine_cart/issues/117
|
16
|
+
if Rails.try(:autoloaders).try(:main).respond_to?(:ignore)
|
17
|
+
Rails.autoloaders.main.ignore(Rails.root.join('lib', 'generators'))
|
18
|
+
end
|
19
|
+
end
|
4
20
|
end
|
5
21
|
end
|
data/lib/qa/version.rb
CHANGED
@@ -212,7 +212,7 @@ describe Qa::Authorities::Discogs::GenericAuthority do
|
|
212
212
|
expect(JSON.parse(results).keys).to match_array ["@context", "@graph"]
|
213
213
|
expect(JSON.parse(results)["@context"]["bf2"]).to eq("http://id.loc.gov/ontologies/bibframe/")
|
214
214
|
expect(results).to include("You Go To My Head")
|
215
|
-
expect(results).to include("Rodgers & Hart")
|
215
|
+
expect(JSON.parse(results).inspect).to include("Rodgers & Hart")
|
216
216
|
expect(results).to include("Ray Brown")
|
217
217
|
expect(results).to include("1952")
|
218
218
|
expect(results).to include("Single")
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Qa::Services::RDFAuthorityParser do
|
5
|
-
let(:source) { [
|
5
|
+
let(:source) { [Qa::Engine.root.join('spec', 'fixtures', 'lexvo_snippet.rdf.xml')] }
|
6
6
|
let(:format) { 'rdfxml' }
|
7
7
|
let(:predicate) { RDF::URI("http://www.w3.org/2008/05/skos#prefLabel") }
|
8
8
|
let(:name) { 'language' }
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
|
1
|
+
# Not sure why these RDF-related gems are only being used in CI and not general
|
2
|
+
# dependencies... maybe meant to be optional dependencies?
|
3
|
+
require 'rdf/n3'
|
4
|
+
require 'rdf/rdfxml'
|
5
|
+
require 'json/ld'
|
6
|
+
require 'rdf/vocab'
|
7
|
+
|
2
8
|
require 'json'
|
3
9
|
require 'engine_cart'
|
4
10
|
require 'byebug' unless ENV['TRAVIS']
|
@@ -1,13 +1,19 @@
|
|
1
1
|
# Use this file to reference specific commits of gems.
|
2
2
|
|
3
|
+
|
3
4
|
group :development do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
# Rails < 6.1 are not compatible with psych 4, although doesn't know it.
|
6
|
+
# Local apps using old Rails will have to lock locally. Latest versions
|
7
|
+
# of Rails 6.1+ has been updated to work with psych 4.
|
8
|
+
# See also:
|
9
|
+
#
|
10
|
+
# https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias/71192990#71192990
|
11
|
+
#
|
12
|
+
if ENV['RAILS_VERSION'] && Gem::Version.new(ENV['RAILS_VERSION']) < Gem::Version.new("6.1")
|
10
13
|
gem 'psych', '< 4'
|
14
|
+
end
|
15
|
+
|
16
|
+
if ENV['RAILS_VERSION'] =~ /^6\.1\./ && ENV['RUBY_VERSION'] =~ /^3\.1\./
|
11
17
|
# opt into mail 2.8.0.rc1 so we get extra dependencies
|
12
18
|
# Once mail 2.8.0 final is released this will not be required.
|
13
19
|
# https://github.com/mikel/mail/pull/1472
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Anderson
|
@@ -16,7 +16,7 @@ authors:
|
|
16
16
|
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
|
-
date:
|
19
|
+
date: 2023-11-09 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activerecord-import
|
@@ -117,7 +117,7 @@ dependencies:
|
|
117
117
|
version: '5.0'
|
118
118
|
- - "<"
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version: '
|
120
|
+
version: '7.2'
|
121
121
|
type: :runtime
|
122
122
|
prerelease: false
|
123
123
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -127,7 +127,7 @@ dependencies:
|
|
127
127
|
version: '5.0'
|
128
128
|
- - "<"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: '
|
130
|
+
version: '7.2'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: rdf
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,19 +217,61 @@ dependencies:
|
|
217
217
|
- !ruby/object:Gem::Version
|
218
218
|
version: '2.0'
|
219
219
|
- !ruby/object:Gem::Dependency
|
220
|
-
name:
|
220
|
+
name: rdf-n3
|
221
221
|
requirement: !ruby/object:Gem::Requirement
|
222
222
|
requirements:
|
223
|
-
- - "
|
223
|
+
- - "~>"
|
224
224
|
- !ruby/object:Gem::Version
|
225
|
-
version: '0'
|
225
|
+
version: '3.0'
|
226
226
|
type: :development
|
227
227
|
prerelease: false
|
228
228
|
version_requirements: !ruby/object:Gem::Requirement
|
229
229
|
requirements:
|
230
|
-
- - "
|
230
|
+
- - "~>"
|
231
231
|
- !ruby/object:Gem::Version
|
232
|
-
version: '0'
|
232
|
+
version: '3.0'
|
233
|
+
- !ruby/object:Gem::Dependency
|
234
|
+
name: rdf-rdfxml
|
235
|
+
requirement: !ruby/object:Gem::Requirement
|
236
|
+
requirements:
|
237
|
+
- - "~>"
|
238
|
+
- !ruby/object:Gem::Version
|
239
|
+
version: '3.0'
|
240
|
+
type: :development
|
241
|
+
prerelease: false
|
242
|
+
version_requirements: !ruby/object:Gem::Requirement
|
243
|
+
requirements:
|
244
|
+
- - "~>"
|
245
|
+
- !ruby/object:Gem::Version
|
246
|
+
version: '3.0'
|
247
|
+
- !ruby/object:Gem::Dependency
|
248
|
+
name: json-ld
|
249
|
+
requirement: !ruby/object:Gem::Requirement
|
250
|
+
requirements:
|
251
|
+
- - "~>"
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: '3.0'
|
254
|
+
type: :development
|
255
|
+
prerelease: false
|
256
|
+
version_requirements: !ruby/object:Gem::Requirement
|
257
|
+
requirements:
|
258
|
+
- - "~>"
|
259
|
+
- !ruby/object:Gem::Version
|
260
|
+
version: '3.0'
|
261
|
+
- !ruby/object:Gem::Dependency
|
262
|
+
name: rdf-vocab
|
263
|
+
requirement: !ruby/object:Gem::Requirement
|
264
|
+
requirements:
|
265
|
+
- - "~>"
|
266
|
+
- !ruby/object:Gem::Version
|
267
|
+
version: '3.0'
|
268
|
+
type: :development
|
269
|
+
prerelease: false
|
270
|
+
version_requirements: !ruby/object:Gem::Requirement
|
271
|
+
requirements:
|
272
|
+
- - "~>"
|
273
|
+
- !ruby/object:Gem::Version
|
274
|
+
version: '3.0'
|
233
275
|
- !ruby/object:Gem::Dependency
|
234
276
|
name: pry
|
235
277
|
requirement: !ruby/object:Gem::Requirement
|
@@ -353,7 +395,6 @@ files:
|
|
353
395
|
- app/models/qa/mesh_tree.rb
|
354
396
|
- app/models/qa/subject_mesh_term.rb
|
355
397
|
- app/services/qa/iri_template_service.rb
|
356
|
-
- app/services/qa/linked_data/authority_service.rb
|
357
398
|
- app/services/qa/linked_data/authority_url_service.rb
|
358
399
|
- app/services/qa/linked_data/deep_sort_service.rb
|
359
400
|
- app/services/qa/linked_data/graph_service.rb
|
@@ -434,6 +475,7 @@ files:
|
|
434
475
|
- lib/qa/authorities/geonames.rb
|
435
476
|
- lib/qa/authorities/getty.rb
|
436
477
|
- lib/qa/authorities/getty/aat.rb
|
478
|
+
- lib/qa/authorities/getty/aat2.rb
|
437
479
|
- lib/qa/authorities/getty/tgn.rb
|
438
480
|
- lib/qa/authorities/getty/ulan.rb
|
439
481
|
- lib/qa/authorities/linked_data.rb
|
@@ -462,6 +504,7 @@ files:
|
|
462
504
|
- lib/qa/configuration.rb
|
463
505
|
- lib/qa/data/TGN_LANGUAGES.xml
|
464
506
|
- lib/qa/engine.rb
|
507
|
+
- lib/qa/linked_data/authority_service.rb
|
465
508
|
- lib/qa/services.rb
|
466
509
|
- lib/qa/services/rdf_authority_parser.rb
|
467
510
|
- lib/qa/version.rb
|
@@ -618,7 +661,8 @@ files:
|
|
618
661
|
homepage: https://github.com/projecthydra/questioning_authority
|
619
662
|
licenses:
|
620
663
|
- APACHE-2
|
621
|
-
metadata:
|
664
|
+
metadata:
|
665
|
+
rubygems_mfa_required: 'true'
|
622
666
|
post_install_message:
|
623
667
|
rdoc_options: []
|
624
668
|
require_paths:
|
@@ -634,7 +678,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
634
678
|
- !ruby/object:Gem::Version
|
635
679
|
version: '0'
|
636
680
|
requirements: []
|
637
|
-
rubygems_version: 3.
|
681
|
+
rubygems_version: 3.4.21
|
638
682
|
signing_key:
|
639
683
|
specification_version: 4
|
640
684
|
summary: You should question your authorities.
|
File without changes
|