pennmarc 1.0.12.pre1 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +0 -1
- data/.rubocop_todo.yml +13 -5
- data/lib/pennmarc/enriched.rb +93 -0
- data/lib/pennmarc/helpers/access.rb +2 -2
- data/lib/pennmarc/helpers/classification.rb +6 -6
- data/lib/pennmarc/helpers/creator.rb +59 -64
- data/lib/pennmarc/helpers/date.rb +3 -3
- data/lib/pennmarc/helpers/format.rb +7 -7
- data/lib/pennmarc/helpers/helper.rb +1 -1
- data/lib/pennmarc/helpers/inventory.rb +92 -0
- data/lib/pennmarc/helpers/inventory_entry/base.rb +23 -0
- data/lib/pennmarc/helpers/inventory_entry/electronic.rb +20 -0
- data/lib/pennmarc/helpers/inventory_entry/physical.rb +38 -0
- data/lib/pennmarc/helpers/location.rb +19 -14
- data/lib/pennmarc/helpers/subject.rb +6 -6
- data/lib/pennmarc/mappings/locations.yml +4 -0
- data/lib/pennmarc/util.rb +16 -1
- data/lib/pennmarc/version.rb +1 -1
- data/spec/lib/pennmarc/helpers/access_spec.rb +5 -5
- data/spec/lib/pennmarc/helpers/classification_spec.rb +6 -6
- data/spec/lib/pennmarc/helpers/creator_spec.rb +41 -7
- data/spec/lib/pennmarc/helpers/format_spec.rb +4 -4
- data/spec/lib/pennmarc/helpers/inventory_spec.rb +129 -0
- data/spec/lib/pennmarc/helpers/location_spec.rb +40 -9
- data/spec/lib/pennmarc/helpers/subject_spec.rb +37 -13
- metadata +10 -5
- data/lib/pennmarc/enriched_marc.rb +0 -49
@@ -3,10 +3,12 @@
|
|
3
3
|
module PennMARC
|
4
4
|
# Methods that return Library and Location values from Alma enhanced MARC fields
|
5
5
|
class Location < Helper
|
6
|
+
ONLINE_LIBRARY = 'Online library'
|
7
|
+
|
6
8
|
class << self
|
7
9
|
# Retrieves library location from enriched marc 'itm' or 'hld' fields, giving priority to the item location over
|
8
10
|
# the holdings location. Returns item's location if available. Otherwise, returns holding's location.
|
9
|
-
# {PennMARC::
|
11
|
+
# {PennMARC::Enriched} maps enriched marc fields and subfields created during Alma publishing.
|
10
12
|
# @see https://developers.exlibrisgroup.com/alma/apis/docs/bibs/R0VUIC9hbG1hd3MvdjEvYmlicy97bW1zX2lkfQ==/
|
11
13
|
# Alma documentation for these added fields
|
12
14
|
# @param [MARC::Record] record
|
@@ -19,7 +21,7 @@ module PennMARC
|
|
19
21
|
# Retrieves the specific location from enriched marc 'itm' or 'hld' fields, giving priority to the item location
|
20
22
|
# over the holdings location. Returns item library location if available. Otherwise, returns holdings library
|
21
23
|
# location.
|
22
|
-
# {PennMARC::
|
24
|
+
# {PennMARC::Enriched} maps enriched marc fields and subfields created during Alma publishing.
|
23
25
|
# @see https://developers.exlibrisgroup.com/alma/apis/docs/bibs/R0VUIC9hbG1hd3MvdjEvYmlicy97bW1zX2lkfQ==/
|
24
26
|
# Alma documentation for these added fields
|
25
27
|
# @param [MARC::Record] record
|
@@ -31,7 +33,7 @@ module PennMARC
|
|
31
33
|
|
32
34
|
# Base method to retrieve location data from enriched marc 'itm' or 'hld' fields, giving priority to the item
|
33
35
|
# location over the holdings location. Returns item location if available. Otherwise, returns holdings location.
|
34
|
-
# {PennMARC::
|
36
|
+
# {PennMARC::Enriched} maps enriched marc fields and subfields created during Alma publishing.
|
35
37
|
# @see https://developers.exlibrisgroup.com/alma/apis/docs/bibs/R0VUIC9hbG1hd3MvdjEvYmlicy97bW1zX2lkfQ==/
|
36
38
|
# Alma documentation for these added fields
|
37
39
|
# @param [MARC::Record] record
|
@@ -61,7 +63,9 @@ module PennMARC
|
|
61
63
|
location_map[subfield.value.to_sym][display_value.to_sym]
|
62
64
|
}.flatten.compact_blank
|
63
65
|
}.uniq
|
64
|
-
|
66
|
+
if record.tags.intersect?([Enriched::Pub::ELEC_INVENTORY_TAG, Enriched::Api::ELEC_INVENTORY_TAG])
|
67
|
+
locations << ONLINE_LIBRARY
|
68
|
+
end
|
65
69
|
locations
|
66
70
|
end
|
67
71
|
|
@@ -82,17 +86,18 @@ module PennMARC
|
|
82
86
|
# Since item records may reflect locations more accurately, we use them if they exist;
|
83
87
|
# if not, we use the holdings.
|
84
88
|
|
85
|
-
tag = PennMARC::EnrichedMarc::TAG_HOLDING
|
86
|
-
subfield_code = PennMARC::EnrichedMarc::SUB_HOLDING_SHELVING_LOCATION
|
87
|
-
|
88
89
|
# if the record has an enriched item field present, use it
|
89
|
-
if field_defined?(record,
|
90
|
-
tag =
|
91
|
-
subfield_code =
|
92
|
-
#
|
93
|
-
elsif field_defined?(record,
|
94
|
-
tag =
|
95
|
-
subfield_code =
|
90
|
+
if field_defined?(record, Enriched::Pub::ITEM_TAG)
|
91
|
+
tag = Enriched::Pub::ITEM_TAG
|
92
|
+
subfield_code = Enriched::Pub::ITEM_CURRENT_LOCATION
|
93
|
+
# if the record has API inventory tags, use them
|
94
|
+
elsif field_defined?(record, Enriched::Api::PHYS_INVENTORY_TAG)
|
95
|
+
tag = Enriched::Api::PHYS_INVENTORY_TAG
|
96
|
+
subfield_code = Enriched::Api::PHYS_LOCATION_CODE
|
97
|
+
# otherwise use Pub holding tags
|
98
|
+
else
|
99
|
+
tag = Enriched::Pub::PHYS_INVENTORY_TAG
|
100
|
+
subfield_code = Enriched::Pub::PHYS_LOCATION_CODE
|
96
101
|
end
|
97
102
|
|
98
103
|
{ tag: tag, subfield_code: subfield_code }
|
@@ -173,9 +173,9 @@ module PennMARC
|
|
173
173
|
|
174
174
|
case type.to_sym
|
175
175
|
when :facet
|
176
|
-
|
176
|
+
term[:parts].join('--').strip
|
177
177
|
when :display
|
178
|
-
"#{term[:parts].join('--')} #{term[:
|
178
|
+
"#{term[:parts].join('--')} #{term[:append].join(' ')}".strip
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
@@ -227,9 +227,9 @@ module PennMARC
|
|
227
227
|
# @todo do i need all this?
|
228
228
|
# @todo do i need to handle punctuation? see append_new_part
|
229
229
|
# @param [MARC::DataField] field
|
230
|
-
# @return [Hash{Symbol
|
230
|
+
# @return [Hash{Symbol => Integer, Array}, Nil]
|
231
231
|
def build_subject_hash(field)
|
232
|
-
term_info = { count: 0, parts: [], append: [],
|
232
|
+
term_info = { count: 0, parts: [], append: [], uri: nil,
|
233
233
|
local: field.indicator2 == '4' || field.tag.starts_with?('69'), # local subject heading
|
234
234
|
vernacular: field.tag == '880' }
|
235
235
|
field.each do |subfield|
|
@@ -251,8 +251,8 @@ module PennMARC
|
|
251
251
|
# 'e' is relator term; not sure what 'w' is. These are used to append for record-view display only
|
252
252
|
term_info[:append] << subfield.value.strip # TODO: map relator code?
|
253
253
|
when 'b', 'c', 'd', 'p', 'q', 't'
|
254
|
-
# these are appended to the last component if possible (i.e., when joined, should have no delimiter)
|
255
|
-
term_info[:
|
254
|
+
# these are appended to the last component (part) if possible (i.e., when joined, should have no delimiter)
|
255
|
+
term_info[:parts].last << ", #{subfield.value.strip}"
|
256
256
|
term_info[:count] += 1
|
257
257
|
else
|
258
258
|
# the usual case; add a new component to `parts`
|
@@ -588,6 +588,10 @@ finecore:
|
|
588
588
|
specific_location: Fisher Fine Arts Library - Core Reading Collection
|
589
589
|
library: Fisher Fine Arts Library
|
590
590
|
display: Fine Arts Library - Core Reading Collection
|
591
|
+
fineexhib:
|
592
|
+
specific_location: Fisher Fine Arts Library - Exhibitions Corridor
|
593
|
+
library: Fisher Fine Arts Library
|
594
|
+
display: Fine Arts Library - Exhibitions Corridor
|
591
595
|
finelock:
|
592
596
|
specific_location: Fisher Fine Arts Library - Locked Case
|
593
597
|
library:
|
data/lib/pennmarc/util.rb
CHANGED
@@ -14,7 +14,7 @@ module PennMARC
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# Join subfields from a field selected based on a provided proc
|
17
|
-
# @param [MARC::DataField] field
|
17
|
+
# @param [MARC::DataField, nil] field
|
18
18
|
# @param [Proc] selector
|
19
19
|
# @return [String]
|
20
20
|
def join_subfields(field, &selector)
|
@@ -125,6 +125,21 @@ module PennMARC
|
|
125
125
|
string.sub map[trailer.to_sym], ''
|
126
126
|
end
|
127
127
|
|
128
|
+
# Intelligently append given punctuation to the end of a string
|
129
|
+
# @param [Symbol] trailer
|
130
|
+
# @param [String] string
|
131
|
+
# @return [String]
|
132
|
+
def append_trailing(trailer, string)
|
133
|
+
return string if string.end_with?('.', '-')
|
134
|
+
|
135
|
+
map = { semicolon: ';',
|
136
|
+
colon: ':',
|
137
|
+
slash: '/',
|
138
|
+
comma: ',',
|
139
|
+
period: '.' }
|
140
|
+
string + map[trailer.to_sym]
|
141
|
+
end
|
142
|
+
|
128
143
|
# MARC 880 field "Alternate Graphic Representation" contains text "linked" to another
|
129
144
|
# field (e.g., 254 [Title]) used as an alternate representation. Often used to hold
|
130
145
|
# translations of title values. A common need is to extract subfields as selected by
|
data/lib/pennmarc/version.rb
CHANGED
@@ -10,7 +10,7 @@ describe 'PennMARC::Access' do
|
|
10
10
|
let(:record) { marc_record fields: [marc_field(tag: tag)] }
|
11
11
|
|
12
12
|
context 'with enrichment via the Alma publishing process' do
|
13
|
-
let(:tag) { PennMARC::
|
13
|
+
let(:tag) { PennMARC::Enriched::Pub::ELEC_INVENTORY_TAG }
|
14
14
|
|
15
15
|
it 'returns expected access value' do
|
16
16
|
expect(helper.facet(record)).to contain_exactly(PennMARC::Access::ONLINE)
|
@@ -18,7 +18,7 @@ describe 'PennMARC::Access' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'with enrichment with availability info via the Alma API' do
|
21
|
-
let(:tag) { PennMARC::
|
21
|
+
let(:tag) { PennMARC::Enriched::Api::ELEC_INVENTORY_TAG }
|
22
22
|
|
23
23
|
it 'returns expected access value' do
|
24
24
|
expect(helper.facet(record)).to contain_exactly(PennMARC::Access::ONLINE)
|
@@ -30,7 +30,7 @@ describe 'PennMARC::Access' do
|
|
30
30
|
let(:record) { marc_record fields: [marc_field(tag: tag)] }
|
31
31
|
|
32
32
|
context 'with enrichment via the Alma publishing process' do
|
33
|
-
let(:tag) { PennMARC::
|
33
|
+
let(:tag) { PennMARC::Enriched::Pub::PHYS_INVENTORY_TAG }
|
34
34
|
|
35
35
|
it 'returns expected access value' do
|
36
36
|
expect(helper.facet(record)).to contain_exactly(PennMARC::Access::AT_THE_LIBRARY)
|
@@ -38,7 +38,7 @@ describe 'PennMARC::Access' do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
context 'with enrichment with availability info via the Alma API' do
|
41
|
-
let(:tag) { PennMARC::
|
41
|
+
let(:tag) { PennMARC::Enriched::Api::PHYS_INVENTORY_TAG }
|
42
42
|
|
43
43
|
it 'returns expected access value' do
|
44
44
|
expect(helper.facet(record)).to contain_exactly(PennMARC::Access::AT_THE_LIBRARY)
|
@@ -48,7 +48,7 @@ describe 'PennMARC::Access' do
|
|
48
48
|
|
49
49
|
context 'with a record containing a link to a finding aid (as a handle link)' do
|
50
50
|
let(:record) do
|
51
|
-
marc_record fields: [marc_field(tag: PennMARC::
|
51
|
+
marc_record fields: [marc_field(tag: PennMARC::Enriched::Pub::PHYS_INVENTORY_TAG),
|
52
52
|
marc_field(tag: '856', subfields: location_and_access_subfields, **indicators)]
|
53
53
|
end
|
54
54
|
|
@@ -17,9 +17,9 @@ describe 'PennMARC::Classification' do
|
|
17
17
|
|
18
18
|
describe '.facet' do
|
19
19
|
context 'with enrichment via the Alma publishing process' do
|
20
|
-
let(:tag) { PennMARC::
|
21
|
-
let(:call_number_type_sf) { PennMARC::
|
22
|
-
let(:call_number_sf) { PennMARC::
|
20
|
+
let(:tag) { PennMARC::Enriched::Pub::ITEM_TAG }
|
21
|
+
let(:call_number_type_sf) { PennMARC::Enriched::Pub::ITEM_CALL_NUMBER_TYPE }
|
22
|
+
let(:call_number_sf) { PennMARC::Enriched::Pub::ITEM_CALL_NUMBER }
|
23
23
|
|
24
24
|
it 'returns expected values' do
|
25
25
|
expect(helper.facet(record)).to contain_exactly('T - Technology', '600 - Technology',
|
@@ -28,9 +28,9 @@ describe 'PennMARC::Classification' do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'with enrichment with availability info via Alma Api' do
|
31
|
-
let(:tag) { PennMARC::
|
32
|
-
let(:call_number_type_sf) { PennMARC::
|
33
|
-
let(:call_number_sf) { PennMARC::
|
31
|
+
let(:tag) { PennMARC::Enriched::Api::PHYS_INVENTORY_TAG }
|
32
|
+
let(:call_number_type_sf) { PennMARC::Enriched::Api::PHYS_CALL_NUMBER_TYPE }
|
33
|
+
let(:call_number_sf) { PennMARC::Enriched::Api::PHYS_CALL_NUMBER }
|
34
34
|
|
35
35
|
it 'returns expected values' do
|
36
36
|
expect(helper.facet(record)).to contain_exactly('T - Technology', '600 - Technology',
|
@@ -17,11 +17,11 @@ describe 'PennMARC::Creator' do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'contains the expected search field values for a single author work' do
|
20
|
-
expect(helper.search(record, relator_map: mapping)).to
|
20
|
+
expect(helper.search(record, relator_map: mapping)).to contain_exactly(
|
21
21
|
'Name Surname http://cool.uri/12345 author 1900-2000.',
|
22
22
|
'Surname, Name http://cool.uri/12345 author 1900-2000.',
|
23
23
|
'Alternative Surname'
|
24
|
-
|
24
|
+
)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -32,8 +32,33 @@ describe 'PennMARC::Creator' do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'contains the expected search field values for a corporate author work' do
|
35
|
-
expect(helper.search(record, relator_map: mapping)).to
|
36
|
-
|
35
|
+
expect(helper.search(record, relator_map: mapping)).to contain_exactly(
|
36
|
+
'Group of People Annual Meeting, Author.',
|
37
|
+
'Alt. Group Name Alt. Annual Meeting'
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '.search_aux' do
|
44
|
+
let(:record) { marc_record fields: fields }
|
45
|
+
|
46
|
+
context 'with a record that has an added name in the 7xx field' do
|
47
|
+
let(:fields) do
|
48
|
+
[marc_field(tag: '100', subfields: { a: 'Author', c: 'Fancy', d: 'active 24th century AD', '4': 'aut' }),
|
49
|
+
marc_field(tag: '700', subfields: { a: 'Author, Added' }),
|
50
|
+
marc_field(tag: '880', subfields: { '6': '100', a: 'Alt Author', c: 'Alt Fanciness' }),
|
51
|
+
marc_field(tag: '880', subfields: { '6': '700', a: 'Alt Added Author' })]
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'contains the expected search_aux field values for a single author work' do
|
55
|
+
expect(helper.search_aux(record, relator_map: mapping)).to contain_exactly(
|
56
|
+
'Author Fancy active 24th century AD, Author.',
|
57
|
+
'Author, Added.',
|
58
|
+
'Added Author.',
|
59
|
+
'Alt Author Alt Fanciness',
|
60
|
+
'Alt Added Author'
|
61
|
+
)
|
37
62
|
end
|
38
63
|
end
|
39
64
|
end
|
@@ -187,6 +212,18 @@ describe 'PennMARC::Creator' do
|
|
187
212
|
end
|
188
213
|
end
|
189
214
|
|
215
|
+
describe '.conference_search' do
|
216
|
+
let(:record) do
|
217
|
+
marc_record fields: [
|
218
|
+
marc_field(tag: '111', subfields: { a: 'MARC History Symposium', c: 'Moscow', '4': 'aut' })
|
219
|
+
]
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'returns conference name information for searching without relator value' do
|
223
|
+
expect(helper.conference_search(record)).to eq ['MARC History Symposium Moscow']
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
190
227
|
describe '.contributor_show' do
|
191
228
|
let(:record) do
|
192
229
|
marc_record fields: [
|
@@ -217,7 +254,4 @@ describe 'PennMARC::Creator' do
|
|
217
254
|
)
|
218
255
|
end
|
219
256
|
end
|
220
|
-
|
221
|
-
# describe '.conference_search'
|
222
|
-
# describe '.search_aux'
|
223
257
|
end
|
@@ -68,9 +68,9 @@ describe 'PennMARC::Format' do
|
|
68
68
|
context 'with API enriched fields' do
|
69
69
|
let(:record) do
|
70
70
|
marc_record fields: [
|
71
|
-
marc_field(tag: PennMARC::
|
71
|
+
marc_field(tag: PennMARC::Enriched::Api::PHYS_INVENTORY_TAG, subfields: {
|
72
72
|
:h => 'AB123',
|
73
|
-
PennMARC::
|
73
|
+
PennMARC::Enriched::Api::PHYS_CALL_NUMBER_TYPE => '.456 Microfilm'
|
74
74
|
})
|
75
75
|
]
|
76
76
|
end
|
@@ -83,9 +83,9 @@ describe 'PennMARC::Format' do
|
|
83
83
|
context 'with publishing enriched fields' do
|
84
84
|
let(:record) do
|
85
85
|
marc_record fields: [
|
86
|
-
marc_field(tag: PennMARC::
|
86
|
+
marc_field(tag: PennMARC::Enriched::Pub::PHYS_INVENTORY_TAG,
|
87
87
|
subfields: { :h => 'AB123',
|
88
|
-
PennMARC::
|
88
|
+
PennMARC::Enriched::Pub::ITEM_CALL_NUMBER_TYPE => '.456 Microfilm' })
|
89
89
|
]
|
90
90
|
end
|
91
91
|
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'PennMARC::Inventory' do
|
4
|
+
include MarcSpecHelpers
|
5
|
+
|
6
|
+
let(:helper) { PennMARC::Inventory }
|
7
|
+
let(:record) do
|
8
|
+
marc_record fields: fields
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'physical' do
|
12
|
+
let(:fields) do
|
13
|
+
[marc_field(tag: mapper::PHYS_INVENTORY_TAG,
|
14
|
+
subfields: subfields)]
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with API enrichment fields' do
|
18
|
+
let(:mapper) { PennMARC::Enriched::Api }
|
19
|
+
let(:subfields) do
|
20
|
+
{ mapper::PHYS_CALL_NUMBER => 'AB123.4',
|
21
|
+
mapper::PHYS_HOLDING_ID => '123456789',
|
22
|
+
mapper::PHYS_LOCATION_CODE => 'vanpelt',
|
23
|
+
mapper::PHYS_LOCATION_NAME => 'Van Pelt Library',
|
24
|
+
mapper::PHYS_PRIORITY => '1' }
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns expected array of hash values' do
|
28
|
+
expect(helper.physical(record)).to contain_exactly(
|
29
|
+
{ call_num: 'AB123.4', holding_id: '123456789', location_code: 'vanpelt',
|
30
|
+
location_name: 'Van Pelt Library', priority: '1' }
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with Pub enrichment fields' do
|
36
|
+
let(:mapper) { PennMARC::Enriched::Pub }
|
37
|
+
let(:subfields) do
|
38
|
+
{ mapper::HOLDING_CLASSIFICATION_PART => 'AB123',
|
39
|
+
mapper::HOLDING_ITEM_PART => '.4',
|
40
|
+
mapper::PHYS_HOLDING_ID => '123456789',
|
41
|
+
mapper::PHYS_LOCATION_CODE => 'vanpelt',
|
42
|
+
mapper::PHYS_LOCATION_NAME => 'Van Pelt Library' }
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'returns expected array of hash values' do
|
46
|
+
expect(helper.physical(record)).to contain_exactly(
|
47
|
+
{ call_num: 'AB123.4', holding_id: '123456789', location_code: 'vanpelt',
|
48
|
+
location_name: 'Van Pelt Library', priority: nil }
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'electronic' do
|
55
|
+
let(:fields) do
|
56
|
+
[marc_field(tag: mapper::ELEC_INVENTORY_TAG,
|
57
|
+
subfields: subfields)]
|
58
|
+
end
|
59
|
+
let(:subfields) do
|
60
|
+
{ mapper::ELEC_PORTFOLIO_ID => '234567890',
|
61
|
+
mapper::ELEC_SERVICE_URL => 'https://www.iwish.com',
|
62
|
+
mapper::ELEC_COLLECTION_NAME => 'All Articles Repo',
|
63
|
+
mapper::ELEC_COVERAGE_STMT => 'All time',
|
64
|
+
mapper::ELEC_PUBLIC_NOTE => 'Portfolio public note' }
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'with API enrichment fields' do
|
68
|
+
let(:mapper) { PennMARC::Enriched::Api }
|
69
|
+
|
70
|
+
it 'returns expected array of hash values' do
|
71
|
+
expect(helper.electronic(record)).to contain_exactly(
|
72
|
+
{ portfolio_id: '234567890', url: 'https://www.iwish.com', collection_name: 'All Articles Repo',
|
73
|
+
coverage: 'All time', note: 'Portfolio public note' }
|
74
|
+
)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'with Pub enrichment fields' do
|
79
|
+
let(:mapper) { PennMARC::Enriched::Pub }
|
80
|
+
|
81
|
+
it 'returns expected array of hash values' do
|
82
|
+
expect(helper.electronic(record)).to contain_exactly(
|
83
|
+
{ portfolio_id: '234567890', url: 'https://www.iwish.com', collection_name: 'All Articles Repo',
|
84
|
+
coverage: 'All time', note: 'Portfolio public note' }
|
85
|
+
)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe 'electronic_portfolio_count' do
|
91
|
+
let(:fields) { [marc_field(tag: inventory_tag), marc_field(tag: inventory_tag)] }
|
92
|
+
|
93
|
+
context 'with API enrichment fields' do
|
94
|
+
let(:inventory_tag) { PennMARC::Enriched::Api::ELEC_INVENTORY_TAG }
|
95
|
+
|
96
|
+
it 'returns the correct count' do
|
97
|
+
expect(helper.electronic_portfolio_count(record)).to eq 2
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'with Pub enrichment fields' do
|
102
|
+
let(:inventory_tag) { PennMARC::Enriched::Pub::ELEC_INVENTORY_TAG }
|
103
|
+
|
104
|
+
it 'returns the correct count' do
|
105
|
+
expect(helper.electronic_portfolio_count(record)).to eq 2
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe 'physical_holding_count' do
|
111
|
+
let(:fields) { [marc_field(tag: inventory_tag), marc_field(tag: inventory_tag)] }
|
112
|
+
|
113
|
+
context 'with API enrichment fields' do
|
114
|
+
let(:inventory_tag) { PennMARC::Enriched::Api::PHYS_INVENTORY_TAG }
|
115
|
+
|
116
|
+
it 'returns the correct count' do
|
117
|
+
expect(helper.physical_holding_count(record)).to eq 2
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'with Pub enrichment fields' do
|
122
|
+
let(:inventory_tag) { PennMARC::Enriched::Pub::PHYS_INVENTORY_TAG }
|
123
|
+
|
124
|
+
it 'returns the correct count' do
|
125
|
+
expect(helper.physical_holding_count(record)).to eq 2
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -4,11 +4,15 @@ describe 'PennMARC::Location' do
|
|
4
4
|
include MarcSpecHelpers
|
5
5
|
|
6
6
|
let(:helper) { PennMARC::Location }
|
7
|
+
let(:enriched_marc) { PennMARC::Enriched }
|
7
8
|
let(:mapping) { location_map }
|
8
9
|
|
9
10
|
describe 'location' do
|
10
11
|
context "with only 'itm' field present" do
|
11
|
-
let(:record)
|
12
|
+
let(:record) do
|
13
|
+
marc_record(fields: [marc_field(tag: enriched_marc::Pub::ITEM_TAG,
|
14
|
+
subfields: { enriched_marc::Pub::ITEM_CURRENT_LOCATION => 'stor' })])
|
15
|
+
end
|
12
16
|
|
13
17
|
it 'returns expected value' do
|
14
18
|
expect(helper.location(record: record, location_map: mapping,
|
@@ -19,7 +23,10 @@ describe 'PennMARC::Location' do
|
|
19
23
|
end
|
20
24
|
|
21
25
|
context "with only 'hld' field present" do
|
22
|
-
let(:record)
|
26
|
+
let(:record) do
|
27
|
+
marc_record(fields: [marc_field(tag: enriched_marc::Pub::PHYS_INVENTORY_TAG,
|
28
|
+
subfields: { enriched_marc::Pub::PHYS_LOCATION_CODE => 'stor' })])
|
29
|
+
end
|
23
30
|
|
24
31
|
it 'returns expected value' do
|
25
32
|
expect(helper.location(record: record, location_map: mapping,
|
@@ -29,10 +36,12 @@ describe 'PennMARC::Location' do
|
|
29
36
|
end
|
30
37
|
end
|
31
38
|
|
32
|
-
context
|
39
|
+
context 'with both holding and item tag fields present=' do
|
33
40
|
let(:record) do
|
34
|
-
marc_record(fields: [marc_field(tag:
|
35
|
-
|
41
|
+
marc_record(fields: [marc_field(tag: enriched_marc::Pub::ITEM_TAG,
|
42
|
+
subfields: { enriched_marc::Pub::ITEM_CURRENT_LOCATION => 'stor' }),
|
43
|
+
marc_field(tag: enriched_marc::Pub::PHYS_INVENTORY_TAG,
|
44
|
+
subfields: { enriched_marc::Pub::PHYS_LOCATION_CODE => 'dent' })])
|
36
45
|
end
|
37
46
|
|
38
47
|
it 'returns item location' do
|
@@ -42,7 +51,7 @@ describe 'PennMARC::Location' do
|
|
42
51
|
end
|
43
52
|
|
44
53
|
context 'with multiple library locations' do
|
45
|
-
let(:record) { marc_record(fields: [marc_field(tag:
|
54
|
+
let(:record) { marc_record(fields: [marc_field(tag: enriched_marc::Pub::ITEM_TAG, subfields: { g: %w[dent] })]) }
|
46
55
|
|
47
56
|
it 'returns expected value' do
|
48
57
|
expect(helper.location(record: record, location_map: mapping,
|
@@ -60,17 +69,26 @@ describe 'PennMARC::Location' do
|
|
60
69
|
end
|
61
70
|
|
62
71
|
context 'with electronic inventory tag' do
|
63
|
-
let(:record)
|
72
|
+
let(:record) do
|
73
|
+
marc_record(fields: [marc_field(tag: enriched_marc::Pub::ITEM_TAG,
|
74
|
+
subfields: { enriched_marc::Pub::ITEM_CURRENT_LOCATION => 'stor' }),
|
75
|
+
marc_field(tag: enriched_marc::Pub::ELEC_INVENTORY_TAG)])
|
76
|
+
end
|
64
77
|
|
65
78
|
it 'returns expected value' do
|
66
79
|
expect(helper.location(record: record, location_map: mapping,
|
67
|
-
display_value: :library)).to contain_exactly('LIBRA',
|
80
|
+
display_value: :library)).to contain_exactly('LIBRA', helper::ONLINE_LIBRARY)
|
68
81
|
end
|
69
82
|
end
|
70
83
|
|
71
84
|
context 'with AVA fields' do
|
72
85
|
let(:record) do
|
73
|
-
marc_record(fields: [marc_field(tag:
|
86
|
+
marc_record(fields: [marc_field(tag: enriched_marc::Api::PHYS_INVENTORY_TAG,
|
87
|
+
subfields: {
|
88
|
+
enriched_marc::Api::PHYS_LIBRARY_CODE => 'Libra',
|
89
|
+
enriched_marc::Api::PHYS_LOCATION_NAME => 'LIBRA',
|
90
|
+
enriched_marc::Api::PHYS_LOCATION_CODE => 'stor'
|
91
|
+
})])
|
74
92
|
end
|
75
93
|
|
76
94
|
it 'returns expected values' do
|
@@ -79,5 +97,18 @@ describe 'PennMARC::Location' do
|
|
79
97
|
)
|
80
98
|
end
|
81
99
|
end
|
100
|
+
|
101
|
+
context 'with AVE fields' do
|
102
|
+
let(:record) do
|
103
|
+
marc_record(fields: [marc_field(tag: enriched_marc::Api::ELEC_INVENTORY_TAG,
|
104
|
+
subfields: { enriched_marc::Api::ELEC_COLLECTION_NAME => 'Nature' })])
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'returns expected values' do
|
108
|
+
expect(helper.location(record: record, location_map: mapping, display_value: :library)).to(
|
109
|
+
contain_exactly(helper::ONLINE_LIBRARY)
|
110
|
+
)
|
111
|
+
end
|
112
|
+
end
|
82
113
|
end
|
83
114
|
end
|