pennmarc 1.4.13 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef3dc2e703536d342d55adee946f7ff062f608d8eb9fde3cf94f96c13370e06f
4
- data.tar.gz: b98eeb2932eb8e1f2f353479748071f11988bae0d4f4b3946a3b4367f97a99a1
3
+ metadata.gz: 902d5be008d40346163cd1509d45ffa7c02dcec24767ef72e8000a54560a30a1
4
+ data.tar.gz: 548fc5f72df6f41fa4e1da1db956c758b1d5d85ccbd9899fb1eb1e5b78863791
5
5
  SHA512:
6
- metadata.gz: 7c29038b83ce92f6d95168e1d0268f6d3a27c30d4baa7f3fa13c5a2257b8e91b705bc8d921eec6cb9ab3f979c1311a098699acaa33d16b9f9b87d9a8820d8333
7
- data.tar.gz: 304937c1e2146d111dd314d64b6d5d78a942a3b9fbe6cd987ccc6e4f6c38937543bd67e6b3b17028d94c39d4fe8bc1f903ebec83da221d7e579dc77cb4fe3336
6
+ metadata.gz: 0adc28d4ee62c8ad08d18d2724416f88966042dbb764048cf60c261ee3ab772f09b5ca3a9eed3faa1047e65b9437b0924844884d93e220b41f4d85e8efcfc9bb
7
+ data.tar.gz: a516e3b2e11864e86d4d2208f4e89bc61aa4d20d6ff88be78e5642d19b3d075b05092acf36e576d1edfb10725ae9cfe222bfd0773aa22f168c0b3d79eecac3eb
@@ -18,7 +18,7 @@ module PennMARC
18
18
  editions = record.fields('250').map do |field|
19
19
  join_subfields(field, &subfield_not_in?(%w[6 7 8]))
20
20
  end
21
- editions += linked_alternate_not_6_or_8(record, '250') if with_alternate
21
+ editions += linked_alternate_not_6_7_8(record, '250') if with_alternate
22
22
 
23
23
  editions.uniq
24
24
  end
@@ -70,10 +70,8 @@ module PennMARC
70
70
  term_hash = build_subject_hash(field, override)
71
71
  next if term_hash.blank? || term_hash[:count]&.zero?
72
72
 
73
- heading = format_term type: :facet, term: term_hash
74
- main_term = trim_trailing(:period, term_hash[:subfield_a]) if term_hash[:lcsh] && term_hash[:subfield_a]
75
-
76
- [heading, main_term].compact_blank
73
+ [format_term(type: :facet, term: term_hash),
74
+ main_term_for(field: field, term: term_hash, override: override)].compact_blank
77
75
  }.flatten.uniq
78
76
  end
79
77
 
@@ -90,7 +88,7 @@ module PennMARC
90
88
  next if term_hash.blank? || term_hash[:count]&.zero?
91
89
 
92
90
  [format_term(type: :display, term: term_hash),
93
- main_term_for(field: field, term: term_hash, override: override)].compact_blank
91
+ main_term_for(field: field, term: term_hash, override: override, append_period: true)].compact_blank
94
92
  }.flatten.uniq
95
93
  end
96
94
 
@@ -195,11 +193,13 @@ module PennMARC
195
193
  # @param field [MARC::DataField]
196
194
  # @param term [Hash]
197
195
  # @param override [Boolean]
196
+ # @param append_period [Boolean] for display case usage
198
197
  # @return [String, nil]
199
- def main_term_for(field:, term:, override:)
198
+ def main_term_for(field:, term:, override:, append_period: false)
200
199
  return unless term[:lcsh] && term[:subfield_a]
201
200
 
202
- subfield_a_term = "#{trim_trailing(:period, term[:subfield_a])}."
201
+ subfield_a_term = trim_trailing(:period, term[:subfield_a])
202
+ subfield_a_term = "#{trim_trailing(:period, term[:subfield_a])}." if append_period
203
203
  return HeadingControl.term_override(subfield_a_term) if override && HeadingControl.overrideable_field?(field)
204
204
 
205
205
  subfield_a_term
data/lib/pennmarc/util.rb CHANGED
@@ -194,27 +194,26 @@ module PennMARC
194
194
  end
195
195
  end
196
196
 
197
- # Common case of wanting to extract all the subfields besides 6 or 8,
198
- # from 880 datafield that has a particular subfield 6 value. We exclude 6 because
199
- # that value is the linkage ID itself and 8 because... IDK
197
+ # Common case of wanting to extract all the subfields besides 6, 7 or 8,
198
+ # from 880 datafield that has a particular subfield 6 value.
200
199
  # @param record [MARC::Record]
