qa 5.14.0 → 5.15.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/config/authorities/assign_fast/oclc_assign_fast.json +6 -0
- data/lib/qa/authorities/assign_fast/generic_authority.rb +16 -1
- data/lib/qa/configuration.rb +2 -2
- data/lib/qa/linked_data/authority_service.rb +34 -14
- data/lib/qa/version.rb +1 -1
- data/spec/controllers/terms_controller_spec.rb +1 -1
- data/spec/lib/authorities/assign_fast_spec.rb +3 -3
- data/spec/test_app_templates/Gemfile.extra +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11cbb13006d50dd1457c8782b84f49a677717302d43a3978e3629670ac9ec433
|
4
|
+
data.tar.gz: 72c2de2f8114cc9df223ef68eeac9f3ff9046a74c87dd93103a3461d24c2c15e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30f799610d3d6980f0e33d3b5fcb2364e9c0019c18f8a12f5474dd22a82ccb865f95cc5f4d49da70df2246fda033ab17ea20dd3da554c220b881841d2a64c1bf
|
7
|
+
data.tar.gz: cc3c22f2e7cb940eff5f7f3d398090ae2caaff78840a81eff1ea9e229d1db2c2a17673617e0cd12fd9aef1a6ffa30128accf66cf8eaa1537b0df901e1847ceac
|
@@ -19,6 +19,7 @@ module Qa::Authorities
|
|
19
19
|
Faraday.get(url) do |req|
|
20
20
|
req.options.params_encoder = space_fix_encoder
|
21
21
|
req.headers['Accept'] = 'application/json'
|
22
|
+
req.options.timeout = connection_timeout_in_seconds unless connection_timeout_in_seconds.nil?
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
@@ -49,11 +50,25 @@ module Qa::Authorities
|
|
49
50
|
|
50
51
|
# sort=usage+desc is not documented by OCLC but seems necessary to get the sort
|
51
52
|
# we formerly got without specifying, that is most useful in our use case.
|
52
|
-
"
|
53
|
+
"#{assign_fast_url}?&query=#{escaped_query}&queryIndex=#{index}&queryReturn=#{return_data}&suggest=autoSubject&rows=#{num_rows}&sort=usage+desc"
|
53
54
|
end
|
54
55
|
|
55
56
|
private
|
56
57
|
|
58
|
+
# See https://github.com/samvera/questioning_authority/wiki/Connecting-to-OCLC-FAST
|
59
|
+
# for more info about config settings for this authority.
|
60
|
+
def assign_fast_config
|
61
|
+
Qa.config.assign_fast_authority_configs
|
62
|
+
end
|
63
|
+
|
64
|
+
def connection_timeout_in_seconds
|
65
|
+
assign_fast_config.dig(:OCLC_ASSIGN_FAST, :search, :connection, :timeout)&.to_i
|
66
|
+
end
|
67
|
+
|
68
|
+
def assign_fast_url
|
69
|
+
assign_fast_config.dig(:OCLC_ASSIGN_FAST, :search, :urls, :fastsuggest) || 'https://fast.oclc.org/searchfast/fastsuggest'
|
70
|
+
end
|
71
|
+
|
57
72
|
# Removes characters from the query string that are not tolerated by the API
|
58
73
|
# See oclc sample code at
|
59
74
|
# http://experimental.worldcat.org/fast/assignfast/js/assignFASTComplete.js
|
data/lib/qa/configuration.rb
CHANGED
@@ -28,8 +28,8 @@ module Qa
|
|
28
28
|
token == authorized_reload_token
|
29
29
|
end
|
30
30
|
|
31
|
-
# Hold
|
32
|
-
attr_accessor :linked_data_authority_configs
|
31
|
+
# Hold authority configs
|
32
|
+
attr_accessor :linked_data_authority_configs, :assign_fast_authority_configs
|
33
33
|
|
34
34
|
# For linked data access, specify default language for sorting and selection. The default is only used if a language is not
|
35
35
|
# specified in the authority's configuration file and not passed in as a parameter. (e.g. :en, [:en], or [:en, :fr])
|
@@ -2,25 +2,45 @@
|
|
2
2
|
module Qa
|
3
3
|
module LinkedData
|
4
4
|
class AuthorityService
|
5
|
-
# Load or reload the linked data configuration files
|
6
5
|
def self.load_authorities
|
7
|
-
|
8
|
-
|
6
|
+
load_linked_data_config
|
7
|
+
load_assign_fast_config
|
8
|
+
end
|
9
|
+
|
10
|
+
# Load or reload the linked data configuration files
|
11
|
+
def self.load_linked_data_config
|
12
|
+
ld_auth_cfg = {}
|
13
|
+
# Linked data settings
|
9
14
|
Dir[File.join(Qa::Engine.root, 'config', 'authorities', 'linked_data', '*.json')].each do |fn|
|
10
|
-
|
11
|
-
json = File.read(File.expand_path(fn, __FILE__))
|
12
|
-
cfg = JSON.parse(json).deep_symbolize_keys
|
13
|
-
auth_cfg[auth] = cfg
|
15
|
+
process_config_file(file_path: fn, config_hash: ld_auth_cfg)
|
14
16
|
end
|
15
|
-
|
16
|
-
# load app configured linked data authorities and overrides
|
17
|
+
# Optional local (app) linked data settings overrides
|
17
18
|
Dir[Rails.root.join('config', 'authorities', 'linked_data', '*.json')].each do |fn|
|
18
|
-
|
19
|
-
json = File.read(File.expand_path(fn, __FILE__))
|
20
|
-
cfg = JSON.parse(json).deep_symbolize_keys
|
21
|
-
auth_cfg[auth] = cfg
|
19
|
+
process_config_file(file_path: fn, config_hash: ld_auth_cfg)
|
22
20
|
end
|
23
|
-
Qa.config.linked_data_authority_configs =
|
21
|
+
Qa.config.linked_data_authority_configs = ld_auth_cfg
|
22
|
+
end
|
23
|
+
|
24
|
+
# similar to the above; these settings are for getting (non-linked-data) FAST subject headings from OCLC.
|
25
|
+
def self.load_assign_fast_config
|
26
|
+
assign_fast_auth_cfg = {}
|
27
|
+
# assign_fast settings
|
28
|
+
Dir[File.join(Qa::Engine.root, 'config', 'authorities', 'assign_fast', '*.json')].each do |fn|
|
29
|
+
process_config_file(file_path: fn, config_hash: assign_fast_auth_cfg)
|
30
|
+
end
|
31
|
+
# Optional local (app) assign_fast settings overrides
|
32
|
+
Dir[Rails.root.join('config', 'authorities', 'assign_fast', '*.json')].each do |fn|
|
33
|
+
process_config_file(file_path: fn, config_hash: assign_fast_auth_cfg)
|
34
|
+
end
|
35
|
+
Qa.config.assign_fast_authority_configs = assign_fast_auth_cfg
|
36
|
+
end
|
37
|
+
|
38
|
+
# load settings into a configuration hash:
|
39
|
+
def self.process_config_file(file_path:, config_hash:)
|
40
|
+
file_key = File.basename(file_path, '.json').upcase.to_sym
|
41
|
+
json = File.read(File.expand_path(file_path, __FILE__))
|
42
|
+
cfg = JSON.parse(json).deep_symbolize_keys
|
43
|
+
config_hash[file_key] = cfg
|
24
44
|
end
|
25
45
|
|
26
46
|
# Get the list of names of the loaded authorities
|
data/lib/qa/version.rb
CHANGED
@@ -199,7 +199,7 @@ describe Qa::TermsController, type: :controller do
|
|
199
199
|
|
200
200
|
context "assign_fast" do
|
201
201
|
before do
|
202
|
-
stub_request(:get, "
|
202
|
+
stub_request(:get, "https://fast.oclc.org/searchfast/fastsuggest?query=word&queryIndex=suggest50&queryReturn=suggest50,idroot,auth,type&rows=20&suggest=autoSubject&sort=usage+desc")
|
203
203
|
.with(headers: { 'Accept' => 'application/json' })
|
204
204
|
.to_return(body: webmock_fixture("assign-fast-topical-result.json"), status: 200, headers: {})
|
205
205
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Qa::Authorities::AssignFast do
|
4
4
|
let(:query) { "word (ling" }
|
5
|
-
let(:expected_url) { "
|
5
|
+
let(:expected_url) { "https://fast.oclc.org/searchfast/fastsuggest?&query=word%20ling&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20&sort=usage+desc" }
|
6
6
|
|
7
7
|
# subauthority infrastructure
|
8
8
|
describe "#new" do
|
@@ -60,7 +60,7 @@ describe Qa::Authorities::AssignFast do
|
|
60
60
|
|
61
61
|
context "when query is blank" do
|
62
62
|
let(:query) { "" }
|
63
|
-
let(:expected_url) { "
|
63
|
+
let(:expected_url) { "https://fast.oclc.org/searchfast/fastsuggest?&query=&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20&sort=usage+desc" }
|
64
64
|
|
65
65
|
# server returns results but no results header
|
66
66
|
let :results do
|
@@ -104,7 +104,7 @@ describe Qa::Authorities::AssignFast do
|
|
104
104
|
|
105
105
|
context "with topical results" do
|
106
106
|
let(:query) { "word" }
|
107
|
-
let(:expected_url) { "
|
107
|
+
let(:expected_url) { "https://fast.oclc.org/searchfast/fastsuggest?query=word&queryIndex=suggest50&queryReturn=suggest50,idroot,auth,type&rows=20&suggest=autoSubject&sort=usage+desc" }
|
108
108
|
|
109
109
|
let :results do
|
110
110
|
stub_request(:get, expected_url)
|
@@ -21,4 +21,9 @@ group :development do
|
|
21
21
|
# See https://stackoverflow.com/questions/70500220/rails-7-ruby-3-1-loaderror-cannot-load-such-file-net-smtp
|
22
22
|
gem 'net-smtp', require: false
|
23
23
|
end
|
24
|
+
|
25
|
+
if Gem::Version.new(ENV['RAILS_VERSION']) < Gem::Version.new('7.1')
|
26
|
+
gem 'concurrent-ruby', '1.3.4'
|
27
|
+
end
|
28
|
+
|
24
29
|
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.15.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: 2025-06-02 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activerecord-import
|
@@ -413,6 +413,7 @@ files:
|
|
413
413
|
- app/services/qa/pagination_service.rb
|
414
414
|
- app/views/layouts/qa/application.html.erb
|
415
415
|
- config/authorities.yml
|
416
|
+
- config/authorities/assign_fast/oclc_assign_fast.json
|
416
417
|
- config/authorities/linked_data/loc.json
|
417
418
|
- config/authorities/linked_data/oclc_fast.json
|
418
419
|
- config/authorities/states.yml
|