pennmarc 1.0.21 → 1.0.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec3fde9cb69168e9d4f3221df750bc9b6345409a2e413e0b7117f66f7e1be843
4
- data.tar.gz: 32cb166f43c18235282e10927c9589e9b62b4889c247adf4628a8459a5c4e47c
3
+ metadata.gz: d9222d0bfd9ca8704ec91ef01d1e27ce90711506b648f2d0006fc2270dd6d82d
4
+ data.tar.gz: c250833003d00f8d2b12a6c8e4043d9eadcdaaa33bba8ae70468e3210cdb1780
5
5
  SHA512:
6
- metadata.gz: 3e114ad5839e035a3297f45548a4dccad0bd3b752b01126612307c0cb08d30cf2d2da7a752f6049a48014e9145c7fdb882294a936b998f5d6c644154609ec21d
7
- data.tar.gz: 3d2874d2d62231efb4d887ae14fc69ccdc7bd3ca3d4fa929a56c6a7b39b121f10cfc34cb1222e80fdbcac38395b9279d3c05b130c166fe011f93ff7b4a0fea74
6
+ metadata.gz: b9a1c42746b7d1448df78aad4528c1bf20731feeadc073e4937d0722bcfbed6ec42c104ae2d1241cf31830e6c7e50b0b6ab125140cf9d232511530a7b82861ef
7
+ data.tar.gz: c143ab4e9056f6a62a06a90d01938d70a6b7088704930e0dcf402c392954c08164a9821f39f35d03d07023393ca1d64844fa56d16522155ec55ca4a9a35fcf9b
@@ -47,7 +47,7 @@ module PennMARC
47
47
 
48
48
  locations = record.fields(tag).flat_map { |field|
49
49
  field.filter_map { |subfield|
50
- # skip unless subfield code does not match enriched marc tag subfield code
50
+ # skip unless subfield matches enriched marc tag subfield code
51
51
  next unless subfield.code == location_code_sf
52
52
 
53
53
  location_code = subfield.value
@@ -57,11 +57,7 @@ module PennMARC
57
57
  override = specific_location_override(display_value: display_value, location_code: location_code,
58
58
  field: field, call_num_sf: call_num_sf)
59
59
 
60
- if override.present?
61
- override
62
- else
63
- location_map[location_code.to_sym][display_value.to_sym]
64
- end
60
+ override || location_map[location_code.to_sym][display_value.to_sym]
65
61
  }.flatten.compact_blank
66
62
  }.uniq
67
63
  if record.tags.intersect?([Enriched::Pub::ELEC_INVENTORY_TAG, Enriched::Api::ELEC_INVENTORY_TAG])
@@ -124,25 +120,23 @@ module PennMARC
124
120
 
125
121
  # Retrieves a specific location override based on location code and call number. Specific location overrides are
126
122
  # located in `location_overrides.yml`.
127
- # @param [String] display_value
123
+ # @param [String | Symbol] display_value
128
124
  # @param [String] location_code
129
125
  # @param [MARC::Field] field
130
126
  # @param [String] call_num_sf
131
127
  # @return [String, Nil]
132
128
  def specific_location_override(display_value:, location_code:, field:, call_num_sf:)
133
- return unless display_value == :specific_location
129
+ return unless display_value.to_sym == :specific_location
134
130
 
135
131
  locations_overrides = Mappers.location_overrides
136
132
 
137
133
  call_numbers = subfield_values(field, call_num_sf)
138
134
 
139
- override = locations_overrides.select do |_key, value|
135
+ override = locations_overrides.find do |_key, value|
140
136
  value[:location_code] == location_code && call_numbers.any? { |num| num.match?(value[:call_num_pattern]) }
141
137
  end
142
138
 
143
- return if override.blank?
144
-
145
- override[override.keys.first][:specific_location]
139
+ override&.last&.dig(:specific_location)
146
140
  end
147
141
  end
148
142
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PennMARC
4
- VERSION = '1.0.21'
4
+ VERSION = '1.0.22'
5
5
  end
@@ -110,21 +110,26 @@ describe 'PennMARC::Location' do
110
110
  )
111
111
  end
112
112
  end
113
- end
114
113
 
115
- context 'with a specific location override' do
116
- let(:record) do
117
- marc_record(fields: [marc_field(tag: enriched_marc::Pub::ITEM_TAG,
118
- subfields: { enriched_marc::Pub::ITEM_CURRENT_LOCATION => 'vanp',
119
- enriched_marc::Pub::ITEM_CALL_NUMBER => 'ML3534 .D85 1984' }),
120
- marc_field(tag: enriched_marc::Pub::ITEM_TAG,
121
- subfields: { enriched_marc::Pub::ITEM_CURRENT_LOCATION => 'stor',
122
- enriched_marc::Pub::ITEM_CALL_NUMBER => 'L3534 .D85 1984' })])
123
- end
114
+ context 'with a specific location override' do
115
+ let(:record) do
116
+ marc_record(fields: [marc_field(tag: enriched_marc::Pub::ITEM_TAG,
117
+ subfields: { enriched_marc::Pub::ITEM_CURRENT_LOCATION => 'vanp',
118
+ enriched_marc::Pub::ITEM_CALL_NUMBER => 'ML3534 .D85 1984' }),
119
+ marc_field(tag: enriched_marc::Pub::ITEM_TAG,
120
+ subfields: { enriched_marc::Pub::ITEM_CURRENT_LOCATION => 'stor',
121
+ enriched_marc::Pub::ITEM_CALL_NUMBER => 'L3534 .D85 1984' })])
122
+ end
124
123
 
125
- it 'returns expected values' do
126
- expect(helper.location(record: record, display_value: :specific_location, location_map: mapping))
127
- .to(contain_exactly(PennMARC::Mappers.location_overrides[:albrecht][:specific_location], 'LIBRA'))
124
+ it 'returns expected values' do
125
+ expect(helper.location(record: record, display_value: :specific_location, location_map: mapping))
126
+ .to(contain_exactly(PennMARC::Mappers.location_overrides[:albrecht][:specific_location], 'LIBRA'))
127
+ end
128
+
129
+ it 'returns expected values when receiving a string for display_value' do
130
+ expect(helper.location(record: record, display_value: 'specific_location', location_map: mapping))
131
+ .to(contain_exactly(PennMARC::Mappers.location_overrides[:albrecht][:specific_location], 'LIBRA'))
132
+ end
128
133
  end
129
134
  end
130
135
  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.0.21
4
+ version: 1.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Kanning
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-05-22 00:00:00.000000000 Z
13
+ date: 2024-05-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport