qa 5.16.0 → 5.17.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/app/services/qa/pagination_service.rb +2 -2
- data/config/authorities/linked_data/getty_aac.json +6 -0
- data/lib/generators/qa/apidoc/apidoc_generator.rb +1 -1
- data/lib/qa/authorities/assign_fast/space_fix_encoder.rb +2 -4
- data/lib/qa/authorities/getty/aat.rb +10 -2
- data/lib/qa/authorities/linked_data/search_query.rb +1 -1
- data/lib/qa/authorities/loc_subauthority.rb +2 -1
- data/lib/qa/authorities/local/registry.rb +2 -8
- data/lib/qa/engine.rb +7 -0
- data/lib/qa/version.rb +1 -1
- data/lib/qa.rb +14 -2
- data/lib/tasks/mesh.rake +2 -2
- data/spec/controllers/terms_controller_spec.rb +1 -1
- data/spec/lib/authorities/getty/aat_spec.rb +3 -3
- data/spec/services/linked_data/authority_service_spec.rb +2 -1
- data/spec/services/linked_data/response_header_service_spec.rb +1 -2
- data/spec/test_app_templates/Gemfile.extra +9 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- metadata +4 -18
- data/lib/qa/authorities/getty/aat2.rb +0 -62
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16eaf3a1b00dfb3b3063af78f2065ebd16b254fe5d97c55bc27c6255e41c5946
|
|
4
|
+
data.tar.gz: 50dc8f8818c16b2ccfcfa0dfb79b74ebb1d7032ca1cd389ac4d181e885ca0db1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ee41c3074ee5172e3e4455afa5a1a7858e61894140642e45d6c3efddca298cd46749f9eed04a9446bc287965497dbab715167e682821a85e37aba97a0e36e71b
|
|
7
|
+
data.tar.gz: 6412e3a3843ee1984797299d22cac8c6e8f9ac19f544b8b85c530db4a67c8826811f416fb546d633467736b1070bc86068fde65db7c48e939e9cba12d6956f65
|
|
@@ -433,7 +433,7 @@ module Qa
|
|
|
433
433
|
# linked_data module pagination).
|
|
434
434
|
def requested_page_offset
|
|
435
435
|
return @requested_page_offset if @requested_page_offset.present?
|
|
436
|
-
@requested_page_offset =
|
|
436
|
+
@requested_page_offset = request_params['page_offset'] || request_params['startRecord']
|
|
437
437
|
end
|
|
438
438
|
|
|
439
439
|
# @return [Integer] The first record to include in the response data as
|
|
@@ -470,7 +470,7 @@ module Qa
|
|
|
470
470
|
# linked_data module pagination).
|
|
471
471
|
def requested_page_limit
|
|
472
472
|
return @requested_page_limit if @requested_page_limit.present?
|
|
473
|
-
@requested_page_limit ||=
|
|
473
|
+
@requested_page_limit ||= request_params['page_limit'] || request_params['maxRecords']
|
|
474
474
|
end
|
|
475
475
|
|
|
476
476
|
# @return [Integer] The max number of records to include in response data as
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
module Qa::Authorities
|
|
2
2
|
# for use with Faraday; encode spaces as '%20' not '+'
|
|
3
3
|
class AssignFast::SpaceFixEncoder
|
|
4
|
+
delegate :decode, to: Faraday::NestedParamsEncoder
|
|
5
|
+
|
|
4
6
|
def encode(hash)
|
|
5
7
|
encoded = Faraday::NestedParamsEncoder.encode(hash)
|
|
6
8
|
encoded.gsub('+', '%20')
|
|
7
9
|
end
|
|
8
|
-
|
|
9
|
-
def decode(str)
|
|
10
|
-
Faraday::NestedParamsEncoder.decode(str)
|
|
11
|
-
end
|
|
12
10
|
end
|
|
13
11
|
end
|
|
@@ -7,7 +7,7 @@ module Qa::Authorities
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def build_query_url(q)
|
|
10
|
-
"
|
|
10
|
+
"#{getty_vocab_url}/sparql.json?query=#{ERB::Util.url_encode(sparql(q))}&_implicit=false&implicit=true&_equivalent=false&_form=%2Fsparql"
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def sparql(q) # rubocop:disable Metrics/MethodLength
|
|
@@ -38,7 +38,7 @@ module Qa::Authorities
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def find_url(id)
|
|
41
|
-
"
|
|
41
|
+
"#{getty_vocab_url}/download/json?uri=#{getty_vocab_url}/aat/#{id}.json"
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def request_options
|
|
@@ -58,5 +58,13 @@ module Qa::Authorities
|
|
|
58
58
|
Rails.logger.warn " ERROR fetching Getty response: #{e.message}; cause: #{cause}"
|
|
59
59
|
{}
|
|
60
60
|
end
|
|
61
|
+
|
|
62
|
+
def linked_data_authority_configs
|
|
63
|
+
Qa.config.linked_data_authority_configs
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def getty_vocab_url
|
|
67
|
+
@getty_vocab_url ||= linked_data_authority_configs.dig(:GETTY_AAC, :search, :urls, :getty_vocab_url) || 'https://vocab.getty.edu'
|
|
68
|
+
end
|
|
61
69
|
end
|
|
62
70
|
end
|
|
@@ -22,7 +22,7 @@ module Qa::Authorities::LocSubauthority
|
|
|
22
22
|
return "authorities" if authorities.include?(authority)
|
|
23
23
|
return "vocabulary" if vocabularies.include?(authority)
|
|
24
24
|
return "datatype" if datatypes.include?(authority)
|
|
25
|
-
|
|
25
|
+
"vocabulary/preservation" if preservation.include?(authority)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def authorities
|
|
@@ -47,6 +47,7 @@ module Qa::Authorities::LocSubauthority
|
|
|
47
47
|
"languages",
|
|
48
48
|
"iso639-1",
|
|
49
49
|
"iso639-2",
|
|
50
|
+
"iso639-3",
|
|
50
51
|
"iso639-5",
|
|
51
52
|
"preservation",
|
|
52
53
|
"actionsGranted",
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
module Qa::Authorities
|
|
2
2
|
module Local
|
|
3
3
|
class Registry
|
|
4
|
+
delegate :keys, :fetch, to: :@hash
|
|
5
|
+
|
|
4
6
|
def initialize
|
|
5
7
|
@hash = {}
|
|
6
8
|
yield self if block_given?
|
|
7
9
|
end
|
|
8
10
|
|
|
9
|
-
def keys
|
|
10
|
-
@hash.keys
|
|
11
|
-
end
|
|
12
|
-
|
|
13
11
|
def instance_for(key)
|
|
14
12
|
fetch(key).instance
|
|
15
13
|
end
|
|
16
14
|
|
|
17
|
-
def fetch(key)
|
|
18
|
-
@hash.fetch(key)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
15
|
def self.logger
|
|
22
16
|
@logger ||= ::Rails.logger if defined? Rails && Rails.respond_to?(:logger)
|
|
23
17
|
end
|
data/lib/qa/engine.rb
CHANGED
|
@@ -17,5 +17,12 @@ module Qa
|
|
|
17
17
|
Rails.autoloaders.main.ignore(Rails.root.join('lib', 'generators'))
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
# Allow main application to configure deprecation behavior
|
|
22
|
+
if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1.0')
|
|
23
|
+
initializer "qa.deprecator" do |app|
|
|
24
|
+
app.deprecators[:qa] = Qa.deprecator
|
|
25
|
+
end
|
|
26
|
+
end
|
|
20
27
|
end
|
|
21
28
|
end
|
data/lib/qa/version.rb
CHANGED
data/lib/qa.rb
CHANGED
|
@@ -25,10 +25,22 @@ module Qa
|
|
|
25
25
|
@config
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
def self.deprecator
|
|
29
|
+
@deprecator ||= deprecator_instance
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# TODO: refactor when support for Rails < 7.1.0 is dropped
|
|
33
|
+
def self.deprecator_instance
|
|
34
|
+
if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1.0')
|
|
35
|
+
ActiveSupport::Deprecation.new("6.0.0", "Qa")
|
|
36
|
+
else
|
|
37
|
+
Rails.logger
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
28
41
|
def self.deprecation_warning(in_msg: nil, msg:)
|
|
29
|
-
return if Rails.env == 'test'
|
|
30
42
|
in_msg = in_msg.present? ? "In #{in_msg}, " : ''
|
|
31
|
-
warn "
|
|
43
|
+
deprecator.warn "#{in_msg}#{msg} It will be removed in the next major release."
|
|
32
44
|
end
|
|
33
45
|
|
|
34
46
|
# Raised when the authority is not valid
|
data/lib/tasks/mesh.rake
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require 'benchmark'
|
|
2
|
-
|
|
3
1
|
namespace :qa do
|
|
4
2
|
namespace :mesh do
|
|
5
3
|
desc "Import MeSH terms from the file $MESH_FILE, it will update any terms which are already in the database"
|
|
6
4
|
task import: :environment do
|
|
5
|
+
require 'benchmark' # may require you to add benchmark dependency in ruby 4+
|
|
6
|
+
|
|
7
7
|
fname = ENV['MESH_FILE']
|
|
8
8
|
if fname.nil?
|
|
9
9
|
puts "Need to set $MESH_FILE with path to file to ingest"
|
|
@@ -32,7 +32,7 @@ describe Qa::TermsController, type: :controller do
|
|
|
32
32
|
msg = "Unable to initialize sub-authority non-existent-subauthority for Qa::Authorities::Loc. Valid sub-authorities are " \
|
|
33
33
|
"[\"subjects\", \"names\", \"classification\", \"childrensSubjects\", \"genreForms\", \"performanceMediums\", " \
|
|
34
34
|
"\"graphicMaterials\", \"organizations\", \"relators\", \"countries\", \"ethnographicTerms\", \"geographicAreas\", " \
|
|
35
|
-
"\"languages\", \"iso639-1\", \"iso639-2\", \"iso639-5\", \"preservation\", \"actionsGranted\", \"agentType\", " \
|
|
35
|
+
"\"languages\", \"iso639-1\", \"iso639-2\", \"iso639-3\", \"iso639-5\", \"preservation\", \"actionsGranted\", \"agentType\", " \
|
|
36
36
|
"\"edtf\", \"contentLocationType\", \"copyrightStatus\", \"cryptographicHashFunctions\", " \
|
|
37
37
|
"\"environmentCharacteristic\", \"environmentPurpose\", \"eventRelatedAgentRole\", \"eventRelatedObjectRole\", " \
|
|
38
38
|
"\"eventType\", \"formatRegistryRole\", \"hardwareType\", \"inhibitorTarget\", \"inhibitorType\", \"objectCategory\", " \
|
|
@@ -5,12 +5,12 @@ describe Qa::Authorities::Getty::AAT do
|
|
|
5
5
|
|
|
6
6
|
describe "#build_query_url" do
|
|
7
7
|
subject { authority.build_query_url("foo") }
|
|
8
|
-
it { is_expected.to match(/^
|
|
8
|
+
it { is_expected.to match(/^https:\/\/vocab\.getty\.edu\//) }
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
describe "#find_url" do
|
|
12
12
|
subject { authority.find_url("300053264") }
|
|
13
|
-
it { is_expected.to eq "
|
|
13
|
+
it { is_expected.to eq "https://vocab.getty.edu/download/json?uri=https://vocab.getty.edu/aat/300053264.json" }
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
describe "#search" do
|
|
@@ -62,7 +62,7 @@ describe Qa::Authorities::Getty::AAT do
|
|
|
62
62
|
describe "#find" do
|
|
63
63
|
context "using a subject id" do
|
|
64
64
|
before do
|
|
65
|
-
stub_request(:get, "
|
|
65
|
+
stub_request(:get, "https://vocab.getty.edu/download/json?uri=https://vocab.getty.edu/aat/300265560.json")
|
|
66
66
|
.to_return(status: 200, body: webmock_fixture("getty-aat-find-response.json"))
|
|
67
67
|
end
|
|
68
68
|
subject { authority.find("300265560") }
|
|
@@ -74,8 +74,7 @@ RSpec.describe Qa::LinkedData::ResponseHeaderService do
|
|
|
74
74
|
|
|
75
75
|
describe '#fetch_header' do
|
|
76
76
|
let(:request_header) do
|
|
77
|
-
{
|
|
78
|
-
}.with_indifferent_access
|
|
77
|
+
{}.with_indifferent_access
|
|
79
78
|
end
|
|
80
79
|
let(:term_config) { double }
|
|
81
80
|
let(:graph) { instance_double(RDF::Graph) }
|
|
@@ -26,4 +26,13 @@ group :development do
|
|
|
26
26
|
gem 'concurrent-ruby', '1.3.4'
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
# multi_json 1.19.x / json 2.19.x interaction causes
|
|
30
|
+
# RDF::Graph#dump(:jsonld, standard_prefixes: true) to raise:
|
|
31
|
+
# NoMethodError: undefined method `except' for JSON::Ext::Generator::State
|
|
32
|
+
# in e.g. lib/qa/authorities/linked_data/find_term.rb and
|
|
33
|
+
# lib/qa/authorities/discogs/discogs_translation.rb
|
|
34
|
+
if RUBY_VERSION =~ /^3\.[01]\./
|
|
35
|
+
gem "multi_json", ">= 1.17", "< 1.19"
|
|
36
|
+
end
|
|
37
|
+
|
|
29
38
|
end
|
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.17.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: 2026-06-22 00:00:00.000000000 Z
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
22
22
|
name: activerecord-import
|
|
@@ -32,20 +32,6 @@ dependencies:
|
|
|
32
32
|
- - ">="
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
34
|
version: '0'
|
|
35
|
-
- !ruby/object:Gem::Dependency
|
|
36
|
-
name: deprecation
|
|
37
|
-
requirement: !ruby/object:Gem::Requirement
|
|
38
|
-
requirements:
|
|
39
|
-
- - ">="
|
|
40
|
-
- !ruby/object:Gem::Version
|
|
41
|
-
version: '0'
|
|
42
|
-
type: :runtime
|
|
43
|
-
prerelease: false
|
|
44
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
45
|
-
requirements:
|
|
46
|
-
- - ">="
|
|
47
|
-
- !ruby/object:Gem::Version
|
|
48
|
-
version: '0'
|
|
49
35
|
- !ruby/object:Gem::Dependency
|
|
50
36
|
name: faraday
|
|
51
37
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -414,6 +400,7 @@ files:
|
|
|
414
400
|
- app/views/layouts/qa/application.html.erb
|
|
415
401
|
- config/authorities.yml
|
|
416
402
|
- config/authorities/assign_fast/oclc_assign_fast.json
|
|
403
|
+
- config/authorities/linked_data/getty_aac.json
|
|
417
404
|
- config/authorities/linked_data/loc.json
|
|
418
405
|
- config/authorities/linked_data/oclc_fast.json
|
|
419
406
|
- config/authorities/states.yml
|
|
@@ -476,7 +463,6 @@ files:
|
|
|
476
463
|
- lib/qa/authorities/geonames.rb
|
|
477
464
|
- lib/qa/authorities/getty.rb
|
|
478
465
|
- lib/qa/authorities/getty/aat.rb
|
|
479
|
-
- lib/qa/authorities/getty/aat2.rb
|
|
480
466
|
- lib/qa/authorities/getty/tgn.rb
|
|
481
467
|
- lib/qa/authorities/getty/ulan.rb
|
|
482
468
|
- lib/qa/authorities/linked_data.rb
|
|
@@ -681,7 +667,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
681
667
|
- !ruby/object:Gem::Version
|
|
682
668
|
version: '0'
|
|
683
669
|
requirements: []
|
|
684
|
-
rubygems_version: 3.
|
|
670
|
+
rubygems_version: 3.5.22
|
|
685
671
|
signing_key:
|
|
686
672
|
specification_version: 4
|
|
687
673
|
summary: You should question your authorities.
|
|
@@ -1,62 +0,0 @@
|
|
|
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.presence || 'UNKNOWN'
|
|
58
|
-
Rails.logger.warn " ERROR fetching Getty response: #{e.message}; cause: #{cause}"
|
|
59
|
-
{}
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|