berkeley_library-av-core 0.4.1 → 0.4.3
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/.github/workflows/build.yml +3 -3
- data/.github/workflows/gem-push.yml +33 -0
- data/.idea/av_core.iml +1 -1
- data/CHANGES.md +10 -1
- data/lib/berkeley_library/av/config.rb +1 -0
- data/lib/berkeley_library/av/constants.rb +4 -0
- data/lib/berkeley_library/av/core/module_info.rb +1 -1
- data/lib/berkeley_library/av/metadata/fields.rb +5 -1
- data/lib/berkeley_library/av/metadata/readers/tind.rb +2 -2
- data/lib/berkeley_library/av/record.rb +1 -0
- data/lib/berkeley_library/av/util.rb +5 -1
- data/rakelib/spec.rake +1 -1
- data/spec/data/record-audio-multiple-856s.xml +55 -0
- data/spec/lib/berkeley_library/av/metadata/field_spec.rb +21 -0
- data/spec/lib/berkeley_library/av/metadata/fields_spec.rb +2 -1
- data/spec/lib/berkeley_library/av/metadata/metadata_spec.rb +5 -5
- data/spec/lib/berkeley_library/av/metadata/source_spec.rb +1 -1
- data/spec/lib/berkeley_library/av/record_spec.rb +5 -5
- data/spec/lib/berkeley_library/av/util_spec.rb +26 -0
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 971da7efa1200b726375ad3d140e194e430dd26f445640469bacebc9c9f2a7ea
|
|
4
|
+
data.tar.gz: 20d351482ba8d7d9e31ae026d250462abaca8e1285793737c51f1ce0f0fa6386
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab15fd5cbb329b686211a62c6d653e2c8af16f6a1bb68414e8eedfcb183b5e4b0bbcecabff013d724051059540e6b5b7f42018733dbbf629e6e7c04e3fc36c95
|
|
7
|
+
data.tar.gz: 3b3f405f9c7abb05037963e51e92cf8a83d47ea80881d9d4ba4e96a0846a1d7d7a12a1a54f0a7b09aa6178b9f4c797e6e97755614b035e3c82976f46afe071a9
|
data/.github/workflows/build.yml
CHANGED
|
@@ -11,7 +11,7 @@ jobs:
|
|
|
11
11
|
|
|
12
12
|
steps:
|
|
13
13
|
- name: Check out repository
|
|
14
|
-
uses: actions/checkout@
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
15
|
|
|
16
16
|
- name: Set up Ruby
|
|
17
17
|
uses: ruby/setup-ruby@v1
|
|
@@ -24,7 +24,7 @@ jobs:
|
|
|
24
24
|
|
|
25
25
|
- name: Upload artifacts
|
|
26
26
|
if: ${{ always() }}
|
|
27
|
-
uses: actions/upload-artifact@
|
|
27
|
+
uses: actions/upload-artifact@v4
|
|
28
28
|
with:
|
|
29
|
-
name: artifacts
|
|
29
|
+
name: artifacts-${{ matrix.os }}-${{ matrix.ruby }}
|
|
30
30
|
path: artifacts/**
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Build and push Ruby Gem
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
name: Build + Publish
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
packages: write
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Ruby
|
|
19
|
+
uses: ruby/setup-ruby@v1
|
|
20
|
+
with:
|
|
21
|
+
ruby-version: '3.2'
|
|
22
|
+
bundler-cache: true
|
|
23
|
+
|
|
24
|
+
- name: Publish to RubyGems
|
|
25
|
+
run: |
|
|
26
|
+
mkdir -p $HOME/.gem
|
|
27
|
+
touch $HOME/.gem/credentials
|
|
28
|
+
chmod 0600 $HOME/.gem/credentials
|
|
29
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
|
30
|
+
gem build *.gemspec
|
|
31
|
+
gem push *.gem
|
|
32
|
+
env:
|
|
33
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/.idea/av_core.iml
CHANGED
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
</RakeTaskImpl>
|
|
114
114
|
<RakeTaskImpl description="Run all specs in spec directory, with coverage" fullCommand="coverage" id="coverage" />
|
|
115
115
|
<RakeTaskImpl description="Run tests, check test coverage, check code style, check for vulnerabilities, build gem" fullCommand="default" id="default" />
|
|
116
|
-
<RakeTaskImpl description="Build av_core.gemspec as
|
|
116
|
+
<RakeTaskImpl description="Build av_core.gemspec as berkeley_library-av-core-0.4.1.gem" fullCommand="gem" id="gem" />
|
|
117
117
|
<RakeTaskImpl description="Run RuboCop with auto-correct, and output results to console" fullCommand="ra" id="ra" />
|
|
118
118
|
<RakeTaskImpl description="Run rubocop with HTML output" fullCommand="rubocop" id="rubocop" />
|
|
119
119
|
<RakeTaskImpl id="rubocop">
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
# 0.4.3 (2025-11-04)
|
|
2
|
+
|
|
3
|
+
- BerkeleyLibrary::AV::Metadata::Readers:TIND now uses the /api/v1/search endpoint to retrieve records. The public /search endpoint stopped working for non-browser/human clients in the past week due to TIND changes.
|
|
4
|
+
- BerkeleyLibrary::AV::Util#do_get sources the TIND API key from ENV['LIT_TIND_API_KEY'] if it's set.
|
|
5
|
+
|
|
6
|
+
# 0.4.2 (2024-10-10)
|
|
7
|
+
|
|
8
|
+
- Add TRANSCRIPTS to `AV::METADATA::FIELDS`
|
|
9
|
+
|
|
1
10
|
# 0.4.1 (2023-02-21)
|
|
2
11
|
|
|
3
12
|
- Add `BerkeleyLibrary::AV::Config.log_settings!`
|
|
@@ -14,7 +23,7 @@
|
|
|
14
23
|
- `Metadata#player_link_text`
|
|
15
24
|
- `Metadata#player_url`
|
|
16
25
|
- Remove the following constants:
|
|
17
|
-
- `AV::Constants::RESTRICTIONS_CALNET`
|
|
26
|
+
- `AV::Constants::RESTRICTIONS_CALNET`
|
|
18
27
|
- `AV::Constants::RESTRICTIONS_UCB_IP`
|
|
19
28
|
- `AV::Constants::RESTRICTIONS`
|
|
20
29
|
- `AV::Constants::RESTRICTIONS_NONE`
|
|
@@ -5,6 +5,10 @@ module BerkeleyLibrary
|
|
|
5
5
|
TAG_LINK_FIELD = '856'.freeze
|
|
6
6
|
TAG_TRACK_FIELD = '998'.freeze
|
|
7
7
|
TAG_TIND_ID = '001'.freeze
|
|
8
|
+
TAG_TRANSCRIPT_FIELD = '856'.freeze
|
|
9
|
+
|
|
10
|
+
SUBFIELD_CODE_URI = :u
|
|
11
|
+
SUBFIELD_CODE_LINKTEXT = :y
|
|
8
12
|
|
|
9
13
|
# TODO: use marc/spec
|
|
10
14
|
TAG_TIND_CATALOG_ID = '901'.freeze
|
|
@@ -8,7 +8,7 @@ module BerkeleyLibrary
|
|
|
8
8
|
SUMMARY = 'UC Berkeley Library audio/video core code'.freeze
|
|
9
9
|
DESCRIPTION = 'Gem for UC Berkeley Library shared audio/video code'.freeze
|
|
10
10
|
LICENSE = 'MIT'.freeze
|
|
11
|
-
VERSION = '0.4.
|
|
11
|
+
VERSION = '0.4.3'.freeze
|
|
12
12
|
HOMEPAGE = 'https://github.com/BerkeleyLibrary/av-core'.freeze
|
|
13
13
|
|
|
14
14
|
private_class_method :new
|
|
@@ -12,7 +12,10 @@ module BerkeleyLibrary
|
|
|
12
12
|
CREATOR_PERSONAL = Field.new(order: 2, label: 'Creator', spec: '700')
|
|
13
13
|
CREATOR_CORPORATE = Field.new(order: 2, label: 'Creator', spec: '710')
|
|
14
14
|
TRACKS = Field.new(order: 99, label: 'Tracks', spec: TAG_TRACK_FIELD, subfield_order: %w[g t a])
|
|
15
|
-
CATALOG_LINK = Field.new(order:
|
|
15
|
+
CATALOG_LINK = Field.new(order: 998, label: 'Linked Resources', spec: "#{TAG_LINK_FIELD}{^1=\\4}{^2=\\1}")
|
|
16
|
+
# rubocop:disable Layout/LineLength
|
|
17
|
+
TRANSCRIPTS = Field.new(order: 999, label: 'Transcripts', spec: "#{TAG_TRANSCRIPT_FIELD}{$y~\\Transcript}{^1=\\4}{^2=\\2}", subfield_order: %w[u y])
|
|
18
|
+
# rubocop:enable Layout/LineLength
|
|
16
19
|
|
|
17
20
|
STANDARD_FIELDS = [
|
|
18
21
|
TITLE,
|
|
@@ -20,6 +23,7 @@ module BerkeleyLibrary
|
|
|
20
23
|
CREATOR_PERSONAL,
|
|
21
24
|
CREATOR_CORPORATE,
|
|
22
25
|
TRACKS,
|
|
26
|
+
TRANSCRIPTS,
|
|
23
27
|
CATALOG_LINK
|
|
24
28
|
].freeze
|
|
25
29
|
|
|
@@ -22,9 +22,9 @@ module BerkeleyLibrary
|
|
|
22
22
|
id_field = id_field_for(record_id)
|
|
23
23
|
query_string = URI.encode_www_form(
|
|
24
24
|
'p' => "#{id_field}:\"#{record_id}\"",
|
|
25
|
-
'
|
|
25
|
+
'format' => 'xml'
|
|
26
26
|
)
|
|
27
|
-
URIs.append(base_uri, 'search', '?', query_string)
|
|
27
|
+
URIs.append(base_uri, 'api/v1/search', '?', query_string)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
protected
|
|
@@ -12,7 +12,11 @@ module BerkeleyLibrary
|
|
|
12
12
|
DEFAULT_USER_AGENT = "#{Core::ModuleInfo::NAME} #{Core::ModuleInfo::VERSION} (#{Core::ModuleInfo::HOMEPAGE})".freeze
|
|
13
13
|
|
|
14
14
|
def do_get(uri, ignore_errors: false)
|
|
15
|
-
|
|
15
|
+
headers = { user_agent: DEFAULT_USER_AGENT }
|
|
16
|
+
if uri.to_s.start_with?(BerkeleyLibrary::AV::Config.tind_base_uri.to_s) && ENV['LIT_TIND_API_KEY']
|
|
17
|
+
headers[:authorization] = "Token #{ENV['LIT_TIND_API_KEY']}"
|
|
18
|
+
end
|
|
19
|
+
body = URIs.get(uri, headers:)
|
|
16
20
|
body && body.scrub
|
|
17
21
|
rescue RestClient::Exception
|
|
18
22
|
raise unless ignore_errors
|
data/rakelib/spec.rake
CHANGED
|
@@ -3,7 +3,7 @@ require 'rspec/core/rake_task'
|
|
|
3
3
|
namespace :spec do
|
|
4
4
|
desc 'Run all tests'
|
|
5
5
|
RSpec::Core::RakeTask.new(:all) do |task|
|
|
6
|
-
task.rspec_opts = %w[--color --format documentation
|
|
6
|
+
task.rspec_opts = %w[--color --format documentation]
|
|
7
7
|
task.pattern = 'spec/**/*_spec.rb'
|
|
8
8
|
end
|
|
9
9
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
3
|
+
<collection xmlns="http://www.loc.gov/MARC21/slim">
|
|
4
|
+
<record>
|
|
5
|
+
<controlfield tag="001">207666</controlfield>
|
|
6
|
+
<controlfield tag="005">20231106135319.0</controlfield>
|
|
7
|
+
<datafield tag="035" ind1=" " ind2=" ">
|
|
8
|
+
<subfield code="a">drilmav-00004</subfield>
|
|
9
|
+
</datafield>
|
|
10
|
+
<datafield tag="245" ind1=" " ind2=" ">
|
|
11
|
+
<subfield code="a">On changes regarding discrimination against people with disabilities</subfield>
|
|
12
|
+
</datafield>
|
|
13
|
+
<datafield tag="336" ind1=" " ind2=" ">
|
|
14
|
+
<subfield code="a">Audio</subfield>
|
|
15
|
+
</datafield>
|
|
16
|
+
<datafield tag="540" ind1=" " ind2=" ">
|
|
17
|
+
<subfield code="a">Researchers may make free and open use of the UC Berkeley Library’s digitized public domain materials. However, some materials in our online collections may be protected by U.S. copyright law (Title 17, U.S.C.). Use or reproduction of materials protected by copyright beyond that allowed by fair use (Title 17, U.S.C. § 107) requires permission from the copyright owners. The use or reproduction of some materials may also be restricted by terms of University of California gift or purchase agreements, privacy and publicity rights, or trademark law. Responsibility for determining rights status and permissibility of any use or reproduction rests exclusively with the researcher. To learn more or make inquiries, please see our permissions policies (https://www.lib.berkeley.edu/about/permissions-policies).
|
|
18
|
+
</subfield>
|
|
19
|
+
</datafield>
|
|
20
|
+
<datafield tag="700" ind1="1" ind2=" ">
|
|
21
|
+
<subfield code="a">Billings, Carol Fewell</subfield>
|
|
22
|
+
</datafield>
|
|
23
|
+
<datafield tag="852" ind1=" " ind2=" ">
|
|
24
|
+
<subfield code="c">The Bancroft Library</subfield>
|
|
25
|
+
</datafield>
|
|
26
|
+
<datafield tag="856" ind1="4" ind2="2">
|
|
27
|
+
<subfield code="u">https://avplayer.lib.berkeley.edu/ROHOAudio/drilmav-00004</subfield>
|
|
28
|
+
<subfield code="y">Play Audio</subfield>
|
|
29
|
+
</datafield>
|
|
30
|
+
<datafield tag="856" ind1="4" ind2="2">
|
|
31
|
+
<subfield code="u">https://digitalassets.lib.berkeley.edu/audio/transcript/Carol_Fewell_Billings_Transcript.pdf</subfield>
|
|
32
|
+
<subfield code="y">Transcript of audio file</subfield>
|
|
33
|
+
</datafield>
|
|
34
|
+
<datafield tag="902" ind1=" " ind2=" ">
|
|
35
|
+
<subfield code="d">2/3/21</subfield>
|
|
36
|
+
<subfield code="n">SMS</subfield>
|
|
37
|
+
</datafield>
|
|
38
|
+
<datafield tag="909" ind1="C" ind2="O">
|
|
39
|
+
<subfield code="o">oai:digicoll.lib.berkeley.edu:207666</subfield>
|
|
40
|
+
<subfield code="q">mcleanCalisphere_oai</subfield>
|
|
41
|
+
</datafield>
|
|
42
|
+
<datafield tag="980" ind1=" " ind2=" ">
|
|
43
|
+
<subfield code="a">DRILM: AV</subfield>
|
|
44
|
+
</datafield>
|
|
45
|
+
<datafield tag="982" ind1=" " ind2=" ">
|
|
46
|
+
<subfield code="b">Disability Rights and Independent Living Movement</subfield>
|
|
47
|
+
</datafield>
|
|
48
|
+
<datafield tag="982" ind1=" " ind2=" ">
|
|
49
|
+
<subfield code="a">Disability Rights Movement</subfield>
|
|
50
|
+
</datafield>
|
|
51
|
+
<datafield tag="998" ind1=" " ind2=" ">
|
|
52
|
+
<subfield code="g">billings1.mp3</subfield>
|
|
53
|
+
</datafield>
|
|
54
|
+
</record>
|
|
55
|
+
</collection>
|
|
@@ -66,6 +66,27 @@ module BerkeleyLibrary
|
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
+
context 'transcripts' do
|
|
70
|
+
it 'extracts transcripts from TIND records' do
|
|
71
|
+
marc_record = MARC::XMLReader.new('spec/data/record-audio-multiple-856s.xml').first
|
|
72
|
+
field = Field.new(order: 999, label: 'Transcripts', spec: "#{TAG_TRANSCRIPT_FIELD}{$y~\\Transcript}{^1=\\4}{^2=\\2}", subfield_order: %w[u y])
|
|
73
|
+
value = field.value_from(marc_record)
|
|
74
|
+
expect(value).to be_a(Value)
|
|
75
|
+
expected_transcript = AV::Metadata::Link.new(
|
|
76
|
+
url: 'https://digitalassets.lib.berkeley.edu/audio/transcript/Carol_Fewell_Billings_Transcript.pdf',
|
|
77
|
+
body: 'Transcript of audio file'
|
|
78
|
+
)
|
|
79
|
+
expect(value.entries).to contain_exactly(expected_transcript)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'doesn\'t break when there are no transcripts' do
|
|
83
|
+
marc_record = MARC::XMLReader.new('spec/data/record-(pacradio)01469.xml').first
|
|
84
|
+
field = Field.new(order: 999, label: 'Transcripts', spec: "#{TAG_TRANSCRIPT_FIELD}{$y~\\Transcript}{^1=\\4}{^2=\\2}", subfield_order: %w[u y])
|
|
85
|
+
value = field.value_from(marc_record)
|
|
86
|
+
expect(value).to be_nil
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
69
90
|
describe :hash do
|
|
70
91
|
it 'returns the same hash for identical Fields' do
|
|
71
92
|
f1 = Field.new(order: 2, label: 'Description', spec: '520$a')
|
|
@@ -75,7 +75,8 @@ module BerkeleyLibrary
|
|
|
75
75
|
Field.new(order: 86, spec: '991$a', label: 'Access', subfields_separator: ', '),
|
|
76
76
|
Field.new(order: 89, spec: '982$a', label: 'Collection'),
|
|
77
77
|
Field.new(order: 99, spec: '998', label: 'Tracks', subfield_order: %w[g t a]),
|
|
78
|
-
Field.new(order:
|
|
78
|
+
Field.new(order: 998, spec: '856{^1=\4}{^2=\1}', label: 'Linked Resources'),
|
|
79
|
+
Field.new(order: 999, spec: '856{$y~\Transcript}{^1=\4}{^2=\2}', label: 'Transcripts', subfield_order: %w[u y])
|
|
79
80
|
]
|
|
80
81
|
|
|
81
82
|
fields = Fields.default_fields
|
|
@@ -183,7 +183,7 @@ module BerkeleyLibrary
|
|
|
183
183
|
it 'injects a TIND URL if not present (1/2)' do
|
|
184
184
|
tind_035 = '(miscmat)00615'
|
|
185
185
|
marc_xml = File.read("spec/data/record-#{tind_035}.xml")
|
|
186
|
-
search_url = "https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&
|
|
186
|
+
search_url = "https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&format=xml"
|
|
187
187
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
188
188
|
metadata = Metadata.for_record(record_id: tind_035)
|
|
189
189
|
|
|
@@ -200,7 +200,7 @@ module BerkeleyLibrary
|
|
|
200
200
|
it 'injects a TIND URL if not present (2/2)' do
|
|
201
201
|
tind_035 = 'physcolloquia-bk00169017b'
|
|
202
202
|
marc_xml = File.read("spec/data/record-#{tind_035}.xml")
|
|
203
|
-
search_url = "https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&
|
|
203
|
+
search_url = "https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&format=xml"
|
|
204
204
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
205
205
|
metadata = Metadata.for_record(record_id: tind_035)
|
|
206
206
|
|
|
@@ -218,7 +218,7 @@ module BerkeleyLibrary
|
|
|
218
218
|
it 'works for TIND records with OskiCat URLs' do
|
|
219
219
|
tind_035 = '(pacradio)00107'
|
|
220
220
|
marc_xml = File.read("spec/data/record-#{tind_035}.xml")
|
|
221
|
-
search_url = "https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&
|
|
221
|
+
search_url = "https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&format=xml"
|
|
222
222
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
223
223
|
metadata = Metadata.for_record(record_id: tind_035)
|
|
224
224
|
|
|
@@ -239,7 +239,7 @@ module BerkeleyLibrary
|
|
|
239
239
|
it 'works for TIND-only records' do
|
|
240
240
|
tind_035 = 'physcolloquia-bk00169017b'
|
|
241
241
|
marc_xml = File.read("spec/data/record-#{tind_035}.xml")
|
|
242
|
-
search_url = "https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&
|
|
242
|
+
search_url = "https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&format=xml"
|
|
243
243
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
244
244
|
metadata = Metadata.for_record(record_id: tind_035)
|
|
245
245
|
|
|
@@ -259,7 +259,7 @@ module BerkeleyLibrary
|
|
|
259
259
|
it 'returns the values' do
|
|
260
260
|
tind_035 = 'physcolloquia-bk00169017b'
|
|
261
261
|
marc_xml = File.read("spec/data/record-#{tind_035}.xml")
|
|
262
|
-
search_url = "https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&
|
|
262
|
+
search_url = "https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&format=xml"
|
|
263
263
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
264
264
|
metadata = Metadata.for_record(record_id: tind_035)
|
|
265
265
|
|
|
@@ -161,7 +161,7 @@ module BerkeleyLibrary
|
|
|
161
161
|
|
|
162
162
|
before do
|
|
163
163
|
AV::Config.tind_base_uri = 'https://digicoll.lib.berkeley.edu'
|
|
164
|
-
@record_url = 'https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22%28pacradio%2900107%22&
|
|
164
|
+
@record_url = 'https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22%28pacradio%2900107%22&format=xml'
|
|
165
165
|
end
|
|
166
166
|
|
|
167
167
|
after do
|
|
@@ -46,7 +46,7 @@ module BerkeleyLibrary
|
|
|
46
46
|
it 'returns a player URI based on the record ID for TIND records' do
|
|
47
47
|
tind_035 = '(pacradio)01469'
|
|
48
48
|
marc_xml = File.read("spec/data/record-#{tind_035}.xml")
|
|
49
|
-
search_url = "https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&
|
|
49
|
+
search_url = "https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&format=xml"
|
|
50
50
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
51
51
|
|
|
52
52
|
collection = 'Pacifica'
|
|
@@ -145,7 +145,7 @@ module BerkeleyLibrary
|
|
|
145
145
|
|
|
146
146
|
it 'returns the TIND ID for TIND records' do
|
|
147
147
|
marc_xml = File.read('spec/data/record-(pacradio)01469.xml')
|
|
148
|
-
search_url = 'https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22%28pacradio%2901469%22&
|
|
148
|
+
search_url = 'https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22%28pacradio%2901469%22&format=xml'
|
|
149
149
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
150
150
|
|
|
151
151
|
record = Record.from_metadata(
|
|
@@ -168,7 +168,7 @@ module BerkeleyLibrary
|
|
|
168
168
|
it 'returns nil for TIND records with no bib number' do
|
|
169
169
|
tind_id = '(clir)00020'
|
|
170
170
|
marc_xml = File.read('spec/data/record-(clir)00020.xml')
|
|
171
|
-
search_url = 'https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22%28clir%2900020%22&
|
|
171
|
+
search_url = 'https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22%28clir%2900020%22&format=xml'
|
|
172
172
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
173
173
|
|
|
174
174
|
record = Record.from_metadata(collection: 'Video-Public-Bancroft', record_id: tind_id)
|
|
@@ -179,7 +179,7 @@ module BerkeleyLibrary
|
|
|
179
179
|
describe :from_metadata do
|
|
180
180
|
it 'loads the metadata' do
|
|
181
181
|
marc_xml = File.read('spec/data/record-(pacradio)01469.xml')
|
|
182
|
-
search_url = 'https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22%28pacradio%2901469%22&
|
|
182
|
+
search_url = 'https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22%28pacradio%2901469%22&format=xml'
|
|
183
183
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
184
184
|
|
|
185
185
|
record = Record.from_metadata(collection: 'Pacifica', record_id: '(pacradio)01469')
|
|
@@ -223,7 +223,7 @@ module BerkeleyLibrary
|
|
|
223
223
|
end
|
|
224
224
|
|
|
225
225
|
it "raises #{AV::RecordNotFound} if the record cannot be found" do
|
|
226
|
-
search_url = 'https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22%28pacradio%2901469%22&
|
|
226
|
+
search_url = 'https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22%28pacradio%2901469%22&format=xml'
|
|
227
227
|
stub_request(:get, search_url).to_return(status: 404)
|
|
228
228
|
expect do
|
|
229
229
|
Record.from_metadata(
|
|
@@ -24,6 +24,32 @@ module BerkeleyLibrary
|
|
|
24
24
|
result = AV::Util.do_get(url, ignore_errors: true)
|
|
25
25
|
expect(result).to be_nil
|
|
26
26
|
end
|
|
27
|
+
|
|
28
|
+
it 'includes authorization header for TIND requests if LIT_TIND_API_KEY is set' do
|
|
29
|
+
expected_ua = Util::DEFAULT_USER_AGENT
|
|
30
|
+
expected_auth = 'Token some-long-api-token-value'
|
|
31
|
+
|
|
32
|
+
# expect do_get to call URIs.get with the correct headers
|
|
33
|
+
# but we don't need to actually perform the request
|
|
34
|
+
allow(BerkeleyLibrary::Util::URIs).to receive(:get).and_return('<response></response>')
|
|
35
|
+
allow(AV::Config).to receive(:tind_base_uri).and_return(URI('https://tind.example.edu/'))
|
|
36
|
+
url = "#{AV::Config.tind_base_uri}/some/api/endpoint"
|
|
37
|
+
ENV['LIT_TIND_API_KEY'] = 'some-long-api-token-value'
|
|
38
|
+
AV::Util.do_get(url)
|
|
39
|
+
expect(BerkeleyLibrary::Util::URIs).to have_received(:get).with(url, headers: { user_agent: expected_ua, authorization: expected_auth })
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'does not include authorization header for non-TIND requests' do
|
|
43
|
+
expected_ua = Util::DEFAULT_USER_AGENT
|
|
44
|
+
|
|
45
|
+
# expect do_get to call URIs.get with the correct headers
|
|
46
|
+
# but we don't need to actually perform the request
|
|
47
|
+
allow(BerkeleyLibrary::Util::URIs).to receive(:get).and_return('<response></response>')
|
|
48
|
+
url = URI('https://alma.example.edu/some/api/endpoint')
|
|
49
|
+
ENV['LIT_TIND_API_KEY'] = nil
|
|
50
|
+
AV::Util.do_get(url)
|
|
51
|
+
expect(BerkeleyLibrary::Util::URIs).to have_received(:get).with(url, headers: { user_agent: expected_ua })
|
|
52
|
+
end
|
|
27
53
|
end
|
|
28
54
|
end
|
|
29
55
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: berkeley_library-av-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Moles
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-11-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: berkeley_library-logging
|
|
@@ -322,6 +322,7 @@ extra_rdoc_files: []
|
|
|
322
322
|
files:
|
|
323
323
|
- ".dockerignore"
|
|
324
324
|
- ".github/workflows/build.yml"
|
|
325
|
+
- ".github/workflows/gem-push.yml"
|
|
325
326
|
- ".gitignore"
|
|
326
327
|
- ".idea/av_core.iml"
|
|
327
328
|
- ".idea/codeStyles/Project.xml"
|
|
@@ -395,6 +396,7 @@ files:
|
|
|
395
396
|
- spec/data/record-(miscmat)00615.xml
|
|
396
397
|
- spec/data/record-(pacradio)00107.xml
|
|
397
398
|
- spec/data/record-(pacradio)01469.xml
|
|
399
|
+
- spec/data/record-audio-multiple-856s.xml
|
|
398
400
|
- spec/data/record-empty-result.xml
|
|
399
401
|
- spec/data/record-multiple-998s-disordered.xml
|
|
400
402
|
- spec/data/record-multiple-998s.xml
|
|
@@ -441,7 +443,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
441
443
|
- !ruby/object:Gem::Version
|
|
442
444
|
version: '0'
|
|
443
445
|
requirements: []
|
|
444
|
-
rubygems_version: 3.
|
|
446
|
+
rubygems_version: 3.4.19
|
|
445
447
|
signing_key:
|
|
446
448
|
specification_version: 4
|
|
447
449
|
summary: UC Berkeley Library audio/video core code
|
|
@@ -470,6 +472,7 @@ test_files:
|
|
|
470
472
|
- spec/data/record-(miscmat)00615.xml
|
|
471
473
|
- spec/data/record-(pacradio)00107.xml
|
|
472
474
|
- spec/data/record-(pacradio)01469.xml
|
|
475
|
+
- spec/data/record-audio-multiple-856s.xml
|
|
473
476
|
- spec/data/record-empty-result.xml
|
|
474
477
|
- spec/data/record-multiple-998s-disordered.xml
|
|
475
478
|
- spec/data/record-multiple-998s.xml
|