Skip to content

Commit c2d97ca

Browse files
Updates for RLF to SLF name change
1 parent 38d7103 commit c2d97ca

File tree

14 files changed

+204
-179
lines changed

14 files changed

+204
-179
lines changed

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
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+
16
# 4.1.0 (2025-01-10)
27

38
- Fixed token refresh function and test

lib/berkeley_library/location/location_result.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ def initialize(oclc_number, wc_symbols: [], wc_error: nil, ht_record_url: nil, h
1313
@ht_error = ht_error
1414
end
1515

16-
def nrlf?
17-
@has_nrlf ||= wc_symbols.intersection(WorldCat::Symbols::NRLF).any?
16+
def slfn?
17+
@has_slfn ||= wc_symbols.intersection(WorldCat::Symbols::SLFN).any?
1818
end
1919

20-
def srlf?
21-
@has_srlf ||= wc_symbols.intersection(WorldCat::Symbols::SRLF).any?
20+
def slfs?
21+
@has_slfs ||= wc_symbols.intersection(WorldCat::Symbols::SLFS).any?
2222
end
2323

2424
def uc_symbols

lib/berkeley_library/location/world_cat/oclc_auth.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ def fetch_token
2222
http = Net::HTTP.new(url.host, url.port)
2323
http.use_ssl = url.scheme == 'https'
2424

25+
# Skip SSL verification ONLY when recording new VCR cassettes
26+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if ENV['RE_RECORD_VCR'] == 'true'
27+
2528
request = Net::HTTP::Post.new(url.request_uri)
2629
request.basic_auth(Config.api_key, Config.api_secret)
2730
request['Accept'] = 'application/json'

lib/berkeley_library/location/world_cat/symbols.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ module BerkeleyLibrary
22
module Location
33
module WorldCat
44
module Symbols
5-
NRLF = %w[ZAP ZAPSP].freeze
6-
SRLF = %w[HH0 ZAS ZASSP].freeze
7-
RLF = (NRLF + SRLF).freeze
5+
SLFN = %w[ZAP ZAPSP].freeze
6+
SLFS = %w[HH0 ZAS ZASSP].freeze
7+
SLF = (SLFN + SLFS).freeze
88

99
UC = %w[CLU CRU CUI CUN CUS CUT CUV CUX CUY CUZ MERUC].freeze
10-
ALL = (RLF + UC).freeze
10+
ALL = (SLF + UC).freeze
1111

1212
class << self
1313
include Symbols

lib/berkeley_library/location/xlsx_writer.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ class XLSXWriter
77
include Constants
88
include BerkeleyLibrary::Logging
99

10-
COL_NRLF = 'NRLF'.freeze
11-
COL_SRLF = 'SRLF'.freeze
10+
COL_SLFN = 'SLFN'.freeze
11+
COL_SLFS = 'SLFS'.freeze
1212
COL_OTHER_UC = 'Other UC'.freeze
1313
COL_WC_ERROR = 'WorldCat Error'.freeze
1414

1515
COL_HATHI_TRUST = 'Hathi Trust'.freeze
1616
COL_HATHI_TRUST_ERROR = "#{COL_HATHI_TRUST} Error".freeze
1717

18-
V_NRLF = 'nrlf'.freeze
19-
V_SRLF = 'srlf'.freeze
18+
V_SLFN = 'slfn'.freeze
19+
V_SLFS = 'slfs'.freeze
2020

21-
attr_reader :ss, :rlf, :uc, :hathi_trust
21+
attr_reader :ss, :slf, :uc, :hathi_trust
2222

23-
def initialize(ss, rlf: true, uc: true, hathi_trust: true)
23+
def initialize(ss, slf: true, uc: true, hathi_trust: true)
2424
@ss = ss
25-
@rlf = rlf
25+
@slf = slf
2626
@uc = uc
2727
@hathi_trust = hathi_trust
2828

@@ -32,7 +32,7 @@ def initialize(ss, rlf: true, uc: true, hathi_trust: true)
3232
def <<(result)
3333
r_indices = row_indices_for(result.oclc_number)
3434
r_indices.each do |idx|
35-
write_wc_cols(idx, result) if rlf || uc
35+
write_wc_cols(idx, result) if slf || uc
3636
write_ht_cols(idx, result) if hathi_trust
3737
end
3838
end
@@ -41,7 +41,7 @@ def <<(result)
4141

4242
def write_wc_cols(r_index, result)
4343
write_wc_error(r_index, result)
44-
write_rlf(r_index, result) if rlf
44+
write_slf(r_index, result) if slf
4545
write_uc(r_index, result) if uc
4646
end
4747

@@ -51,9 +51,9 @@ def write_ht_cols(r_index, result)
5151
end
5252

5353
def ensure_columns!
54-
if rlf
55-
nrlf_col_index
56-
srlf_col_index
54+
if slf
55+
slfn_col_index
56+
slfs_col_index
5757
end
5858
uc_col_index if uc
5959
ht_col_index if hathi_trust
@@ -66,9 +66,9 @@ def row_indices_for(oclc_number)
6666
raise ArgumentError, "Unknown OCLC number: #{oclc_number}"
6767
end
6868

69-
def write_rlf(r_index, result)
70-
ss.set_value_at(r_index, nrlf_col_index, V_NRLF) if result.nrlf?
71-
ss.set_value_at(r_index, srlf_col_index, V_SRLF) if result.srlf?
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?
7272
end
7373

7474
def write_uc(r_index, result)
@@ -99,12 +99,12 @@ def oclc_col_index
9999
@oclc_col_index ||= ss.find_column_index_by_header!(OCLC_COL_HEADER)
100100
end
101101

102-
def nrlf_col_index
103-
@nrlf_col_index ||= ss.ensure_column!(COL_NRLF)
102+
def slfn_col_index
103+
@slfn_col_index ||= ss.ensure_column!(COL_SLFN)
104104
end
105105

106-
def srlf_col_index
107-
@srlf_col_index ||= ss.ensure_column!(COL_SRLF)
106+
def slfs_col_index
107+
@slfs_col_index ||= ss.ensure_column!(COL_SLFS)
108108
end
109109

110110
def uc_col_index

spec/berkeley_library/location/world_cat/libraries_request_spec.rb

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,28 @@ module Location
33
module WorldCat
44
describe LibrariesRequest do
55
let(:oclc_number) { '85833285' }
6-
# let(:wc_base_url) { 'https://www.example.test/webservices/' }
76
let(:wc_base_url) { 'https://americas.discovery.api.oclc.org/worldcat/search/v2/' }
87
let(:wc_api_key) { '2lo55pdh7moyfodeo4gwgms0on65x31ghv0g6yg87ffwaljsdw' }
98
let(:wc_api_secret) { 'totallyfakesecret' }
109

11-
# before do
12-
# # Config.base_uri = wc_base_url
13-
# # Config.api_key = wc_api_key
14-
# # Config.api_secret = wc_api_secret
15-
# end
16-
1710
after do
18-
Config.send(:reset!)
11+
BerkeleyLibrary::Location::WorldCat::OCLCAuth
12+
.instance_variable_set(:@singleton__instance__, nil)
1913
end
2014

15+
2116
describe :new do
17+
before do
18+
auth = instance_double(
19+
BerkeleyLibrary::Location::WorldCat::OCLCAuth,
20+
access_token: 'fake-access-token'
21+
)
22+
23+
allow(BerkeleyLibrary::Location::WorldCat::OCLCAuth)
24+
.to receive(:new)
25+
.and_return(auth)
26+
end
27+
2228
describe :oclc_number do
2329
it 'accepts a valid OCLC number' do
2430
q = LibrariesRequest.new(oclc_number)
@@ -65,13 +71,24 @@ module WorldCat
6571
end
6672

6773
it 'rejects an array containing nonexistent symbols' do
68-
bad_symbols = [Symbols::NRLF, ['not a WorldCat institution symbol'], Symbols::SRLF].flatten
74+
bad_symbols = [Symbols::SLFN, ['not a WorldCat institution symbol'], Symbols::SLFS].flatten
6975
expect { LibrariesRequest.new(oclc_number, symbols: bad_symbols) }.to raise_error(ArgumentError)
7076
end
7177
end
7278
end
7379

7480
describe :uri do
81+
before do
82+
auth = instance_double(
83+
BerkeleyLibrary::Location::WorldCat::OCLCAuth,
84+
access_token: 'fake-access-token'
85+
)
86+
87+
allow(BerkeleyLibrary::Location::WorldCat::OCLCAuth)
88+
.to receive(:new)
89+
.and_return(auth)
90+
end
91+
7592
it 'returns the URI for the specified OCLC number' do
7693
uri_expected = URI.parse("#{wc_base_url}bibs-holdings")
7794
uri_actual = LibrariesRequest.new(oclc_number).uri
@@ -92,7 +109,7 @@ module WorldCat
92109

93110
it 'returns a specified subset of holdings' do
94111
holdings_expected = %w[ZAP]
95-
symbols = Symbols::RLF
112+
symbols = Symbols::SLF
96113
req = LibrariesRequest.new(oclc_number, symbols:)
97114

98115
VCR.use_cassette('libraries_request/execute_holdings_2') do
@@ -116,7 +133,7 @@ module WorldCat
116133

117134
it 'returns an empty list when no holdings are found' do
118135
oclc_number = '10045193'
119-
symbols = Symbols::RLF
136+
symbols = Symbols::SLF
120137
req = LibrariesRequest.new(oclc_number, symbols:)
121138

122139
VCR.use_cassette('libraries_request/execute_holdings_4') do

0 commit comments

Comments
 (0)