qa 4.0.0.rc2 → 4.0.0.rc3

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
2
  SHA1:
3
- metadata.gz: f973c50da7d6620ac328e37f5cdac7e57f272206
4
- data.tar.gz: 94f2320009030be3a989feb19d78e2a5a3cc89b2
3
+ metadata.gz: de32b8faa17be4ebfa99c1bde6b357cacb1beb3f
4
+ data.tar.gz: 5b1a2952d54233aedad9d2981113ac99d3279106
5
5
  SHA512:
6
- metadata.gz: 9b80b00632adfc5514009304394016012954cb7c5e4fe3b2cec4dcdf5b22140f88ff4c52c4c130271fdcfba04f11b6a5c18a941798ee077de99f96899f044bff
7
- data.tar.gz: d50bc77a2dbe1368b691349252b5889e80b2a7c04c6c1ead788f1d5f7a8e03d40adb514bacb1cc67baeb100e9b7eb03cd40723d13e36266cf05422b4bfcf868d
6
+ metadata.gz: 6436875ac41e2da533c468342247b85e2964176779378df25f2a8faab7426538d3ff4975d10bd392952aa68cde811ac7b6defb9564f644a35a889087d5a1a433
7
+ data.tar.gz: c5e8c5375474db838240a77507e2d08255614c26243eddb8945c70d659b3a219e3859ab312b2c9eaa836fcb133d2c15e5d7fca515ff91b97630e65d28536e004
@@ -68,11 +68,15 @@ module Qa::Authorities
68
68
  preds = { label: label_pred_uri }
69
69
  preds[:uri] = :subject_uri
70
70
  preds[:altlabel] = search_config.results_altlabel_predicate unless search_config.results_altlabel_predicate.nil?
71
- preds[:id] = search_config.results_id_predicate unless search_config.results_id_predicate.nil?
71
+ preds[:id] = id_predicate.present? ? id_predicate : :subject_uri
72
72
  preds[:sort] = sort_predicate.present? ? sort_predicate : preds[:label]
73
73
  preds
74
74
  end
75
75
 
76
+ def id_predicate
77
+ @id_predicate ||= search_config.results_id_predicate
78
+ end
79
+
76
80
  def sort_predicate
77
81
  @sort_predicate ||= search_config.results_sort_predicate
78
82
  end
@@ -86,7 +90,7 @@ module Qa::Authorities
86
90
  def convert_result_to_json(result)
87
91
  json_result = {}
88
92
  json_result[:uri] = result[:uri].first.to_s
89
- json_result[:id] = result[:id].first.to_s
93
+ json_result[:id] = result[:id].any? ? result[:id].first.to_s : ""
90
94
  json_result[:label] = full_label(result[:label], result[:altlabel])
91
95
  json_result[:context] = result[:context] if context?
92
96
  json_result
data/lib/qa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qa
2
- VERSION = "4.0.0.rc2".freeze
2
+ VERSION = "4.0.0.rc3".freeze
3
3
  end
@@ -43,7 +43,6 @@
43
43
  "query": "query"
44
44
  },
45
45
  "results": {
46
- "id_predicate": "http://purl.org/dc/terms/identifier",
47
46
  "label_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel"
48
47
  }
49
48
  }
@@ -58,6 +58,21 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
58
58
  end
59
59
  end
60
60
 
61
+ context 'when id predicate is not specified' do
62
+ let(:min_authority) { described_class.new(:LOD_MIN_CONFIG) }
63
+ let :results do
64
+ stub_request(:get, 'http://localhost/test_default/search?query=peanuts')
65
+ .to_return(status: 200, body: webmock_fixture('lod_oclc_personalName_query_3_results.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
66
+ min_authority.search('peanuts')
67
+ end
68
+ it 'uses subject uri for id' do
69
+ expect(results.count).to eq(3)
70
+ expect(results.first).to eq(uri: 'http://id.worldcat.org/fast/409667', id: 'http://id.worldcat.org/fast/409667', label: 'Cornell, Ezra, 1807-1874')
71
+ expect(results.second).to eq(uri: 'http://id.worldcat.org/fast/5140', id: 'http://id.worldcat.org/fast/5140', label: 'Cornell, Joseph')
72
+ expect(results.third).to eq(uri: 'http://id.worldcat.org/fast/72456', id: 'http://id.worldcat.org/fast/72456', label: 'Cornell, Sarah Maria, 1802-1832')
73
+ end
74
+ end
75
+
61
76
  # context 'in LOC authority' do
62
77
  # ###################################
63
78
  # ### SEARCH NOT SUPPORTED BY LOC ###
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: 4.0.0.rc2
4
+ version: 4.0.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Anderson