pennmarc 1.4.12 → 1.4.13

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: ed8428b56d9ed1e81912885aef968ba0f104f647491afd2498e4e3893748b9c4
4
- data.tar.gz: fead988cff9b7cb56201510a7eba63152dd16f8e691ece753d6b306158afc53e
3
+ metadata.gz: ef3dc2e703536d342d55adee946f7ff062f608d8eb9fde3cf94f96c13370e06f
4
+ data.tar.gz: b98eeb2932eb8e1f2f353479748071f11988bae0d4f4b3946a3b4367f97a99a1
5
5
  SHA512:
6
- metadata.gz: 21e44d07cd4bde553e717f84a944dd297055f94518a27a14f9d9fb3d64c3f1f9172746af0ba0d9e1549fb69198a7ef5f5c23b5323189bba500d04cc5ace40a32
7
- data.tar.gz: caaf7925c9d91833c92ba25524dc70f4bad6f4b31c7640ff35823f20477d5d9c7b7449770bd8ffdcd66fde1a39460ddbad58666d71eeeb22ca3b225f5da72d9a
6
+ metadata.gz: 7c29038b83ce92f6d95168e1d0268f6d3a27c30d4baa7f3fa13c5a2257b8e91b705bc8d921eec6cb9ab3f979c1311a098699acaa33d16b9f9b87d9a8820d8333
7
+ data.tar.gz: 304937c1e2146d111dd314d64b6d5d78a942a3b9fbe6cd987ccc6e4f6c38937543bd67e6b3b17028d94c39d4fe8bc1f903ebec83da221d7e579dc77cb4fe3336
data/README.md CHANGED
@@ -20,14 +20,14 @@ This gem provides configuration as well as a method for overriding and removing
20
20
  you can remove or replace the configured terms like so:
21
21
 
22
22
  ```ruby
23
- improved_values = PennMARC::HeadingControl.term_override(values)
23
+ improved_value = PennMARC::HeadingControl.term_override(value)
24
24
  ```
25
25
 
26
- This will remove any elements of the `values` array that include any terms defined in [`headings_remove.yml`](lib/pennmarc/mappings/headings_remove.yml) and
27
- replace any terms defined in the [`headings_override.yml`](lib/pennmarc/mappings/headings_override.yml) file.
26
+ This will remove the term (return nil) if `value` is included in `headings_remove.yml`](lib/pennmarc/mappings/headings_remove.yml) and replace it if it matches any of the terms defined
27
+ in the [`headings_override.yml`](lib/pennmarc/mappings/headings_override.yml) file.
28
28
 
29
29
  By default, terms are replaced for `Subject#*show` and `Subject#facet` methods. You can bypass the default overriding on
30
- on these methods by passing `override: false`.
30
+ on these methods by passing `override: false`. Decomposed LCSH headings are also subject to overriding.
31
31
 
32
32
  ## Development
33
33
 
@@ -89,10 +89,8 @@ module PennMARC
89
89
  term_hash = build_subject_hash(field, override)
90
90
  next if term_hash.blank? || term_hash[:count]&.zero?
91
91
 
92
- heading = format_term type: :display, term: term_hash
93
- main_term = "#{trim_trailing(:period, term_hash[:subfield_a])}." if term_hash[:lcsh] && term_hash[:subfield_a]
94
-
95
- [heading, main_term].compact_blank
92
+ [format_term(type: :display, term: term_hash),
93
+ main_term_for(field: field, term: term_hash, override: override)].compact_blank
96
94
  }.flatten.uniq
97
95
  end
98
96
 
@@ -193,6 +191,20 @@ module PennMARC
193
191
  term[:override] ? HeadingControl.term_override(value) : value
194
192
  end
195
193
 
194
+ # Process and return the "main term" (sf a) from a field, overriding if necessary
195
+ # @param field [MARC::DataField]
196
+ # @param term [Hash]
197
+ # @param override [Boolean]
198
+ # @return [String, nil]
199
+ def main_term_for(field:, term:, override:)
200
+ return unless term[:lcsh] && term[:subfield_a]
201
+
202
+ subfield_a_term = "#{trim_trailing(:period, term[:subfield_a])}."
203
+ return HeadingControl.term_override(subfield_a_term) if override && HeadingControl.overrideable_field?(field)
204
+
205
+ subfield_a_term
206
+ end
207
+
196
208
  # Is a field intended for display in a general subject field? To be included, the field tag is in either
197
209
  # {DISPLAY_TAGS} or {LOCAL_TAGS}, and has an indicator 2 value that is in {VALID_SOURCE_INDICATORS}. If
198
210
  # indicator 2 is '7' - indicating "source specified", the specified source must be in our approved source code
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PennMARC
4
- VERSION = '1.4.12'
4
+ VERSION = '1.4.13'
5
5
  end
@@ -359,19 +359,24 @@ describe 'PennMARC::Subject' do
359
359
 
360
360
  context 'with headings that contain terms for removal and replacement' do
361
361
  let(:fields) do
362
- [marc_field(tag: '650', subfields: { a: 'History.' }),
363
- marc_field(tag: '650', subfields: { a: PennMARC::Mappers.headings_to_remove.first }),
364
- marc_field(tag: '650', subfields: { a: PennMARC::Mappers.heading_overrides.first[0] })]
362
+ [marc_field(tag: '650', subfields: { a: PennMARC::Mappers.headings_to_remove.first }),
363
+ marc_field(tag: '650', indicator2: '0',
364
+ subfields: { a: PennMARC::Mappers.heading_overrides.first[0],
365
+ z: 'United States', x: 'History' })]
365
366
  end
366
367
 
367
368
  it 'removes and replaces terms as expected' do
368
- expect(values).to contain_exactly 'History.', "#{PennMARC::Mappers.heading_overrides.first[1]}."
369
+ expect(values).to contain_exactly(
370
+ "#{PennMARC::Mappers.heading_overrides.first[1]}--United States--History.",
371
+ "#{PennMARC::Mappers.heading_overrides.first[1]}."
372
+ )
369
373
  end
370
374
 
371
375
  it 'does not remove or replace terms if override param is false' do
372
376
  expect(helper.show(record, override: false)).to contain_exactly(
373
- 'History.', "#{PennMARC::Mappers.headings_to_remove.first}.",
374
- "#{PennMARC::Mappers.heading_overrides.first[0]}."
377
+ "#{PennMARC::Mappers.headings_to_remove.first}.",
378
+ "#{PennMARC::Mappers.heading_overrides.first[0]}.",
379
+ "#{PennMARC::Mappers.heading_overrides.first[0]}--United States--History."
375
380
  )
376
381
  end
377
382
  end
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.12
4
+ version: 1.4.13
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-11 00:00:00.000000000 Z
15
+ date: 2026-11-12 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport