pennmarc 0.0.1
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 +7 -0
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +119 -0
- data/README.md +82 -0
- data/legacy/indexer.rb +568 -0
- data/legacy/marc.rb +2964 -0
- data/legacy/test_file_output.json +49 -0
- data/lib/pennmarc/encoding_level.rb +43 -0
- data/lib/pennmarc/enriched_marc.rb +36 -0
- data/lib/pennmarc/heading_control.rb +11 -0
- data/lib/pennmarc/helpers/citation.rb +31 -0
- data/lib/pennmarc/helpers/creator.rb +237 -0
- data/lib/pennmarc/helpers/database.rb +89 -0
- data/lib/pennmarc/helpers/date.rb +85 -0
- data/lib/pennmarc/helpers/edition.rb +90 -0
- data/lib/pennmarc/helpers/format.rb +312 -0
- data/lib/pennmarc/helpers/genre.rb +71 -0
- data/lib/pennmarc/helpers/helper.rb +11 -0
- data/lib/pennmarc/helpers/identifier.rb +134 -0
- data/lib/pennmarc/helpers/language.rb +37 -0
- data/lib/pennmarc/helpers/link.rb +12 -0
- data/lib/pennmarc/helpers/location.rb +97 -0
- data/lib/pennmarc/helpers/note.rb +132 -0
- data/lib/pennmarc/helpers/production.rb +131 -0
- data/lib/pennmarc/helpers/relation.rb +135 -0
- data/lib/pennmarc/helpers/series.rb +118 -0
- data/lib/pennmarc/helpers/subject.rb +304 -0
- data/lib/pennmarc/helpers/title.rb +197 -0
- data/lib/pennmarc/mappings/language.yml +516 -0
- data/lib/pennmarc/mappings/locations.yml +1801 -0
- data/lib/pennmarc/mappings/relator.yml +263 -0
- data/lib/pennmarc/parser.rb +177 -0
- data/lib/pennmarc/util.rb +240 -0
- data/lib/pennmarc.rb +6 -0
- data/pennmarc.gemspec +22 -0
- data/spec/fixtures/marcxml/test.xml +167 -0
- data/spec/lib/pennmarc/helpers/citation_spec.rb +27 -0
- data/spec/lib/pennmarc/helpers/creator_spec.rb +183 -0
- data/spec/lib/pennmarc/helpers/database_spec.rb +60 -0
- data/spec/lib/pennmarc/helpers/date_spec.rb +105 -0
- data/spec/lib/pennmarc/helpers/edition_spec.rb +38 -0
- data/spec/lib/pennmarc/helpers/format_spec.rb +200 -0
- data/spec/lib/pennmarc/helpers/genre_spec.rb +89 -0
- data/spec/lib/pennmarc/helpers/identifer_spec.rb +105 -0
- data/spec/lib/pennmarc/helpers/language_spec.rb +30 -0
- data/spec/lib/pennmarc/helpers/location_spec.rb +70 -0
- data/spec/lib/pennmarc/helpers/note_spec.rb +233 -0
- data/spec/lib/pennmarc/helpers/production_spec.rb +193 -0
- data/spec/lib/pennmarc/helpers/relation_spec.rb +120 -0
- data/spec/lib/pennmarc/helpers/subject_spec.rb +262 -0
- data/spec/lib/pennmarc/helpers/title_spec.rb +169 -0
- data/spec/lib/pennmarc/marc_util_spec.rb +206 -0
- data/spec/lib/pennmarc/parser_spec.rb +13 -0
- data/spec/spec_helper.rb +104 -0
- data/spec/support/marc_spec_helpers.rb +84 -0
- metadata +171 -0
@@ -0,0 +1,200 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'PennMARC::Format' do
|
4
|
+
include MarcSpecHelpers
|
5
|
+
|
6
|
+
let(:helper) { PennMARC::Format }
|
7
|
+
|
8
|
+
describe '.facet' do
|
9
|
+
let(:map) { location_map }
|
10
|
+
let(:formats) { helper.facet(record, map) }
|
11
|
+
|
12
|
+
context 'for an "Archive"' do
|
13
|
+
let(:map) do
|
14
|
+
{ musearch: { specific_location: 'Penn Museum Archives',
|
15
|
+
library: 'Penn Museum Archives',
|
16
|
+
display: 'Penn Museum Archives, 215-898-8304' },
|
17
|
+
nursarch: { specific_location: 'Nursing Archives',
|
18
|
+
library: 'Nursing Archives',
|
19
|
+
display: 'Barbara Bates Center for History of Nursing - Fagin Hall 2U' } }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'for a record in "Penn Museum Archives (musearch)"' do
|
23
|
+
let(:record) { marc_record fields: [marc_field(tag: 'hld', subfields: { c: 'musearch' })] }
|
24
|
+
|
25
|
+
it 'returns format values of "Archive" for a record with holdings located in "musearch"' do
|
26
|
+
expect(formats).to include 'Archive'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'for a record in "Nursing Archives (nursarch)"' do
|
31
|
+
let(:record) { marc_record fields: [marc_field(tag: 'hld', subfields: { c: 'nursarch' })] }
|
32
|
+
|
33
|
+
it 'returns format values of without "Archive" for a record with a holding in "nursarch"' do
|
34
|
+
expect(formats).not_to include 'Archive'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'for a "Newspaper"' do
|
40
|
+
let(:record) do
|
41
|
+
marc_record leader: ' as',
|
42
|
+
fields: [marc_control_field(tag: '008', value: ' n')]
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'returns a facet value including "Newspaper" and "Journal/Periodical"' do
|
46
|
+
expect(formats).to eq %w[Newspaper Journal/Periodical]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# TODO: confirm this as desired functionality
|
51
|
+
# Inspired by https://franklin.library.upenn.edu/catalog/FRANKLIN_999444703503681
|
52
|
+
# which appears to be a thesis on microfilm, but only has microfilm as a format.
|
53
|
+
context 'for a "Thesis" on "Microfilm"' do
|
54
|
+
let(:record) do
|
55
|
+
marc_record leader: ' tm',
|
56
|
+
fields: [
|
57
|
+
marc_field(tag: '245', subfields: { h: '[microfilm]' }),
|
58
|
+
marc_field(tag: '502', subfields: { a: 'Ed.D. Thesis' })
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'returns a facet value of only "Microformat"' do
|
63
|
+
# expect(formats).to eq %w[Microformat Thesis/Dissertation]
|
64
|
+
expect(formats).to eq %w[Microformat]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'for Microformats as determined by the holding call numbers' do
|
69
|
+
let(:record) do
|
70
|
+
marc_record fields: [marc_field(tag: 'hld', subfields: { h: 'AB123', i: '.456 Microfilm' })]
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'returns a facet value of "Microformat"' do
|
74
|
+
expect(formats).to eq ['Microformat']
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'for a "Book"' do
|
79
|
+
let(:record) do
|
80
|
+
marc_record leader: ' aa',
|
81
|
+
fields: [marc_field(tag: '245', subfields: { k: 'blah' })]
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'returns a facet value including only "Book"' do
|
85
|
+
expect(formats).to eq ['Book']
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'for a "Projected Graphic"' do
|
90
|
+
let(:record) do
|
91
|
+
marc_record leader: ' gm',
|
92
|
+
fields: [marc_control_field(tag: '007', value: 'go hkaaa ')]
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'returns a facet value including only "Projected graphic"' do
|
96
|
+
expect(formats).to eq ['Projected graphic']
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'with a "Curated Format" set' do
|
101
|
+
let(:record) do
|
102
|
+
marc_record fields: [marc_field(tag: '944', subfields: { a: subfield_a_value })]
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'with a format explicitly specified in 944 ǂa' do
|
106
|
+
let(:subfield_a_value) { 'Book' }
|
107
|
+
|
108
|
+
it 'returns a facet value including a curated format of "Book"' do
|
109
|
+
expect(formats).to eq %w[Other Book]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'with a number in 944 ǂa' do
|
114
|
+
let(:subfield_a_value) { '123' }
|
115
|
+
|
116
|
+
it 'returns no content from 944 ǂa' do
|
117
|
+
expect(formats).to eq ['Other']
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '.show' do
|
124
|
+
let(:record) { marc_record fields: fields }
|
125
|
+
|
126
|
+
context 'with entry in the 300 field' do
|
127
|
+
let(:fields) do
|
128
|
+
[marc_field(tag: '300', subfields: { a: '1 volume', b: 'illustration, maps', c: '12cm', '3': 'excluded' }),
|
129
|
+
marc_field(tag: '880', subfields: { '6': '300', a: 'Alt. Extent' })]
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'returns the expected format values' do
|
133
|
+
value = helper.show(record)
|
134
|
+
expect(value).to contain_exactly '1 volume illustration, maps 12cm', 'Alt. Extent'
|
135
|
+
expect(value.join(' ')).not_to include 'excluded'
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'with entry in the 255 field' do
|
140
|
+
let(:fields) do
|
141
|
+
[marc_field(tag: '255', subfields: { a: 'Scale 1:24,000', b: 'Mercator projection',
|
142
|
+
c: '(W 150°--W 30°/N 70°--N 40°)' }),
|
143
|
+
marc_field(tag: '880', subfields: { '6': '255', a: 'Alt. Scale', b: 'Alt. Projection' })]
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'returns the expected format values' do
|
147
|
+
expect(helper.show(record)).to contain_exactly 'Alt. Scale Alt. Projection',
|
148
|
+
'Scale 1:24,000 Mercator projection (W 150°--W 30°/N 70°--N 40°)'
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context 'with entries in the 340' do
|
153
|
+
let(:fields) do
|
154
|
+
[marc_field(tag: '340', subfields: { a: 'cassette tape', b: '90 min', '0': 'excluded' }),
|
155
|
+
marc_field(tag: '880', subfields: { '6': '340', a: 'alt. extent' })]
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'returns the expected format values' do
|
159
|
+
value = helper.show(record)
|
160
|
+
expect(value).to contain_exactly 'cassette tape 90 min', 'alt. extent'
|
161
|
+
expect(value.join(' ')).not_to include 'excluded'
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe '.other_show' do
|
167
|
+
let(:record) do
|
168
|
+
marc_record fields: [marc_field(tag: '776', subfields: {
|
169
|
+
i: 'Online edition', a: 'Author, Name', t: 'Title', b: 'First Edition',
|
170
|
+
d: 'Some Publisher', w: '(OCoLC)12345', s: 'Uniform Title', o: '12345'
|
171
|
+
}),
|
172
|
+
marc_field(tag: '880', subfields: {
|
173
|
+
'6': '776', i: 'Alt. Online Edition', t: 'Alt. Title'
|
174
|
+
})]
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'returns other format information for display, with data from only ǂi, ǂa, ǂs, ǂt and ǂo' do
|
178
|
+
expect(helper.other_show(record)).to contain_exactly 'Alt. Online Edition Alt. Title',
|
179
|
+
'Online edition Author, Name Title Uniform Title 12345'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe '.includes_manuscript?' do
|
184
|
+
context 'with a manuscript location incldued' do
|
185
|
+
let(:locations) { ['Van Pelt', 'Kislak Center for Special Collections - Manuscripts Storage'] }
|
186
|
+
|
187
|
+
it 'returns true' do
|
188
|
+
expect(helper.include_manuscripts?(locations)).to be true
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
context 'without a manuscript location included' do
|
193
|
+
let(:locations) { ['Van Pelt'] }
|
194
|
+
|
195
|
+
it 'returns false' do
|
196
|
+
expect(helper.include_manuscripts?(locations)).to be false
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'PennMARC::Genre' do
|
4
|
+
include MarcSpecHelpers
|
5
|
+
|
6
|
+
let(:helper) { PennMARC::Genre }
|
7
|
+
let(:record) { marc_record fields: fields }
|
8
|
+
|
9
|
+
describe '.search' do
|
10
|
+
let(:values) { helper.search(record) }
|
11
|
+
let(:fields) do
|
12
|
+
[marc_field(tag: '655', indicator2: '4', subfields: {
|
13
|
+
a: 'Fan magazines', z: 'United States', y: '20th century'
|
14
|
+
}),
|
15
|
+
marc_field(tag: '655', indicator2: '', subfields: { a: 'Zines' }),
|
16
|
+
marc_field(tag: '655', indicator2: '7', subfields: { a: 'Magazine', '2': 'aat' }),
|
17
|
+
marc_field(tag: '655', indicator2: '1', subfields: { a: "Children's Genre" })]
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'includes only appropriate values, excluding subfields 0, 2, 5 and c' do
|
21
|
+
expect(values).to contain_exactly "Children's Genre", 'Fan magazines United States 20th century',
|
22
|
+
'Magazine', 'Zines'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.show' do
|
27
|
+
let(:values) { helper.show(record) }
|
28
|
+
let(:fields) do
|
29
|
+
[marc_field(tag: '655', indicator2: '4', subfields: {
|
30
|
+
a: 'Magazines', b: 'Fan literature', z: 'United States', y: '20th century', '5': 'PU'
|
31
|
+
}),
|
32
|
+
marc_field(tag: '655', indicator2: '', subfields: { a: 'Zines' }),
|
33
|
+
marc_field(tag: '655', indicator2: '0', subfields: { a: 'Magazine' }),
|
34
|
+
marc_field(tag: '655', indicator2: '7', subfields: { a: 'Magazine', c: 'k', '0': '1234567', '2': 'aat' }),
|
35
|
+
marc_field(tag: '655', indicator2: '1', subfields: { a: "Children's Genre" }),
|
36
|
+
marc_field(tag: '880', indicator2: '4', subfields: { a: 'Alt. Magazine', '6': '655' })]
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'includes only appropriate values, without specified subfields, with proper formatting and without duplicates' do
|
40
|
+
expect(values).to contain_exactly 'Magazines Fan literature -- United States -- 20th century', 'Magazine',
|
41
|
+
'Alt. Magazine'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '.facet' do
|
46
|
+
let(:values) { helper.facet(record, location_map) }
|
47
|
+
let(:location_map) do
|
48
|
+
{ manu: { specific_location: 'Secure Manuscripts Storage' },
|
49
|
+
vanp: { specific_location: 'Van Pelt' } }
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'for a non-video, non-manuscript record' do
|
53
|
+
let(:fields) do
|
54
|
+
[marc_control_field(tag: '007', value: 'x'),
|
55
|
+
marc_field(tag: 'hld', subfields: { c: 'vanp' }),
|
56
|
+
marc_field(tag: '655', indicator2: '7', subfields: { a: 'Genre.' })]
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns no genre values for faceting' do
|
60
|
+
expect(values).to be_empty
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'for a video record' do
|
65
|
+
let(:fields) do
|
66
|
+
[marc_control_field(tag: '007', value: 'v'),
|
67
|
+
marc_field(tag: 'hld', subfields: { c: 'vanp' }),
|
68
|
+
marc_field(tag: '655', indicator2: '7', subfields: { a: 'Documentary films' }),
|
69
|
+
marc_field(tag: '655', indicator2: '7', subfields: { a: 'Sports' })]
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'contains the expected genre facet values' do
|
73
|
+
expect(values).to contain_exactly 'Documentary films', 'Sports'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'for a manuscript-located record' do
|
78
|
+
let(:fields) do
|
79
|
+
[marc_control_field(tag: '007', value: 'x'),
|
80
|
+
marc_field(tag: 'hld', subfields: { c: 'manu' }),
|
81
|
+
marc_field(tag: '655', indicator2: '7', subfields: { a: 'Astronomy', '2': 'zzzz' })]
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'returns the expected genre values' do
|
85
|
+
expect(values).to contain_exactly 'Astronomy'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'PennMARC::Identifier' do
|
4
|
+
include MarcSpecHelpers
|
5
|
+
|
6
|
+
let(:helper) { PennMARC::Identifier }
|
7
|
+
|
8
|
+
describe '.mmsid' do
|
9
|
+
let(:record) { marc_record fields: [marc_control_field(tag: '001', value: '9977233551603681')] }
|
10
|
+
|
11
|
+
it 'returns expected value' do
|
12
|
+
expect(helper.mmsid(record)).to eq('9977233551603681')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.isxn_search' do
|
17
|
+
let(:record) do
|
18
|
+
marc_record fields: [
|
19
|
+
marc_field(tag: '020', subfields: { a: '9781594205071', z: '1594205078' }),
|
20
|
+
marc_field(tag: '022', subfields: { a: '0008-6533', l: '0300-7162', z: '0008-6533' })
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns expected search values' do
|
25
|
+
expect(helper.isxn_search(record)).to contain_exactly('9781594205071', '1594205078', '0300-7162', '0008-6533')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'converts ISBN10 values to ISBN13' do
|
29
|
+
record = marc_record fields: [marc_field(tag: '020', subfields: { a: '0805073698' })]
|
30
|
+
expect(helper.isxn_search(record)).to contain_exactly('9780805073690', '0805073698')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.isbn_show' do
|
35
|
+
let(:record) do
|
36
|
+
marc_record fields: [
|
37
|
+
marc_field(tag: '020', subfields: { a: '9781594205071', z: '1594205078' }),
|
38
|
+
marc_field(tag: '020', subfields: { a: '0805073698', z: '9780735222786' }),
|
39
|
+
marc_field(tag: '880', subfields: { a: '0735222789', z: '9780805073690', '6': '020' })
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns expected show values' do
|
44
|
+
expect(helper.isbn_show(record)).to contain_exactly('9781594205071 1594205078', '0805073698 9780735222786',
|
45
|
+
'0735222789 9780805073690')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '.issn_show' do
|
50
|
+
let(:record) do
|
51
|
+
marc_record fields: [
|
52
|
+
marc_field(tag: '022', subfields: { a: '0008-6533', z: '0008-6533' }),
|
53
|
+
marc_field(tag: '022', subfields: { a: '2470-6302', z: '1534-6714' }),
|
54
|
+
marc_field(tag: '880', subfields: { a: '1080-6512', z: '2213-4360', '6': '022' })
|
55
|
+
]
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'returns expected show values' do
|
59
|
+
expect(helper.issn_show(record)).to contain_exactly('0008-6533 0008-6533', '2470-6302 1534-6714',
|
60
|
+
'1080-6512 2213-4360')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '.oclc_id' do
|
65
|
+
let(:record) do
|
66
|
+
marc_record fields: [
|
67
|
+
marc_field(tag: '035', subfields: { a: '(PU)4422776-penndb-Voyager' }),
|
68
|
+
marc_field(tag: '035', subfields: { a: '(OCoLC)ocn610094484' }),
|
69
|
+
marc_field(tag: '035', subfields: { a: '(OCoLC)1483169584' })
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'returns expected show values' do
|
74
|
+
expect(helper.oclc_id(record)).to contain_exactly('610094484')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '.publisher_number_show' do
|
79
|
+
let(:record) do
|
80
|
+
marc_record fields: [
|
81
|
+
marc_field(tag: '024', subfields: { a: '602537854325', '6': '880-01' }),
|
82
|
+
marc_field(tag: '028', subfields: { a: 'B002086600', b: 'Island Def Jam Music Group', '6': '880-01' }),
|
83
|
+
marc_field(tag: '880', subfields: { a: '523458735206', '6': '024' }),
|
84
|
+
marc_field(tag: '880', subfields: { a: '006680200B', b: 'Island', '6': '028' })
|
85
|
+
]
|
86
|
+
end
|
87
|
+
it 'returns expected show values' do
|
88
|
+
expect(helper.publisher_number_show(record)).to contain_exactly('602537854325',
|
89
|
+
'B002086600 Island Def Jam Music Group',
|
90
|
+
'523458735206', '006680200B Island')
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '.publisher_number_search' do
|
95
|
+
let(:record) do
|
96
|
+
marc_record fields: [
|
97
|
+
marc_field(tag: '024', subfields: { a: '602537854325' }),
|
98
|
+
marc_field(tag: '028', subfields: { a: 'B002086600', b: 'Island Def Jam Music Group' })
|
99
|
+
]
|
100
|
+
end
|
101
|
+
it 'returns expected search values' do
|
102
|
+
expect(helper.publisher_number_search(record)).to contain_exactly('602537854325', 'B002086600')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'PennMARC::Language' do
|
4
|
+
include MarcSpecHelpers
|
5
|
+
|
6
|
+
let(:helper) { PennMARC::Language }
|
7
|
+
let(:mapping) do
|
8
|
+
{ eng: 'English', und: 'Undetermined' }
|
9
|
+
end
|
10
|
+
let(:record) do
|
11
|
+
marc_record fields: [
|
12
|
+
marc_control_field(tag: '008', value: ' eng'),
|
13
|
+
marc_field(tag: '546', subfields: { a: 'Great', c: 'Content', '6': 'Not Included' }),
|
14
|
+
marc_field(tag: '546', subfields: { b: 'More!', '8': 'Not Included' }),
|
15
|
+
marc_field(tag: '880', subfields: { c: 'Mas!', '6': '546', '8': 'Not Included' })
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.search' do
|
20
|
+
it 'returns the expected display value' do
|
21
|
+
expect(helper.search(record, mapping)).to eq 'English'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.show' do
|
26
|
+
it 'returns the expected show values' do
|
27
|
+
expect(helper.show(record)).to contain_exactly 'Great Content', 'More!', 'Mas!'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'PennMARC::Location' do
|
4
|
+
include MarcSpecHelpers
|
5
|
+
|
6
|
+
let(:helper) { PennMARC::Location }
|
7
|
+
let(:mapping) { location_map }
|
8
|
+
|
9
|
+
describe 'location' do
|
10
|
+
context "with only 'itm' field present" do
|
11
|
+
let(:record) { marc_record(fields: [marc_field(tag: 'itm', subfields: { g: 'stor' })]) }
|
12
|
+
|
13
|
+
it 'returns expected value' do
|
14
|
+
expect(helper.location(record: record, location_map: mapping,
|
15
|
+
display_value: :library)).to contain_exactly('LIBRA')
|
16
|
+
expect(helper.location(record:, location_map: mapping,
|
17
|
+
display_value: 'specific_location')).to contain_exactly('LIBRA')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with only 'hld' field present" do
|
22
|
+
let(:record) { marc_record(fields: [marc_field(tag: 'hld', subfields: { c: 'stor' })]) }
|
23
|
+
|
24
|
+
it 'returns expected value' do
|
25
|
+
expect(helper.location(record: record, location_map: mapping,
|
26
|
+
display_value: :library)).to contain_exactly('LIBRA')
|
27
|
+
expect(helper.location(record: record, location_map: mapping,
|
28
|
+
display_value: 'specific_location')).to contain_exactly('LIBRA')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "with both 'hld' and 'itm' fields present" do
|
33
|
+
let(:record) do
|
34
|
+
marc_record(fields: [marc_field(tag: 'itm', subfields: { g: 'stor' }),
|
35
|
+
marc_field(tag: 'hld', subfields: { c: 'dent' })])
|
36
|
+
end
|
37
|
+
it 'returns item location' do
|
38
|
+
expect(helper.location(record: record, location_map: mapping,
|
39
|
+
display_value: :library)).to contain_exactly('LIBRA')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with multiple library locations' do
|
44
|
+
let(:record) { marc_record(fields: [marc_field(tag: 'itm', subfields: { g: %w[dent] })]) }
|
45
|
+
|
46
|
+
it 'returns expected value' do
|
47
|
+
expect(helper.location(record: record, location_map: mapping,
|
48
|
+
display_value: :library)).to contain_exactly('Health Sciences Libraries',
|
49
|
+
'Levy Dental Medicine Library')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'without enriched marc location tag' do
|
54
|
+
let(:record) { marc_record(fields: [marc_field(tag: '852', subfields: { g: 'stor' })]) }
|
55
|
+
|
56
|
+
it 'returns expected value' do
|
57
|
+
expect(helper.location(record: record, location_map: mapping, display_value: :library)).to be_empty
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'with electronic inventory tag' do
|
62
|
+
let(:record) { marc_record(fields: [marc_field(tag: 'itm', subfields: { g: 'stor' }), marc_field(tag: 'prt')]) }
|
63
|
+
|
64
|
+
it 'returns expected value' do
|
65
|
+
expect(helper.location(record: record, location_map: mapping,
|
66
|
+
display_value: :library)).to contain_exactly('LIBRA', 'Online library')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|