Skip to content

Commit

Permalink
Merge pull request #687 from pulibrary/i590_display_non_romanized_title
Browse files Browse the repository at this point in the history
Include non-romanized title in selector csvs
  • Loading branch information
christinach authored Mar 6, 2024
2 parents 2adf307 + d350660 commit 120322c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/oclc/newly_cataloged_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def row_data(record:)
record.oclc_id, record.isbns, record.lccns, record.author, record.title,
record.f008_pub_place, record.pub_place, record.pub_name, record.pub_date,
record.description, record.format, record.languages, record.call_number,
record.subject_string
record.subject_string, record.non_romanized_title
]
end
end
Expand Down
22 changes: 22 additions & 0 deletions app/models/oclc/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,28 @@ def title
scrub_string(title_string)
end

def non_romanized_title
return '' unless title_linkage

linked_880s = record.fields('880').select do |linked_field|
linked_field['6'].include?("245-#{number_of_title_880}")
end
scrub_string(linked_880s.first['a'])
end

# Finds information on the 880 "Alternate Graphic Representation" connected to the 245 title field
def title_linkage
record['245']['6']
end

# Records can have more than one "Alternate Graphic Representation" for different fields
# They are linked by the number in the subfield 6
# rubocop:disable Naming/VariableNumber
def number_of_title_880
title_linkage.match(/(\d{2}$)/).captures&.first
end
# rubocop:enable Naming/VariableNumber

def oclc_id
record['001'].value.strip
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/oclc/selector_csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def file_path
def create
headers = ['OCLC Number', 'ISBNs', 'LCCNs', 'Author', 'Title', '008 Place Code',
'Pub Place', 'Pub Name', 'Pub Date', 'Description', 'Format', 'Languages',
'Call Number', 'Subjects']
'Call Number', 'Subjects', 'Non-Romanized Title']
CSV.open(file_path, 'w', encoding: 'bom|utf-8') do |csv|
csv.to_io.write "\uFEFF" # use CSV#to_io to write BOM directly
csv << headers
Expand Down
5 changes: 5 additions & 0 deletions spec/models/oclc/newly_cataloged_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,10 @@
expect(first_row[13]).to eq("Bible -- Criticism, interpretation, etc | " \
"Christianity -- Economic aspects -- Biblical teaching | " \
"Economics -- Religious aspects -- Christianity | Kingdom of God -- Biblical teaching")

second_row = csv_file[2]
expect(second_row[1]).to eq('9787221165381')
expect(second_row[4]).to eq('Guizhou bao xian bai nian')
expect(second_row[14]).to eq('贵州保险百年')
end
end
2 changes: 2 additions & 0 deletions spec/models/oclc/record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
expect(subject.lccns).to eq('2023214610')
expect(subject.author).to eq('')
expect(subject.title).to include('Oruzheĭnyĭ sbornik')
expect(subject.non_romanized_title).to include('Оружейный сборник')
expect(subject.f008_pub_place).to eq('ru')
expect(subject.pub_place).to eq('Sankt-Peterburg')
expect(subject.pub_name).to eq("Izdatel'stvo Gosudarstvennogo Ėrmitazha")
Expand Down Expand Up @@ -227,6 +228,7 @@
expect(subject.lccns).to eq('70230550')
expect(subject.author).to eq('Catholic Church Pope (1198-1216 : Innocent III)')
expect(subject.title).to include("Die Register Innocenz' III")
expect(subject.non_romanized_title).to eq('')
expect(subject.f008_pub_place).to eq('au')
expect(subject.pub_place).to eq('Graz ;')
expect(subject.pub_name).to eq('Hermann Böhlaus Nachf.')
Expand Down
2 changes: 1 addition & 1 deletion spec/models/oclc/selector_csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
let(:headers) do
['OCLC Number', 'ISBNs', 'LCCNs', 'Author', 'Title', '008 Place Code',
'Pub Place', 'Pub Name', 'Pub Date', 'Description', 'Format', 'Languages',
'Call Number', 'Subjects']
'Call Number', 'Subjects', 'Non-Romanized Title']
end

around do |example|
Expand Down

0 comments on commit 120322c

Please sign in to comment.