Skip to content

Commit

Permalink
added data and a test for transcript display
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-raitz committed Oct 9, 2024
1 parent a60e430 commit 9b112db
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/berkeley_library/av/metadata/fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
55 changes: 55 additions & 0 deletions spec/data/record-audio-multiple-856s.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

<?xml version="1.0" encoding="UTF-8"?>
<collection xmlns="http://www.loc.gov/MARC21/slim">
<record>
<controlfield tag="001">207666</controlfield>
<controlfield tag="005">20231106135319.0</controlfield>
<datafield tag="035" ind1=" " ind2=" ">
<subfield code="a">drilmav-00004</subfield>
</datafield>
<datafield tag="245" ind1=" " ind2=" ">
<subfield code="a">On changes regarding discrimination against people with disabilities</subfield>
</datafield>
<datafield tag="336" ind1=" " ind2=" ">
<subfield code="a">Audio</subfield>
</datafield>
<datafield tag="540" ind1=" " ind2=" ">
<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).
</subfield>
</datafield>
<datafield tag="700" ind1="1" ind2=" ">
<subfield code="a">Billings, Carol Fewell</subfield>
</datafield>
<datafield tag="852" ind1=" " ind2=" ">
<subfield code="c">The Bancroft Library</subfield>
</datafield>
<datafield tag="856" ind1="4" ind2="2">
<subfield code="u">https://avplayer.lib.berkeley.edu/ROHOAudio/drilmav-00004</subfield>
<subfield code="y">Play Audio</subfield>
</datafield>
<datafield tag="856" ind1="4" ind2="2">
<subfield code="u">https://digitalassets.lib.berkeley.edu/audio/transcript/Carol_Fewell_Billings_Transcript.pdf</subfield>
<subfield code="y">Transcript of audio file</subfield>
</datafield>
<datafield tag="902" ind1=" " ind2=" ">
<subfield code="d">2/3/21</subfield>
<subfield code="n">SMS</subfield>
</datafield>
<datafield tag="909" ind1="C" ind2="O">
<subfield code="o">oai:digicoll.lib.berkeley.edu:207666</subfield>
<subfield code="q">mcleanCalisphere_oai</subfield>
</datafield>
<datafield tag="980" ind1=" " ind2=" ">
<subfield code="a">DRILM: AV</subfield>
</datafield>
<datafield tag="982" ind1=" " ind2=" ">
<subfield code="b">Disability Rights and Independent Living Movement</subfield>
</datafield>
<datafield tag="982" ind1=" " ind2=" ">
<subfield code="a">Disability Rights Movement</subfield>
</datafield>
<datafield tag="998" ind1=" " ind2=" ">
<subfield code="g">billings1.mp3</subfield>
</datafield>
</record>
</collection>
21 changes: 21 additions & 0 deletions spec/lib/berkeley_library/av/metadata/field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 9b112db

Please sign in to comment.