pennmarc 1.0.21 → 1.0.22
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/lib/pennmarc/helpers/location.rb +6 -12
- data/lib/pennmarc/version.rb +1 -1
- data/spec/lib/pennmarc/helpers/location_spec.rb +18 -13
- 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: d9222d0bfd9ca8704ec91ef01d1e27ce90711506b648f2d0006fc2270dd6d82d
|
4
|
+
data.tar.gz: c250833003d00f8d2b12a6c8e4043d9eadcdaaa33bba8ae70468e3210cdb1780
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
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.
|
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
|
-
|
144
|
-
|
145
|
-
override[override.keys.first][:specific_location]
|
139
|
+
override&.last&.dig(:specific_location)
|
146
140
|
end
|
147
141
|
end
|
148
142
|
end
|
data/lib/pennmarc/version.rb
CHANGED
@@ -110,21 +110,26 @@ describe 'PennMARC::Location' do
|
|
110
110
|
)
|
111
111
|
end
|
112
112
|
end
|
113
|
-
end
|
114
113
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
-
|
126
|
-
|
127
|
-
|
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.
|
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-
|
13
|
+
date: 2024-05-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|