From 962dde568f15a554fc087a96c4d4a7b1cbd7796c Mon Sep 17 00:00:00 2001 From: Jason Raitz Date: Wed, 9 Oct 2024 13:44:40 -0400 Subject: [PATCH] added data and a test for transcript display --- lib/berkeley_library/av/metadata/fields.rb | 2 +- spec/data/record-audio-multiple-856s.xml | 55 +++++++++++++++++++ .../av/metadata/field_spec.rb | 21 +++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 spec/data/record-audio-multiple-856s.xml diff --git a/lib/berkeley_library/av/metadata/fields.rb b/lib/berkeley_library/av/metadata/fields.rb index c125283..c246abc 100644 --- a/lib/berkeley_library/av/metadata/fields.rb +++ b/lib/berkeley_library/av/metadata/fields.rb @@ -14,7 +14,7 @@ module Fields TRACKS = Field.new(order: 99, label: 'Tracks', spec: TAG_TRACK_FIELD, subfield_order: %w[g t a]) CATALOG_LINK = Field.new(order: 998, label: 'Linked Resources', spec: "#{TAG_LINK_FIELD}{^1=\\4}{^2=\\1}") # rubocop:disable Layout/LineLength - Field.new(order: 999, label: 'Transcripts', spec: "#{TAG_TRANSCRIPT_FIELD}{$y~\\Transcript}{^1=\\4}{^2=\\2}", subfield_order: %w[u y]) + TRANSCRIPTS = Field.new(order: 999, label: 'Transcripts', spec: "#{TAG_TRANSCRIPT_FIELD}{$y~\\Transcript}{^1=\\4}{^2=\\2}", subfield_order: %w[u y]) # rubocop:enable Layout/LineLength STANDARD_FIELDS = [ diff --git a/spec/data/record-audio-multiple-856s.xml b/spec/data/record-audio-multiple-856s.xml new file mode 100644 index 0000000..a55f297 --- /dev/null +++ b/spec/data/record-audio-multiple-856s.xml @@ -0,0 +1,55 @@ + + + + + 207666 + 20231106135319.0 + + drilmav-00004 + + + On changes regarding discrimination against people with disabilities + + + Audio + + + 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). + + + + Billings, Carol Fewell + + + The Bancroft Library + + + https://avplayer.lib.berkeley.edu/ROHOAudio/drilmav-00004 + Play Audio + + + https://digitalassets.lib.berkeley.edu/audio/transcript/Carol_Fewell_Billings_Transcript.pdf + Transcript of audio file + + + 2/3/21 + SMS + + + oai:digicoll.lib.berkeley.edu:207666 + mcleanCalisphere_oai + + + DRILM: AV + + + Disability Rights and Independent Living Movement + + + Disability Rights Movement + + + billings1.mp3 + + + \ No newline at end of file diff --git a/spec/lib/berkeley_library/av/metadata/field_spec.rb b/spec/lib/berkeley_library/av/metadata/field_spec.rb index 9d183e9..461f30f 100644 --- a/spec/lib/berkeley_library/av/metadata/field_spec.rb +++ b/spec/lib/berkeley_library/av/metadata/field_spec.rb @@ -66,6 +66,27 @@ class Metadata end end + context 'transcripts' do + it 'extracts transcripts from TIND records' do + marc_record = MARC::XMLReader.new('spec/data/record-audio-multiple-856s.xml').first + field = Field.new(order: 999, label: 'Transcripts', spec: "#{TAG_TRANSCRIPT_FIELD}{$y~\\Transcript}{^1=\\4}{^2=\\2}", subfield_order: %w[u y]) + value = field.value_from(marc_record) + expect(value).to be_a(Value) + expected_transcript = AV::Metadata::Link.new( + url: 'https://digitalassets.lib.berkeley.edu/audio/transcript/Carol_Fewell_Billings_Transcript.pdf', + body: 'Transcript of audio file' + ) + expect(value.entries).to contain_exactly(expected_transcript) + end + + it 'doesn\'t break when there are no transcripts' do + marc_record = MARC::XMLReader.new('spec/data/record-(pacradio)01469.xml').first + field = Field.new(order: 999, label: 'Transcripts', spec: "#{TAG_TRANSCRIPT_FIELD}{$y~\\Transcript}{^1=\\4}{^2=\\2}", subfield_order: %w[u y]) + value = field.value_from(marc_record) + expect(value).to be_nil + end + end + describe :hash do it 'returns the same hash for identical Fields' do f1 = Field.new(order: 2, label: 'Description', spec: '520$a')