pennmarc 1.2.7 → 1.2.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 920cef15f1cac246074afedbe31a0f456ee81d9e9bcbb04c0dde024901d925db
4
- data.tar.gz: edf42bff8a460373147e52e4cc3bf1c277655486635952ebf6604bc83fab5912
3
+ metadata.gz: 3b8115ac66bc671e876756b8f20e16fe119373cce76cd17cf00e94d9d9a5c1ad
4
+ data.tar.gz: 584620d7645a8cef217415def55a66f3f611fb4e9611d61d4e5b330dbe21bf2e
5
5
  SHA512:
6
- metadata.gz: 614f6a26980656a8030bdaf28b0c901a9d5a841e0bad65b1e0455e9f09b3071e6c1f379ea3a54c4267c66403efdef3de0e7be4862c9e05c84d3d1f228921ccd8
7
- data.tar.gz: 6b85c2040e4b9dbb0bb95b5e5d0914ada840399338246b54ee94b338ebb7c7c58dd32a22d9ae425337b6ce7074c03124e826a7b4b117bc40cc3d05405cfe2e29
6
+ metadata.gz: 1a18c1297db9093b61e974cfc8593bdbcf34c55097427a17a6eed60322ee0789efa9c81ed96ee13f7662d617378392aa6409b496f142b07561616d6d02cf0f32
7
+ data.tar.gz: '089da372f1421c4a8dc524c24d245be4b1a80b491a87eb5ed30f7c4feb88329bc6f9981b421fab3638b8bf48012b71d7d2012a4d83a36df804861c2c87af374c'
@@ -123,7 +123,7 @@ module PennMARC
123
123
  }.first
124
124
  return unless field
125
125
 
126
- values = title_values(field)
126
+ values = title_values(field, include_subfield_c: true)
127
127
  [format_title(values[:title_or_form]), values[:punctuation], values[:other_info]].compact_blank.join(' ')
128
128
  end
129
129
 
@@ -253,17 +253,17 @@ module PennMARC
253
253
 
254
254
  # Extract title values from provided 245 subfields. Main title components are the following:
255
255
  # - title_or_form: subfields a and k
256
- # - inclusive_dates: subfield c
257
- # - other_info: subfields b, n, and p
256
+ # - other_info: subfields b, n, and p (for alternate title, include subfield c)
258
257
  # https://www.oclc.org/bibformats/en/2xx/245.html
259
258
  #
260
259
  # @param field [MARC::Field]
260
+ # @param include_subfield_c [Boolean]
261
261
  # @return [Hash] title values
262
- def title_values(field)
262
+ def title_values(field, include_subfield_c: false)
263
263
  title_or_form = field.find_all(&subfield_in?(%w[a k]))
264
264
  .map { |sf| trim_trailing(:comma, trim_trailing(:slash, sf.value).rstrip) }
265
265
  .first || ''
266
- other_info = field.find_all(&subfield_in?(%w[b n p]))
266
+ other_info = field.find_all(&subfield_in?(include_subfield_c ? %w[b c n p] : %w[b n p]))
267
267
  .map { |sf| trim_trailing(:slash, sf.value) }
268
268
  .join(' ')
269
269
  title_punctuation = title_or_form.last
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PennMARC
4
- VERSION = '1.2.7'
4
+ VERSION = '1.2.8'
5
5
  end
@@ -117,6 +117,15 @@ describe 'PennMARC::Title' do
117
117
  end
118
118
  end
119
119
 
120
+ context 'with ǂa, ǂc and ǂn defined' do
121
+ let(:fields) { [marc_field(tag: '245', subfields: subfields)] }
122
+ let(:subfields) { { a: 'Five Decades of MARC usage', c: 'Should not be shown', n: 'Part One' } }
123
+
124
+ it 'returns single title value with text from ǂa and ǂn but not #c' do
125
+ expect(helper.show(record)).to eq 'Five Decades of MARC usage Part One'
126
+ end
127
+ end
128
+
120
129
  context 'with no ǂa but a ǂk and ǂn defined' do
121
130
  let(:fields) { [marc_field(tag: '245', subfields: subfields)] }
122
131
  let(:subfields) { { k: 'journals', n: 'Part One' } }
@@ -182,17 +191,29 @@ describe 'PennMARC::Title' do
182
191
  end
183
192
 
184
193
  describe '.alternate_show' do
185
- let(:fields) do
186
- [marc_field(tag: '245', subfields: { k: 'Letters', b: 'to Lewis Mumford. ' }),
187
- marc_field(tag: '880', subfields: { '6': '245', k: 'Lettres', b: 'à Lewis Mumford.' })]
188
- end
189
-
190
194
  context 'with subfields ǂk and ǂb' do
195
+ let(:fields) do
196
+ [marc_field(tag: '245', subfields: { k: 'Letters', b: 'to Lewis Mumford. ' }),
197
+ marc_field(tag: '880', subfields: { '6': '245', k: 'Lettres', b: 'à Lewis Mumford.' })]
198
+ end
199
+
191
200
  it 'returns alternate title values' do
192
201
  expect(helper.alternate_show(record)).to eq 'Lettres à Lewis Mumford.'
193
202
  end
194
203
  end
195
204
 
205
+ context 'with subfields ǂk, ǂb and ǂc' do
206
+ let(:fields) do
207
+ [marc_field(tag: '245', subfields: { k: 'Letters', b: 'to Lewis Mumford. ' }),
208
+ marc_field(tag: '880', subfields: { '6': '245', k: 'Lettres',
209
+ b: 'à Lewis Mumford.', c: 'Additional copy' })]
210
+ end
211
+
212
+ it 'returns alternate title values' do
213
+ expect(helper.alternate_show(record)).to eq 'Lettres à Lewis Mumford. Additional copy'
214
+ end
215
+ end
216
+
196
217
  context 'when 880 field is not present' do
197
218
  let(:fields) do
198
219
  [marc_field(tag: '245', subfields: { k: 'Letters', b: 'to Lewis Mumford. ' })]
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.2.7
4
+ version: 1.2.8
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-12-23 00:00:00.000000000 Z
15
+ date: 2025-01-08 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport