pennmarc 1.0.12 → 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/.rubocop_todo.yml +2 -2
- 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 +8 -3
- data/lib/pennmarc/enriched_marc.rb +0 -49
@@ -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
|
@@ -101,13 +101,14 @@ describe 'PennMARC::Subject' do
|
|
101
101
|
let(:fields) do
|
102
102
|
[marc_field(tag: '650', indicator2: '7',
|
103
103
|
subfields: {
|
104
|
-
a: 'Libraries',
|
104
|
+
a: 'Libraries', d: '22nd Century', x: 'History', e: 'relator',
|
105
105
|
'2': 'fast', '0': 'http://fast.org/libraries'
|
106
106
|
})]
|
107
107
|
end
|
108
108
|
|
109
109
|
it 'properly concatenates heading components' do
|
110
|
-
expect(values.first).to
|
110
|
+
expect(values.first).to start_with 'Libraries'
|
111
|
+
expect(values.first).to end_with '--History'
|
111
112
|
end
|
112
113
|
|
113
114
|
it 'excludes URI values from ǂ0 or ǂ1' do
|
@@ -123,14 +124,14 @@ describe 'PennMARC::Subject' do
|
|
123
124
|
end
|
124
125
|
|
125
126
|
it 'joins all values in the expected way' do
|
126
|
-
expect(values.first).to eq 'Libraries
|
127
|
+
expect(values.first).to eq 'Libraries, 22nd Century--History'
|
127
128
|
end
|
128
129
|
end
|
129
130
|
end
|
130
131
|
|
131
132
|
describe '.show' do
|
132
133
|
let(:record) { marc_record fields: fields }
|
133
|
-
let(:values) { helper.
|
134
|
+
let(:values) { helper.show(record) }
|
134
135
|
|
135
136
|
context 'with a variety of headings' do
|
136
137
|
let(:fields) do
|
@@ -162,8 +163,28 @@ describe 'PennMARC::Subject' do
|
|
162
163
|
end
|
163
164
|
|
164
165
|
it 'properly formats the heading parts' do
|
165
|
-
expect(values.first).to eq 'Subways--Pennsylvania--Philadelphia Metropolitan Area--Maps--1989'
|
166
|
-
|
166
|
+
expect(values.first).to eq 'Subways--Pennsylvania--Philadelphia Metropolitan Area--Maps--1989 relator'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context 'with the record including trailing punctuation in the parts' do
|
171
|
+
let(:fields) do
|
172
|
+
[marc_field(tag: '600', indicator2: '7', subfields: {
|
173
|
+
a: 'Franklin, Benjamin,',
|
174
|
+
d: '1706-1790',
|
175
|
+
'2': 'fast',
|
176
|
+
'0': 'http://id.worldcat.org/fast/34115'
|
177
|
+
}),
|
178
|
+
marc_field(tag: '600', indicator1: '1', indicator2: '0', subfields: {
|
179
|
+
a: 'Franklin, Benjamin,',
|
180
|
+
d: '1706-1790.',
|
181
|
+
x: 'As inventor.'
|
182
|
+
})]
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'returns what Franklin shows', pending: 'proper handling of punctuation in subject parts' do
|
186
|
+
expect(values).to contain_exactly 'Franklin, Benjamin, 1706-1790.',
|
187
|
+
'Franklin, Benjamin, 1706-1790--As inventor.'
|
167
188
|
end
|
168
189
|
end
|
169
190
|
|
@@ -187,14 +208,14 @@ describe 'PennMARC::Subject' do
|
|
187
208
|
let(:fields) do
|
188
209
|
[marc_field(tag: '611', indicator2: '0', subfields: {
|
189
210
|
a: 'Conference',
|
190
|
-
|
191
|
-
|
192
|
-
|
211
|
+
c: ['(Johannesburg, South Africa', 'Cape Town, South Africa'],
|
212
|
+
d: '2002)',
|
213
|
+
n: '2nd'
|
193
214
|
})]
|
194
215
|
end
|
195
216
|
|
196
217
|
it 'properly formats the heading parts' do
|
197
|
-
expect(values.first).to eq 'Conference
|
218
|
+
expect(values.first).to eq 'Conference, (Johannesburg, South Africa, Cape Town, South Africa, 2002)--2nd'
|
198
219
|
end
|
199
220
|
end
|
200
221
|
|
@@ -202,14 +223,17 @@ describe 'PennMARC::Subject' do
|
|
202
223
|
let(:fields) do
|
203
224
|
[marc_field(tag: '600', indicator2: '0', subfields: {
|
204
225
|
a: 'Person, Significant Author',
|
226
|
+
b: 'Numerator',
|
227
|
+
c: %w[Title Rank],
|
205
228
|
d: '1899-1971',
|
206
|
-
|
207
|
-
|
229
|
+
t: 'Collection',
|
230
|
+
v: 'Early works to 1950'
|
208
231
|
})]
|
209
232
|
end
|
210
233
|
|
211
234
|
it 'properly formats the heading parts' do
|
212
|
-
expect(values.first).to eq
|
235
|
+
expect(values.first).to eq('Person, Significant Author, Numerator, Title, Rank, 1899-1971, Collection--' \
|
236
|
+
'Early works to 1950')
|
213
237
|
end
|
214
238
|
end
|
215
239
|
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.14
|
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-01-
|
13
|
+
date: 2024-01-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -88,7 +88,7 @@ files:
|
|
88
88
|
- README.md
|
89
89
|
- lib/pennmarc.rb
|
90
90
|
- lib/pennmarc/encoding_level.rb
|
91
|
-
- lib/pennmarc/
|
91
|
+
- lib/pennmarc/enriched.rb
|
92
92
|
- lib/pennmarc/heading_control.rb
|
93
93
|
- lib/pennmarc/helpers/access.rb
|
94
94
|
- lib/pennmarc/helpers/citation.rb
|
@@ -101,6 +101,10 @@ files:
|
|
101
101
|
- lib/pennmarc/helpers/genre.rb
|
102
102
|
- lib/pennmarc/helpers/helper.rb
|
103
103
|
- lib/pennmarc/helpers/identifier.rb
|
104
|
+
- lib/pennmarc/helpers/inventory.rb
|
105
|
+
- lib/pennmarc/helpers/inventory_entry/base.rb
|
106
|
+
- lib/pennmarc/helpers/inventory_entry/electronic.rb
|
107
|
+
- lib/pennmarc/helpers/inventory_entry/physical.rb
|
104
108
|
- lib/pennmarc/helpers/language.rb
|
105
109
|
- lib/pennmarc/helpers/link.rb
|
106
110
|
- lib/pennmarc/helpers/location.rb
|
@@ -132,6 +136,7 @@ files:
|
|
132
136
|
- spec/lib/pennmarc/helpers/format_spec.rb
|
133
137
|
- spec/lib/pennmarc/helpers/genre_spec.rb
|
134
138
|
- spec/lib/pennmarc/helpers/identifer_spec.rb
|
139
|
+
- spec/lib/pennmarc/helpers/inventory_spec.rb
|
135
140
|
- spec/lib/pennmarc/helpers/language_spec.rb
|
136
141
|
- spec/lib/pennmarc/helpers/link_spec.rb
|
137
142
|
- spec/lib/pennmarc/helpers/location_spec.rb
|