qa 4.2.3 → 4.2.4

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: eba5e21a3c6692b86e9974f53a642c22fe4b15e6
4
- data.tar.gz: 5d62930818fc514a4e685f5480a15592f5c7c1d3
3
+ metadata.gz: 01ad19bed0c7676d2a803cdf50f3edb8f3786f88
4
+ data.tar.gz: 30f46f8326eabb8fc00e3e27dadd0f2d2c72d8fa
5
5
  SHA512:
6
- metadata.gz: c24bd0c98bb86cca3dbeb5d0889f017af4c97911bbaab33e2a413562f9ce954d6128042b3dd09647483990517d90ec0f6ac493a0fcae3277b215cc75613e4e21
7
- data.tar.gz: c81ee4a69c029942069d39a4b0cb5e3cb3b199abf65b94a7a57e29e5bf3eb9f999e67584a65b6b26d5ebed3790550e2870a7bce38087bd5409f13c2cb5f3abce
6
+ metadata.gz: 3ea728ae633c1a0f504f3d76ac7eb0bd1c353f35a2fdb174d3dcfa42a8798c5c18af88f1bef2d0224fe13b7b583a285f350e13ae78377d09b73b83c40c0505fc
7
+ data.tar.gz: e11d1a74bc87fc1d93b1c5a543ac10a928f3d8c562762b0ecd1e801851f14e26190d69ea532d67d760631c02c120e5970f90ff901595392a4b69c3ebadddc352
@@ -30,17 +30,16 @@ module Qa::Authorities
30
30
  # all we need is a work and not an instance. If there's no subauthority, we can determine
31
31
  # if the discogs record is a master because it will have a main_release field.
32
32
  if master_only(response, subauthority)
33
- self.work_uri = response["uri"]
33
+ self.work_uri = response["uri"].present? ? response["uri"] : response["resource_url"]
34
34
  complete_rdf_stmts.concat(build_master_statements(response))
35
35
  else
36
- # If the subauthority is not "master," we need to define an instance as well as a
36
+ # If the subauthority is "release," we need to define an instance as well as a
37
37
  # work. If the discogs record has a master_id, fetch that and use the results to
38
38
  # build the statements for the work.
39
39
  master_resp = response["master_id"].present? ? json("https://api.discogs.com/masters/#{response['master_id']}") : response
40
- self.work_uri = master_resp["uri"] if master_resp["uri"].present? && master_resp["uri"].include?("master")
41
40
  complete_rdf_stmts.concat(build_master_statements(master_resp))
42
- # Now do the statements for the instance.
43
- self.instance_uri = response["uri"] if response["uri"].present?
41
+ # Now do the statements for the release/instance.
42
+ self.instance_uri = response["uri"].present? ? response["uri"] : response["resource_url"]
44
43
  complete_rdf_stmts.concat(build_instance_statements(response))
45
44
  end
46
45
  end
@@ -93,7 +92,7 @@ module Qa::Authorities
93
92
  # @return [Array] rdf statements
94
93
  def get_primary_instance_definition(response)
95
94
  stmts = []
96
- stmts << contruct_stmt_uri_object(work_uri, "http://id.loc.gov/ontologies/bibframe/hasInstance", instance_uri)
95
+ stmts << contruct_stmt_uri_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/instanceOf", work_uri)
97
96
  stmts << contruct_stmt_uri_object(instance_uri, rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/Instance")
98
97
  stmts << contruct_stmt_uri_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/title", "titlen2")
99
98
  stmts << contruct_stmt_literal_object("titlen2", bf_main_title_predicate, response["title"])
@@ -12,8 +12,8 @@ module Qa::Authorities
12
12
  def initialize(subauthority)
13
13
  @subauthority = subauthority
14
14
  self.primary_artists = []
15
- self.work_uri = "http://generic.uri/workn1"
16
- self.instance_uri = "http://generic.uri/instn1"
15
+ self.work_uri = "workn1"
16
+ self.instance_uri = "instn1"
17
17
  end
18
18
 
19
19
  # @param [String] the query
@@ -127,13 +127,18 @@ module Qa::Authorities
127
127
  # }
128
128
  def parse_authority_response(response)
129
129
  response['results'].map do |result|
130
- { 'uri' => result['resource_url'].to_s,
130
+ { 'uri' => build_uri(result),
131
131
  'id' => result['id'].to_s,
132
132
  'label' => result['title'].to_s,
133
133
  'context' => assemble_search_context(result) }
134
134
  end
135
135
  end
136
136
 
137
+ # @param [Hash] the results hash from the JSON returned by Discogs
138
+ def build_uri(result)
139
+ result['uri'].present? ? "https://www.discogs.com" + result['uri'].to_s : result['resource_url'].to_s
140
+ end
141
+
137
142
  # @param [Hash] the results hash from the JSON returned by Discogs
138
143
  def assemble_search_context(result)
139
144
  { "Image URL" => get_context_for_string(result['cover_image']),
data/lib/qa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qa
2
- VERSION = "4.2.3".freeze
2
+ VERSION = "4.2.4".freeze
3
3
  end
@@ -1 +1 @@
1
- {"status":"Accepted","series":[],"labels":[{"name":"Blue Note"}],"year":1962,"artists":[{"name":"Dexter Gordon"}],"id":3380671,"genres":["Jazz"],"title":"A Swingin' Affair","styles":["Hard Bop"],"formats":[{"qty":"1","descriptions":["LP","Album","Mono"],"name":"Vinyl"}]}
1
+ {"status":"Accepted","series":[],"labels":[{"name":"Blue Note"}],"year":1962,"artists":[{"name":"Dexter Gordon"}],"id":3380671,"genres":["Jazz"],"title":"A Swingin' Affair","styles":["Hard Bop"],"formats":[{"qty":"1","descriptions":["LP","Album","Mono"],"name":"Vinyl"}],"uri":"https://www.discogs.com/Dexter-Gordon-A-Swingin-Affair/release/3380671","resource_url":"https://api.discogs.com/releases/3380671"}
@@ -273,7 +273,7 @@ describe Qa::Authorities::Discogs::GenericAuthority do
273
273
  end
274
274
 
275
275
  it "has id and label keys" do
276
- expect(results.first["uri"]).to eq("https://api.discogs.com/releases/1750352")
276
+ expect(results.first["uri"]).to eq("https://www.discogs.com/Melody-Gardot-Who-Will-Comfort-Me-Over-The-Rainbow/release/1750352")
277
277
  expect(results.first["id"]).to eq "1750352"
278
278
  expect(results.first["label"]).to eq "Melody Gardot - Who Will Comfort Me / Over The Rainbow"
279
279
  expect(results.first["context"]["Year"]).to eq ['2009']
@@ -296,7 +296,7 @@ describe Qa::Authorities::Discogs::GenericAuthority do
296
296
  end
297
297
 
298
298
  it "has id and label keys" do
299
- expect(results.first['uri']).to eq "https://api.discogs.com/masters/606116"
299
+ expect(results.first['uri']).to eq "https://www.discogs.com/Wes-Montgomery-Bumpin-On-Sunset-Tequila/master/606116"
300
300
  expect(results.first['id']).to eq "606116"
301
301
  expect(results.first['label']).to eq "Wes Montgomery - Bumpin' On Sunset / Tequila"
302
302
  expect(results.first['context']["Year"]).to eq ['1966']
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.2.3
4
+ version: 4.2.4
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: 2019-10-10 00:00:00.000000000 Z
19
+ date: 2019-10-17 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: activerecord-import