pennmarc 1.1.1 → 1.2.1
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/.rubocop_todo.yml +2 -2
- data/lib/pennmarc/helpers/series.rb +26 -2
- data/lib/pennmarc/helpers/title.rb +4 -19
- data/lib/pennmarc/mappings/locations.yml +9 -9
- data/lib/pennmarc/version.rb +1 -1
- data/spec/lib/pennmarc/helpers/series_spec.rb +18 -0
- data/spec/lib/pennmarc/helpers/title_spec.rb +36 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7c380943acc4f69a8a7555260d122aa77046b2ab62a2f73e1b3559740bd409b
|
4
|
+
data.tar.gz: 0cc7fb1a1860265fb9bb2fcd637966d0d2972e6496a79545328649fa27fc1445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0265623f80ef1573fdf1d5c2a6a62636291a8edc4e7d06350238b3133071b30cd01a58a9679047578546e856f166ac6df9a9e413c562fafff60eecfc6eb12b93
|
7
|
+
data.tar.gz: aea9b53a26a97e7ff018fda2aacb6101bfb1c21585ac663fcbbdfba7084235de148643b9b03cc1478e230944ce3d45be641189f9852c6b88d7017da00c652bbc
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 10000`
|
3
|
-
# on 2024-08-
|
3
|
+
# on 2024-08-30 16:12:14 UTC using RuboCop version 1.51.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -138,7 +138,7 @@ RSpec/FilePath:
|
|
138
138
|
Exclude:
|
139
139
|
- 'spec/lib/pennmarc/parser_spec.rb'
|
140
140
|
|
141
|
-
# Offense count:
|
141
|
+
# Offense count: 27
|
142
142
|
# Configuration parameters: Max, AllowedGroups.
|
143
143
|
RSpec/NestedGroups:
|
144
144
|
Exclude:
|
@@ -35,6 +35,23 @@ module PennMARC
|
|
35
35
|
series_values.uniq
|
36
36
|
end
|
37
37
|
|
38
|
+
# Hash that associates {https://www.loc.gov/marc/bibliographic/bd830.html 830} and
|
39
|
+
# {https://www.loc.gov/marc/bibliographic/bd440.html 440} show values to query values to make building fielded
|
40
|
+
# search links easier in the downstream app.
|
41
|
+
# @param record [MARC::Record]
|
42
|
+
# @return [Hash]
|
43
|
+
def show_query_map(record)
|
44
|
+
record.fields(%w[830 440]).each_with_object({}) do |field, hash|
|
45
|
+
show_values = title_show_entries(record, field.tag) + [remaining_show_value(field)]
|
46
|
+
|
47
|
+
query_value = trim_punctuation(join_subfields(field, &subfield_in?(%w[a n p])))
|
48
|
+
|
49
|
+
show_values.each do |show_value|
|
50
|
+
hash[show_value] = query_value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
38
55
|
# Values from series fields for display.
|
39
56
|
# @param record [MARC::Record]
|
40
57
|
# @param relator_map [Hash]
|
@@ -141,10 +158,10 @@ module PennMARC
|
|
141
158
|
# @note added 2017/04/10: filter out 0 (authority record numbers) added by Alma
|
142
159
|
# @param record [MARC::Record]
|
143
160
|
# @param tags_present [Array<String>]
|
144
|
-
# @return [Array<
|
161
|
+
# @return [Array<String>] array of remaining show entry hashes
|
145
162
|
def remaining_show_entries(record, tags_present)
|
146
163
|
record.fields(tags_present.drop(1)).map do |field|
|
147
|
-
|
164
|
+
remaining_show_value(field)
|
148
165
|
end || []
|
149
166
|
end
|
150
167
|
|
@@ -200,6 +217,13 @@ module PennMARC
|
|
200
217
|
join_subfields(field, &subfield_in?(%w[i a s t n d]))
|
201
218
|
end
|
202
219
|
end
|
220
|
+
|
221
|
+
# Parse the value for a given remaining show field
|
222
|
+
# @param field [MARC::Field]
|
223
|
+
# @return [String]
|
224
|
+
def remaining_show_value(field)
|
225
|
+
join_subfields(field, &subfield_not_in?(%w[0 5 6 8]))
|
226
|
+
end
|
203
227
|
end
|
204
228
|
end
|
205
229
|
end
|
@@ -88,7 +88,6 @@ module PennMARC
|
|
88
88
|
# Single-valued Title, for use in headings. Takes the first {https://www.oclc.org/bibformats/en/2xx/245.html 245}
|
89
89
|
# value. Special consideration for
|
90
90
|
# {https://www.oclc.org/bibformats/en/2xx/245.html#punctuation punctuation practices}.
|
91
|
-
# @todo still consider ǂh? medium, which OCLC doc says DO NOT USE...but that is OCLC...
|
92
91
|
# @todo is punctuation handling still as desired? treatment here is described in spreadsheet from 2011
|
93
92
|
# @param record [MARC::Record]
|
94
93
|
# @return [String] single title for display
|
@@ -98,15 +97,14 @@ module PennMARC
|
|
98
97
|
[format_title(values[:title_or_form]), values[:punctuation], values[:other_info]].compact_blank.join(' ')
|
99
98
|
end
|
100
99
|
|
101
|
-
# Same as show, but with
|
100
|
+
# Same as show, but with all subfields included as found - except for subfield c.
|
102
101
|
# @param record [MARC::Record]
|
103
102
|
# @return [String] detailed title for display
|
104
103
|
def detailed_show(record)
|
105
104
|
field = record.fields('245')&.first
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
values[:inclusive_dates].present? ? [title, values[:inclusive_dates]].compact_blank.join(', ') : title
|
105
|
+
return unless field
|
106
|
+
|
107
|
+
join_subfields(field, &subfield_not_in?(%w[6 8]))
|
110
108
|
end
|
111
109
|
|
112
110
|
# Same structure as show, but linked alternate title.
|
@@ -124,17 +122,6 @@ module PennMARC
|
|
124
122
|
[format_title(values[:title_or_form]), values[:punctuation], values[:other_info]].compact_blank.join(' ')
|
125
123
|
end
|
126
124
|
|
127
|
-
# Title statement of responsibility (field 245, subfield c) and linked alternate for display.
|
128
|
-
# See https://www.oclc.org/bibformats/en/2xx/245.html#subfieldc for examples
|
129
|
-
# @param [MARC::Record] record
|
130
|
-
# @return [Array<String>] statement of responsibility and linked alternate
|
131
|
-
def statement_of_responsibility_show(record)
|
132
|
-
field = record.fields('245').first
|
133
|
-
statement = field&.find { |sf| sf.code == 'c' }&.value
|
134
|
-
alternate_statement = linked_alternate(record, '245', &subfield_in?(%w[c]))&.first
|
135
|
-
[statement, alternate_statement].compact_blank
|
136
|
-
end
|
137
|
-
|
138
125
|
# Canonical title with non-filing characters relocated to the end.
|
139
126
|
#
|
140
127
|
# @note Currently we index two "title sort" fields: title_nssort (ssort type - regex token filter applied) and
|
@@ -269,7 +256,6 @@ module PennMARC
|
|
269
256
|
title_or_form = field.find_all(&subfield_in?(%w[a k]))
|
270
257
|
.map { |sf| trim_trailing(:comma, trim_trailing(:slash, sf.value).rstrip) }
|
271
258
|
.first || ''
|
272
|
-
inclusive_dates = field.find { |sf| sf.code == 'f' }&.value
|
273
259
|
other_info = field.find_all(&subfield_in?(%w[b n p]))
|
274
260
|
.map { |sf| trim_trailing(:slash, sf.value) }
|
275
261
|
.join(' ')
|
@@ -283,7 +269,6 @@ module PennMARC
|
|
283
269
|
[title_punctuation, medium_punctuation].include?(':') ? ':' : nil
|
284
270
|
end
|
285
271
|
{ title_or_form: title_or_form,
|
286
|
-
inclusive_dates: inclusive_dates,
|
287
272
|
other_info: other_info,
|
288
273
|
punctuation: punctuation }
|
289
274
|
end
|
@@ -62,9 +62,9 @@ britimp:
|
|
62
62
|
display: Athenaeum of Philadelphia - British Imprints
|
63
63
|
aeon: true
|
64
64
|
carpco:
|
65
|
-
specific_location:
|
66
|
-
library:
|
67
|
-
display:
|
65
|
+
specific_location: Carpenters' Company of the City and County of Philadelphia
|
66
|
+
library: Special Collections
|
67
|
+
display: Carpenters' Company of the City and County of Philadelphia
|
68
68
|
aeon: true
|
69
69
|
catoffice:
|
70
70
|
specific_location: Athenaeum of Philadelphia - Cataloging Office
|
@@ -160,12 +160,16 @@ vismatl:
|
|
160
160
|
aeon: true
|
161
161
|
athstor:
|
162
162
|
specific_location: LIBRA - Athenaeum of Philadelphia
|
163
|
-
library:
|
163
|
+
library:
|
164
|
+
- LIBRA
|
165
|
+
- Athenaeum of Philadelphia
|
164
166
|
display: LIBRA - Athenaeum of Philadelphia
|
165
167
|
aeon: true
|
166
168
|
athstorcir:
|
167
169
|
specific_location: LIBRA - Athenaeum of Philadelphia Circulating
|
168
|
-
library:
|
170
|
+
library:
|
171
|
+
- LIBRA
|
172
|
+
- Athenaeum of Philadelphia
|
169
173
|
display: LIBRA - Athenaeum of Philadelphia Circulating
|
170
174
|
biom:
|
171
175
|
specific_location: Holman Biotech Commons
|
@@ -594,10 +598,6 @@ dncirc:
|
|
594
598
|
- Health Sciences Libraries
|
595
599
|
- Levy Dental Medicine Library
|
596
600
|
display: Levy Dental Medicine Library - Circulation
|
597
|
-
easiacmx:
|
598
|
-
specific_location: Van Pelt - East Asia Comics
|
599
|
-
library: Van Pelt-Dietrich Library Center
|
600
|
-
display: Van Pelt - East Asia Comics
|
601
601
|
easiaover:
|
602
602
|
specific_location: Van Pelt - East Asia Oversize
|
603
603
|
library: Van Pelt-Dietrich Library Center
|
data/lib/pennmarc/version.rb
CHANGED
@@ -15,6 +15,24 @@ describe 'PennMARC::Series' do
|
|
15
15
|
marc_record fields: [marc_field(tag: '666', subfields: { a: 'test' })]
|
16
16
|
end
|
17
17
|
|
18
|
+
describe '.show_query_map' do
|
19
|
+
let(:record) do
|
20
|
+
marc_record fields: [
|
21
|
+
marc_field(tag: '440', subfields: { a: 'Teachings of the feathered pillow', n: 'number', p: 'section' }),
|
22
|
+
marc_field(tag: '490', subfields: { a: 'Ignored' }),
|
23
|
+
marc_field(tag: '830', subfields: { a: 'International litigation in practice', v: 'volume 13.' })
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns expected hash' do
|
28
|
+
expect(helper.show_query_map(record)).to eq(
|
29
|
+
{ 'Teachings of the feathered pillow number section' => 'Teachings of the feathered pillow number section',
|
30
|
+
'Teachings of the feathered pillow section number' => 'Teachings of the feathered pillow number section',
|
31
|
+
'International litigation in practice volume 13.' => 'International litigation in practice' }
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
18
36
|
describe '.show' do
|
19
37
|
it 'returns the series values for display' do
|
20
38
|
expect(helper.show(record, relator_map: mapping)).to contain_exactly(
|
@@ -139,15 +139,44 @@ describe 'PennMARC::Title' do
|
|
139
139
|
end
|
140
140
|
|
141
141
|
describe '.detailed_show' do
|
142
|
-
let(:record) do
|
143
|
-
marc_record fields: [
|
144
|
-
marc_field(tag: '245', subfields: { k: 'Letters', f: '1972-1982', b: 'to Lewis Mumford.' })
|
145
|
-
]
|
146
|
-
end
|
147
|
-
|
148
142
|
context 'with subfields ǂk, ǂf and ǂc' do
|
143
|
+
let(:record) do
|
144
|
+
marc_record fields: [
|
145
|
+
marc_field(tag: '245', subfields: { k: 'Letters,', f: '1972-1982,', b: 'to Lewis Mumford.' })
|
146
|
+
]
|
147
|
+
end
|
148
|
+
|
149
149
|
it 'returns detailed title values' do
|
150
|
-
expect(helper.detailed_show(record)).to eq 'Letters to Lewis Mumford
|
150
|
+
expect(helper.detailed_show(record)).to eq 'Letters, 1972-1982, to Lewis Mumford.'
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'with subfields ǂk and ǂb' do
|
155
|
+
let(:record) do
|
156
|
+
marc_record fields: [
|
157
|
+
marc_field(tag: '245', subfields: { k: 'Letters', b: 'to Lewis Mumford.' })
|
158
|
+
]
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'returns title value without dates' do
|
162
|
+
expect(helper.detailed_show(record)).to eq 'Letters to Lewis Mumford.'
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# e.g., 9977704838303681
|
167
|
+
context 'with ǂa containing an " : " as well as inclusive dates' do
|
168
|
+
let(:record) do
|
169
|
+
marc_record fields: [
|
170
|
+
marc_field(tag: '245', subfields: { a: 'The frugal housewife : ',
|
171
|
+
b: 'dedicated to those who are not ashamed of economy, ',
|
172
|
+
f: '1830 / ', c: 'by the author of Hobomok.' })
|
173
|
+
]
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'returns single title value with text from ǂa and ǂn' do
|
177
|
+
expect(helper.detailed_show(record)).to eq(
|
178
|
+
'The frugal housewife : dedicated to those who are not ashamed of economy, 1830 / by the author of Hobomok.'
|
179
|
+
)
|
151
180
|
end
|
152
181
|
end
|
153
182
|
end
|
@@ -179,25 +208,6 @@ describe 'PennMARC::Title' do
|
|
179
208
|
end
|
180
209
|
end
|
181
210
|
|
182
|
-
describe '.statement_of_responsibility_show' do
|
183
|
-
let(:record) do
|
184
|
-
marc_record fields: [marc_field(tag: '245', subfields: { c: 'statement of responsibility' }),
|
185
|
-
marc_field(tag: '880', subfields: { '6': '245', c: 'déclaration de responsabilité' })]
|
186
|
-
end
|
187
|
-
|
188
|
-
context 'with ǂc defined' do
|
189
|
-
it 'returns statement of responsibility' do
|
190
|
-
expect(helper.statement_of_responsibility_show(record)).to include 'statement of responsibility'
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
context 'with linked alternate of 245 ǂc defined' do
|
195
|
-
it 'returns alternate statement of responsibility' do
|
196
|
-
expect(helper.statement_of_responsibility_show(record)).to include 'déclaration de responsabilité'
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
211
|
describe '.sort' do
|
202
212
|
context 'with a record with a valid indicator2 value' do
|
203
213
|
let(:record) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pennmarc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Kanning
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2024-
|
15
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|