berkeley_library-location 4.0.0 → 4.2.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/CHANGES.md +9 -0
- data/lib/berkeley_library/location/location_result.rb +4 -4
- data/lib/berkeley_library/location/module_info.rb +1 -1
- data/lib/berkeley_library/location/world_cat/oclc_auth.rb +20 -16
- data/lib/berkeley_library/location/world_cat/symbols.rb +4 -4
- data/lib/berkeley_library/location/xlsx_writer.rb +19 -19
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a6dde9a8798f652024e00893fac655ad39c401ec14df226aa6b67c52d22d2527
|
|
4
|
+
data.tar.gz: dc766bed8dedfe4e1f46fa2c9fd9ffe9f20a114815813e7d265d4c0bcd27dd4c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 437efa3af98fe1fad98146917f1ab05e8470a4eacd70f50aa72ddda3e58ddaea236e6fe3c71e1a44a3a5f242b3564806917ba60b3b7e015cc707cb50561374d8
|
|
7
|
+
data.tar.gz: 123e84b09716817c7691bab9279e0908bc0e99b6fd6502c556f8df096bd028794ea6a3289f29b785d276be028b726e01d7905db62be7a3d230a22d420f441175
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
# 4.2.0 (2026-01-06)
|
|
2
|
+
|
|
3
|
+
- Rename RLF to SLF (NRLF -> SLFN, SRLF -> SLFS)
|
|
4
|
+
- Added bypass to skip SSL verification ONLY when recording new VCR cassettes
|
|
5
|
+
|
|
6
|
+
# 4.1.0 (2025-01-10)
|
|
7
|
+
|
|
8
|
+
- Fixed token refresh function and test
|
|
9
|
+
|
|
1
10
|
# 4.0.0 (2025-01-08)
|
|
2
11
|
|
|
3
12
|
- Update from Worldcat API v1 to API v2
|
|
@@ -13,12 +13,12 @@ module BerkeleyLibrary
|
|
|
13
13
|
@ht_error = ht_error
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def
|
|
17
|
-
@
|
|
16
|
+
def slfn?
|
|
17
|
+
@has_slfn ||= wc_symbols.intersection(WorldCat::Symbols::SLFN).any?
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def
|
|
21
|
-
@
|
|
20
|
+
def slfs?
|
|
21
|
+
@has_slfs ||= wc_symbols.intersection(WorldCat::Symbols::SLFS).any?
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def uc_symbols
|
|
@@ -7,7 +7,7 @@ module BerkeleyLibrary
|
|
|
7
7
|
SUMMARY = 'Locaton-related utilities for the UC Berkeley Library'.freeze
|
|
8
8
|
DESCRIPTION = 'A collection of location-related utilities for the UC Berkeley Library'.freeze
|
|
9
9
|
LICENSE = 'MIT'.freeze
|
|
10
|
-
VERSION = '4.
|
|
10
|
+
VERSION = '4.2.0'.freeze
|
|
11
11
|
HOMEPAGE = 'https://github.com/BerkeleyLibrary/location'.freeze
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -10,42 +10,46 @@ module BerkeleyLibrary
|
|
|
10
10
|
attr_accessor :token
|
|
11
11
|
|
|
12
12
|
def initialize
|
|
13
|
+
# Sorry Rubocop - needs to be ||= because we're dealing with a singleton
|
|
13
14
|
# rubocop:disable Lint/DisjunctiveAssignmentInConstructor
|
|
14
15
|
@token ||= fetch_token
|
|
15
16
|
# rubocop:enable Lint/DisjunctiveAssignmentInConstructor:
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def fetch_token
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
http = Net::HTTP.new(url.host, url.port)
|
|
22
|
-
http.use_ssl = url.scheme == 'https'
|
|
23
|
-
|
|
24
|
-
request = Net::HTTP::Post.new(url.request_uri)
|
|
25
|
-
request.basic_auth(Config.api_key, Config.api_secret)
|
|
26
|
-
request['Accept'] = 'application/json'
|
|
27
|
-
response = http.request(request)
|
|
28
|
-
|
|
20
|
+
response = http_request(oclc_token_url)
|
|
29
21
|
JSON.parse(response.body, symbolize_names: true)
|
|
30
22
|
end
|
|
31
23
|
|
|
32
|
-
# def token
|
|
33
|
-
# @token = get_token if token_expired?
|
|
34
|
-
# @token
|
|
35
|
-
# end
|
|
36
|
-
|
|
37
24
|
def oclc_token_url
|
|
38
25
|
URI.parse("#{Config.token_uri}?#{URI.encode_www_form(token_params)}")
|
|
39
26
|
end
|
|
40
27
|
|
|
41
28
|
# Before every request check if the token is expired (OCLC tokens expire after 20 minutes)
|
|
42
29
|
def access_token
|
|
43
|
-
@token =
|
|
30
|
+
@token = fetch_token if token_expired?
|
|
44
31
|
@token[:access_token]
|
|
45
32
|
end
|
|
46
33
|
|
|
47
34
|
private
|
|
48
35
|
|
|
36
|
+
def http_request(url)
|
|
37
|
+
http = build_http(url)
|
|
38
|
+
request = Net::HTTP::Post.new(url.request_uri)
|
|
39
|
+
request.basic_auth(Config.api_key, Config.api_secret)
|
|
40
|
+
request['Accept'] = 'application/json'
|
|
41
|
+
http.request(request)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def build_http(url)
|
|
45
|
+
http = Net::HTTP.new(url.host, url.port)
|
|
46
|
+
http.use_ssl = url.scheme == 'https'
|
|
47
|
+
|
|
48
|
+
# Skip SSL verification ONLY when recording new VCR cassettes
|
|
49
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if ENV['RE_RECORD_VCR'] == 'true'
|
|
50
|
+
http
|
|
51
|
+
end
|
|
52
|
+
|
|
49
53
|
def token_params
|
|
50
54
|
{
|
|
51
55
|
grant_type: 'client_credentials',
|
|
@@ -2,12 +2,12 @@ module BerkeleyLibrary
|
|
|
2
2
|
module Location
|
|
3
3
|
module WorldCat
|
|
4
4
|
module Symbols
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
SLFN = %w[ZAP ZAPSP].freeze
|
|
6
|
+
SLFS = %w[HH0 ZAS ZASSP].freeze
|
|
7
|
+
SLF = (SLFN + SLFS).freeze
|
|
8
8
|
|
|
9
9
|
UC = %w[CLU CRU CUI CUN CUS CUT CUV CUX CUY CUZ MERUC].freeze
|
|
10
|
-
ALL = (
|
|
10
|
+
ALL = (SLF + UC).freeze
|
|
11
11
|
|
|
12
12
|
class << self
|
|
13
13
|
include Symbols
|
|
@@ -7,22 +7,22 @@ module BerkeleyLibrary
|
|
|
7
7
|
include Constants
|
|
8
8
|
include BerkeleyLibrary::Logging
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
COL_SLFN = 'SLFN'.freeze
|
|
11
|
+
COL_SLFS = 'SLFS'.freeze
|
|
12
12
|
COL_OTHER_UC = 'Other UC'.freeze
|
|
13
13
|
COL_WC_ERROR = 'WorldCat Error'.freeze
|
|
14
14
|
|
|
15
15
|
COL_HATHI_TRUST = 'Hathi Trust'.freeze
|
|
16
16
|
COL_HATHI_TRUST_ERROR = "#{COL_HATHI_TRUST} Error".freeze
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
V_SLFN = 'slfn'.freeze
|
|
19
|
+
V_SLFS = 'slfs'.freeze
|
|
20
20
|
|
|
21
|
-
attr_reader :ss, :
|
|
21
|
+
attr_reader :ss, :slf, :uc, :hathi_trust
|
|
22
22
|
|
|
23
|
-
def initialize(ss,
|
|
23
|
+
def initialize(ss, slf: true, uc: true, hathi_trust: true)
|
|
24
24
|
@ss = ss
|
|
25
|
-
@
|
|
25
|
+
@slf = slf
|
|
26
26
|
@uc = uc
|
|
27
27
|
@hathi_trust = hathi_trust
|
|
28
28
|
|
|
@@ -32,7 +32,7 @@ module BerkeleyLibrary
|
|
|
32
32
|
def <<(result)
|
|
33
33
|
r_indices = row_indices_for(result.oclc_number)
|
|
34
34
|
r_indices.each do |idx|
|
|
35
|
-
write_wc_cols(idx, result) if
|
|
35
|
+
write_wc_cols(idx, result) if slf || uc
|
|
36
36
|
write_ht_cols(idx, result) if hathi_trust
|
|
37
37
|
end
|
|
38
38
|
end
|
|
@@ -41,7 +41,7 @@ module BerkeleyLibrary
|
|
|
41
41
|
|
|
42
42
|
def write_wc_cols(r_index, result)
|
|
43
43
|
write_wc_error(r_index, result)
|
|
44
|
-
|
|
44
|
+
write_slf(r_index, result) if slf
|
|
45
45
|
write_uc(r_index, result) if uc
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -51,9 +51,9 @@ module BerkeleyLibrary
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def ensure_columns!
|
|
54
|
-
if
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if slf
|
|
55
|
+
slfn_col_index
|
|
56
|
+
slfs_col_index
|
|
57
57
|
end
|
|
58
58
|
uc_col_index if uc
|
|
59
59
|
ht_col_index if hathi_trust
|
|
@@ -66,9 +66,9 @@ module BerkeleyLibrary
|
|
|
66
66
|
raise ArgumentError, "Unknown OCLC number: #{oclc_number}"
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
def
|
|
70
|
-
ss.set_value_at(r_index,
|
|
71
|
-
ss.set_value_at(r_index,
|
|
69
|
+
def write_slf(r_index, result)
|
|
70
|
+
ss.set_value_at(r_index, slfn_col_index, V_SLFN) if result.slfn?
|
|
71
|
+
ss.set_value_at(r_index, slfs_col_index, V_SLFS) if result.slfs?
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def write_uc(r_index, result)
|
|
@@ -99,12 +99,12 @@ module BerkeleyLibrary
|
|
|
99
99
|
@oclc_col_index ||= ss.find_column_index_by_header!(OCLC_COL_HEADER)
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
def
|
|
103
|
-
@
|
|
102
|
+
def slfn_col_index
|
|
103
|
+
@slfn_col_index ||= ss.ensure_column!(COL_SLFN)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
def
|
|
107
|
-
@
|
|
106
|
+
def slfs_col_index
|
|
107
|
+
@slfs_col_index ||= ss.ensure_column!(COL_SLFS)
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
def uc_col_index
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: berkeley_library-location
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- UC Berkeley Library IT
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: berkeley_library-logging
|