qa 0.10.2 → 0.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/app/controllers/qa/terms_controller.rb +1 -1
- data/lib/qa/authorities/assign_fast/generic_authority.rb +10 -0
- data/lib/qa/authorities/assign_fast/space_fix_encoder.rb +13 -0
- data/lib/qa/version.rb +1 -1
- data/spec/controllers/terms_controller_spec.rb +20 -0
- data/spec/lib/authorities/space_fix_encoder.rb +11 -0
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 480d64287a822e05e82705e1ff868e963c65cd24
|
4
|
+
data.tar.gz: dc6f5d1daf37f5618a5c39fc10f239c1c4bdad0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f766d2479209faf8b67ec4bb682f8dc820b774eb4e8404eaca6910c50137cf4f70ac858f3f8accfa3508525f64025d9de578dfa737a9d814ee6c2c4237c04005
|
7
|
+
data.tar.gz: 9515a364e8d1bf4f0dbfafe45affbdf07257c8617b0b752052c9cbec76d1d562750aa666f32f16c7d7113d3db4e2c03a941796b78c320612b4087eca022cce68
|
@@ -14,7 +14,7 @@ class Qa::TermsController < ApplicationController
|
|
14
14
|
|
15
15
|
# Return a list of terms based on a query
|
16
16
|
def search
|
17
|
-
terms = @authority.search(url_search)
|
17
|
+
terms = @authority.method(:search).arity == 2 ? @authority.search(url_search, self) : @authority.search(url_search)
|
18
18
|
render json: terms
|
19
19
|
end
|
20
20
|
|
@@ -10,6 +10,16 @@ module Qa::Authorities
|
|
10
10
|
|
11
11
|
include WebServiceBase
|
12
12
|
|
13
|
+
require 'qa/authorities/assign_fast/space_fix_encoder'
|
14
|
+
# FAST requires spaces to be encoded as %20 and will not accept + which is Faraday's default encoding
|
15
|
+
def response(url)
|
16
|
+
space_fix_encoder = AssignFast::SpaceFixEncoder.new
|
17
|
+
Faraday.get(url) do |req|
|
18
|
+
req.options.params_encoder = space_fix_encoder
|
19
|
+
req.headers['Accept'] = 'application/json'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
13
23
|
# Search the FAST api
|
14
24
|
#
|
15
25
|
# @param [String] the query
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Qa::Authorities
|
2
|
+
# for use with Faraday; encode spaces as '%20' not '+'
|
3
|
+
class AssignFast::SpaceFixEncoder
|
4
|
+
def encode(hash)
|
5
|
+
encoded = Faraday::NestedParamsEncoder.encode(hash)
|
6
|
+
encoded.gsub('+', '%20')
|
7
|
+
end
|
8
|
+
|
9
|
+
def decode(str)
|
10
|
+
Faraday::NestedParamsEncoder.decode(str)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/qa/version.rb
CHANGED
@@ -47,6 +47,26 @@ describe Qa::TermsController, type: :controller do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
describe "#search" do
|
50
|
+
context "when a local authority expects two arguments" do
|
51
|
+
before do
|
52
|
+
class Qa::Authorities::Local::TwoArgs < Qa::Authorities::Base
|
53
|
+
attr_reader :subauthority
|
54
|
+
def initialize(subauthority)
|
55
|
+
@subauthority = subauthority
|
56
|
+
end
|
57
|
+
|
58
|
+
def search(_arg1, _arg2)
|
59
|
+
true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
Qa::Authorities::Local.register_subauthority('two_args', 'Qa::Authorities::Local::TwoArgs')
|
63
|
+
end
|
64
|
+
it "succeeds" do
|
65
|
+
get :search, q: "a query", vocab: "local", subauthority: "two_args"
|
66
|
+
expect(response).to be_success
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
50
70
|
context "loc" do
|
51
71
|
before do
|
52
72
|
stub_request(:get, "http://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names")
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Qa::Authorities::AssignFast::SpaceFixEncoder do
|
4
|
+
let(:encoder) { described_class.new }
|
5
|
+
|
6
|
+
it 'encodes spaces as %20 instead of +' do
|
7
|
+
input = { "query" => "word ling", "queryIndex" => "suggestall", "queryReturn" => "suggestall,idroot,auth,type", "suggest" => "autoSubject", "rows" => "20" }
|
8
|
+
expected = "query=word%20ling&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&rows=20&suggest=autoSubject"
|
9
|
+
expect(encoder.encode(input)).to eq expected
|
10
|
+
end
|
11
|
+
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: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Anderson
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date:
|
18
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|
@@ -57,14 +57,14 @@ dependencies:
|
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 1.6
|
60
|
+
version: '1.6'
|
61
61
|
type: :runtime
|
62
62
|
prerelease: false
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 1.6
|
67
|
+
version: '1.6'
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: activerecord-import
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,14 +211,14 @@ dependencies:
|
|
211
211
|
requirements:
|
212
212
|
- - "~>"
|
213
213
|
- !ruby/object:Gem::Version
|
214
|
-
version:
|
214
|
+
version: 1.8.0
|
215
215
|
type: :development
|
216
216
|
prerelease: false
|
217
217
|
version_requirements: !ruby/object:Gem::Requirement
|
218
218
|
requirements:
|
219
219
|
- - "~>"
|
220
220
|
- !ruby/object:Gem::Version
|
221
|
-
version:
|
221
|
+
version: 1.8.0
|
222
222
|
description: Provides a set of uniform RESTful routes to query any controlled vocabulary
|
223
223
|
or set of authority terms.
|
224
224
|
email:
|
@@ -260,6 +260,7 @@ files:
|
|
260
260
|
- lib/qa/authorities.rb
|
261
261
|
- lib/qa/authorities/assign_fast.rb
|
262
262
|
- lib/qa/authorities/assign_fast/generic_authority.rb
|
263
|
+
- lib/qa/authorities/assign_fast/space_fix_encoder.rb
|
263
264
|
- lib/qa/authorities/assign_fast_subauthority.rb
|
264
265
|
- lib/qa/authorities/authority_with_sub_authority.rb
|
265
266
|
- lib/qa/authorities/base.rb
|
@@ -329,6 +330,7 @@ files:
|
|
329
330
|
- spec/lib/authorities/mesh_spec.rb
|
330
331
|
- spec/lib/authorities/mysql_table_based_authority_spec.rb
|
331
332
|
- spec/lib/authorities/oclcts_spec.rb
|
333
|
+
- spec/lib/authorities/space_fix_encoder.rb
|
332
334
|
- spec/lib/authorities/table_based_authority_spec.rb
|
333
335
|
- spec/lib/authorities/tgnlang_spec.rb
|
334
336
|
- spec/lib/authorities_loc_subauthorities.rb
|
@@ -359,7 +361,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
359
361
|
version: '0'
|
360
362
|
requirements: []
|
361
363
|
rubyforge_project:
|
362
|
-
rubygems_version: 2.6.
|
364
|
+
rubygems_version: 2.6.8
|
363
365
|
signing_key:
|
364
366
|
specification_version: 4
|
365
367
|
summary: You should question your authorities.
|
@@ -402,6 +404,7 @@ test_files:
|
|
402
404
|
- spec/lib/authorities/mesh_spec.rb
|
403
405
|
- spec/lib/authorities/mysql_table_based_authority_spec.rb
|
404
406
|
- spec/lib/authorities/oclcts_spec.rb
|
407
|
+
- spec/lib/authorities/space_fix_encoder.rb
|
405
408
|
- spec/lib/authorities/table_based_authority_spec.rb
|
406
409
|
- spec/lib/authorities/tgnlang_spec.rb
|
407
410
|
- spec/lib/authorities_loc_subauthorities.rb
|