201
200
  # @param subfield6_value [String, Array] either a string to look for in sub6 or an array of them
202
201
  # @return [Array] array of linked alternates without 8 or 6 values
203
- def linked_alternate_not_6_or_8(record, subfield6_value)
204
- excluded_subfields = %w[6 8]
202
+ def linked_alternate_not_6_7_8(record, subfield6_value)
203
+ excluded_subfields = %w[6 7 8]
205
204
  linked_alternate(record, subfield6_value) do |sf|
206
205
  excluded_subfields.exclude?(sf.code)
207
206
  end
208
207
  end
209
208
 
210
- # Returns the non-6,8 subfields from a datafield and its 880 link.
209
+ # Returns the non-6,7,8 subfields from a datafield and its 880 link.
211
210
  # @param record [MARC::Record]
212
211
  # @param tag [String]
213
212
  # @return [Array<String>] values
214
213
  def datafield_and_linked_alternate(record, tag)
215
214
  record.fields(tag).filter_map { |field|
216
- join_subfields(field, &subfield_not_in?(%w[6 8]))
217
- } + linked_alternate_not_6_or_8(record, tag)
215
+ join_subfields(field, &subfield_not_in?(%w[6 7 8]))
216
+ } + linked_alternate_not_6_7_8(record, tag)
218
217
  end
219
218
 
220
219
  # Get the substring of a string up to a given target character
@@ -283,7 +282,7 @@ module PennMARC
283
282
  next unless field.any? { |sf| sf.code == 'a' && sf.value =~ /^(#{prefix}|%#{prefix})/ }
284
283
 
285
284
  elements = field.select(&subfield_in?(%w[a])).map { |sf| sf.value.gsub(/^%?#{prefix}/, '') }
286
- elements << join_subfields(field, &subfield_not_in?(%w[a 6 8 e w 5]))
285
+ elements << join_subfields(field, &subfield_not_in?(%w[a 6 7 8 e w 5]))
287
286
  join_and_squish elements
288
287
  }.uniq
289
288
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PennMARC
4
- VERSION = '1.4.13'
4
+ VERSION = '1.5.1'
5
5
  end
@@ -200,6 +200,18 @@ describe 'PennMARC::Subject' do
200
200
  end
201
201
  end
202
202
 
203
+ context 'with a record with a decomposed heading subject to overriding' do
204
+ let(:replace_term) { PennMARC::Mappers.heading_overrides.keys[2] }
205
+ let(:fields) do
206
+ [marc_field(tag: '650', indicator2: '0', subfields: { a: replace_term, v: 'Juvenile Literature' })]
207
+ end
208
+
209
+ it 'performs replacement on all eligible headings' do
210
+ replaced_term = PennMARC::HeadingControl.term_override(replace_term)
211
+ expect(values).to contain_exactly "#{replaced_term}--Juvenile Literature", replaced_term
212
+ end
213
+ end
214
+
203
215
  context 'with a record with fields not subject to overriding' do
204
216
  let(:replace_term) { PennMARC::Mappers.heading_overrides.keys[2] }
205
217
  let(:fields) do
@@ -142,11 +142,12 @@ describe 'PennMARC::Util' do
142
142
  describe '.linked_alternate_not_6_or_8' do
143
143
  let(:record) do
144
144
  marc_record fields: [marc_field(tag: '510', subfields: { a: 'Perkins', b: 'Test' }),
145
- marc_field(tag: '880', subfields: { '6': '510', '8': 'Ignore', a: 'Snikrep', b: 'Tset' })]
145
+ marc_field(tag: '880', subfields: { '6': '510', '7': 'blah', '8': 'Ignore', a: 'Snikrep',
146
+ b: 'Tset' })]
146
147
  end
147
148
 
148
- it 'returns the linked alternate without 6 or 8' do
149
- expect(util.linked_alternate_not_6_or_8(record, '510')).to contain_exactly('Snikrep Tset')
149
+ it 'returns the linked alternate without 6, 7 or 8' do
150
+ expect(util.linked_alternate_not_6_7_8(record, '510')).to contain_exactly('Snikrep Tset')
150
151
  end
151
152
  end
152
153
 
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.13
4
+ version: 1.5.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: 2026-11-12 00:00:00.000000000 Z
15
+ date: 2026-12-02 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport