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,233 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'PennMARC::Note' do
|
4
|
+
include MarcSpecHelpers
|
5
|
+
|
6
|
+
let(:helper) { PennMARC::Note }
|
7
|
+
|
8
|
+
describe '.notes_show' do
|
9
|
+
let(:record) { marc_record(fields: fields) }
|
10
|
+
let(:fields) do
|
11
|
+
[
|
12
|
+
marc_field(tag: '500',
|
13
|
+
subfields: { a: 'Gift of R. Winthrop, 1883', '3': 'Abstracts', '4': 'From Winthrop papers' }),
|
14
|
+
marc_field(tag: '502', subfields: { b: 'PhD', c: 'University of Pennsylvania', d: '2021' }),
|
15
|
+
marc_field(tag: '504', subfields: { a: 'Includes bibliographical references (pages 329-[342]) and index.' }),
|
16
|
+
marc_field(tag: '533',
|
17
|
+
subfields: { '3': 'Archives', '5': 'LoC', a: 'Microfilm',
|
18
|
+
b: 'UK', c: 'Historical Association',
|
19
|
+
d: '1917', e: '434 reels',
|
20
|
+
f: '(Seized records)' }),
|
21
|
+
marc_field(tag: '588', subfields: { a: 'Print version record', '5': 'LoC' }),
|
22
|
+
marc_field(tag: '880', subfields: { b: 'Alt PhD', c: 'Alt UPenn', d: 'Alt 2021', '6': '502' }),
|
23
|
+
marc_field(tag: '880', subfields: { b: 'Ignore Note', '6': '501' })
|
24
|
+
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:values) { helper.notes_show(record) }
|
29
|
+
|
30
|
+
it 'returns expected values' do
|
31
|
+
expect(values).to contain_exactly('Gift of R. Winthrop, 1883 Abstracts From Winthrop papers',
|
32
|
+
'PhD University of Pennsylvania 2021',
|
33
|
+
'Includes bibliographical references (pages 329-[342]) and index.',
|
34
|
+
'Archives Microfilm UK Historical Association 1917 434 reels (Seized records)',
|
35
|
+
'Print version record', 'Alt PhD Alt UPenn Alt 2021')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '.local_notes_show' do
|
40
|
+
let(:record) { marc_record(fields: fields) }
|
41
|
+
let(:fields) do
|
42
|
+
[
|
43
|
+
marc_field(tag: '561', subfields: { a: 'Athenaeum copy: ', u: 'No URI' }),
|
44
|
+
marc_field(tag: '561', subfields: { a: 'Ignored' }),
|
45
|
+
marc_field(tag: '562', subfields: { a: 'Torn cover', b: 'desk copy', c: '3rd edition',
|
46
|
+
d: 'intended for reading',
|
47
|
+
e: '2 copies',
|
48
|
+
'3': 'parchment',
|
49
|
+
'5': 'LoC' }),
|
50
|
+
marc_field(tag: '590', subfields: { a: 'local note', '3': 'local paper' }),
|
51
|
+
marc_field(tag: '880', subfields: { a: 'alt cover', b: 'alt copy', c: 'alt edition',
|
52
|
+
d: 'alt presentation', e: 'alt number of copies',
|
53
|
+
'3': 'alt materials',
|
54
|
+
'5': 'LoC', '6': '562' }),
|
55
|
+
marc_field(tag: '880', subfields: { a: 'alt note', '3': 'alt paper', '6': '590' })
|
56
|
+
]
|
57
|
+
end
|
58
|
+
|
59
|
+
let(:values) { helper.local_notes_show(record) }
|
60
|
+
|
61
|
+
it 'returns expected values' do
|
62
|
+
expect(values).to contain_exactly(
|
63
|
+
'Athenaeum copy:',
|
64
|
+
'Torn cover desk copy 3rd edition intended for reading 2 copies parchment',
|
65
|
+
'local note local paper',
|
66
|
+
'alt cover alt copy alt edition alt presentation alt number of copies alt materials',
|
67
|
+
'alt note alt paper'
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'ignores non Athenaeum copies' do
|
72
|
+
expect(values).not_to include('Ignored')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '.provenance_show' do
|
77
|
+
let(:record) { marc_record(fields: fields) }
|
78
|
+
let(:fields) do
|
79
|
+
[
|
80
|
+
marc_field(tag: '561', subfields: { a: 'Not Athenaeum copy: ', u: 'No URI' }, indicator1: '1', indicator2: ' '),
|
81
|
+
marc_field(tag: '561', subfields: { a: 'Ignore', u: 'No URI' }, indicator1: 'Wrong Indicator'),
|
82
|
+
marc_field(tag: '561', subfields: { a: 'Ignore', u: 'No URI' }, indicator2: 'Wrong Indicator'),
|
83
|
+
marc_field(tag: '561', subfields: { a: 'Athenaeum copy: ', u: 'No URI' }),
|
84
|
+
marc_field(tag: '650', indicator2: '4', subfields: { a: 'PRO Heading' }),
|
85
|
+
marc_field(tag: '650', indicator2: '4', subfields: { a: 'Regular Local Heading' }),
|
86
|
+
marc_field(tag: '650', indicator2: '1', subfields: { a: 'LoC Heading' }),
|
87
|
+
marc_field(tag: '880', indicator2: '4', subfields: { '6': '650', a: 'PRO Alt Heading' }),
|
88
|
+
marc_field(tag: '880', indicator2: '4', subfields: { '6': '650', a: 'Alt LoC Heading' }),
|
89
|
+
marc_field(tag: '880', subfields: { a: 'Alt Provenance', u: 'Alt URI', '6': '561' })
|
90
|
+
]
|
91
|
+
end
|
92
|
+
|
93
|
+
let(:values) { helper.provenance_show(record) }
|
94
|
+
|
95
|
+
it 'returns expected data from 561, 650, and linked alternates, removing PRO prefix and ignoring Athenaeum copy' do
|
96
|
+
expect(values).to contain_exactly('Not Athenaeum copy:', 'Heading', 'Alt Provenance', 'Alt Heading')
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '.contents_show' do
|
101
|
+
let(:record) { marc_record(fields: fields) }
|
102
|
+
let(:fields) do
|
103
|
+
[
|
104
|
+
marc_field(tag: '505', subfields: { a: 'Formatted content notes', g: 'Misc Info', r: 'Responsible Agent',
|
105
|
+
t: 'A Title', u: 'URI' }),
|
106
|
+
marc_field(tag: '880', subfields: { a: 'Alt Formatted content notes', g: ' Alt Misc Info',
|
107
|
+
r: 'Alt Responsible Agent', t: 'Alt Title', u: 'Alt URI', '6': '505' })
|
108
|
+
]
|
109
|
+
end
|
110
|
+
|
111
|
+
let(:values) { helper.contents_show(record) }
|
112
|
+
|
113
|
+
it 'returns expected values from 505 and its linked alternate' do
|
114
|
+
expect(values).to contain_exactly(
|
115
|
+
'Formatted content notes Misc Info Responsible Agent A Title URI',
|
116
|
+
'Alt Formatted content notes Alt Misc Info Alt Responsible Agent Alt Title Alt URI'
|
117
|
+
)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe '.access_restriction_show' do
|
122
|
+
let(:record) { marc_record(fields: fields) }
|
123
|
+
let(:fields) do
|
124
|
+
[
|
125
|
+
marc_field(tag: '506', subfields: { a: 'Open to users with valid PennKey', b: 'Donor', c: 'Appointment Only',
|
126
|
+
d: 'estate executors', e: 'Some Policy', f: 'No online access',
|
127
|
+
g: '20300101', q: 'Van Pelt', u: 'URI', '2': 'star' })
|
128
|
+
]
|
129
|
+
end
|
130
|
+
|
131
|
+
let(:values) { helper.access_restriction_show(record) }
|
132
|
+
|
133
|
+
it 'returns expected values from 506' do
|
134
|
+
expect(values).to contain_exactly(
|
135
|
+
'Open to users with valid PennKey Donor Appointment Only estate executors Some Policy No online access
|
136
|
+
20300101 Van Pelt URI star'.squish
|
137
|
+
)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe '.finding_aid_show' do
|
142
|
+
let(:record) { marc_record(fields: fields) }
|
143
|
+
|
144
|
+
let(:fields) do
|
145
|
+
[
|
146
|
+
marc_field(tag: '555', subfields: { a: 'Finding aid', b: 'Source', c: 'Item level control',
|
147
|
+
d: 'citation', u: 'URI', '3': 'Materials' }),
|
148
|
+
marc_field(tag: '880', subfields: { a: 'Alt Finding aid', b: 'Alt Source', c: 'Alt Item level control',
|
149
|
+
d: 'Alt citation', u: 'Alt URI', '3': 'Alt Materials', '6': '555' })
|
150
|
+
]
|
151
|
+
end
|
152
|
+
|
153
|
+
let(:values) { helper.finding_aid_show(record) }
|
154
|
+
|
155
|
+
it 'returns expected values from 555 and its linked alternate' do
|
156
|
+
expect(values).to contain_exactly(
|
157
|
+
'Finding aid Source Item level control citation URI Materials',
|
158
|
+
'Alt Finding aid Alt Source Alt Item level control Alt citation Alt URI Alt Materials'
|
159
|
+
)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '.participant_show' do
|
164
|
+
let(:record) { marc_record(fields: fields) }
|
165
|
+
|
166
|
+
let(:fields) do
|
167
|
+
[
|
168
|
+
marc_field(tag: '511', subfields: { a: 'Narrator: Some Dev' }),
|
169
|
+
marc_field(tag: '880', subfields: { a: 'Alt Participant', '6': '511' })
|
170
|
+
]
|
171
|
+
end
|
172
|
+
|
173
|
+
let(:values) { helper.participant_show(record) }
|
174
|
+
|
175
|
+
it 'returns expected values from 511 and its linked alternate' do
|
176
|
+
expect(values).to contain_exactly('Narrator: Some Dev', 'Alt Participant')
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe '.credits_show' do
|
181
|
+
let(:record) { marc_record(fields: fields) }
|
182
|
+
|
183
|
+
let(:fields) do
|
184
|
+
[
|
185
|
+
marc_field(tag: '508', subfields: { a: 'Music: Some Dev' }),
|
186
|
+
marc_field(tag: '880', subfields: { a: 'Alt Credits', '6': '508' })
|
187
|
+
]
|
188
|
+
end
|
189
|
+
|
190
|
+
let(:values) { helper.credits_show(record) }
|
191
|
+
|
192
|
+
it 'returns expected values from 508 and its linked alternate' do
|
193
|
+
expect(values).to contain_exactly('Music: Some Dev', 'Alt Credits')
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
describe '.biography_show' do
|
198
|
+
let(:record) { marc_record(fields: fields) }
|
199
|
+
|
200
|
+
let(:fields) do
|
201
|
+
[
|
202
|
+
marc_field(tag: '545', subfields: { a: 'A Creator', b: 'Additional Info', 'u': 'URI' }),
|
203
|
+
marc_field(tag: '880', subfields: { a: 'Alt Bio', b: 'Alt Info', u: 'Alt URI', '6': '545' })
|
204
|
+
]
|
205
|
+
end
|
206
|
+
|
207
|
+
let(:values) { helper.biography_show(record) }
|
208
|
+
|
209
|
+
it 'returns expected values from 545 and its linked alternate' do
|
210
|
+
expect(values).to contain_exactly('A Creator Additional Info URI',
|
211
|
+
'Alt Bio Alt Info Alt URI')
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
describe '.summary_show' do
|
216
|
+
let(:record) { marc_record(fields: fields) }
|
217
|
+
|
218
|
+
let(:fields) do
|
219
|
+
[
|
220
|
+
marc_field(tag: '520', subfields: { a: 'An Abstract', b: 'Additional Summary', 'c': 'ProQuest' }),
|
221
|
+
marc_field(tag: '880', subfields: { a: 'Alt Abstract', b: 'Alt Additional Summary', c: 'Alt ProQuest',
|
222
|
+
'6': '520' })
|
223
|
+
]
|
224
|
+
end
|
225
|
+
|
226
|
+
let(:values) { helper.summary_show(record) }
|
227
|
+
|
228
|
+
it 'returns expected values from 520 and its linked alternate' do
|
229
|
+
expect(values).to contain_exactly('An Abstract Additional Summary ProQuest',
|
230
|
+
'Alt Abstract Alt Additional Summary Alt ProQuest')
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
@@ -0,0 +1,193 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'PennMARC::Production' do
|
4
|
+
include MarcSpecHelpers
|
5
|
+
|
6
|
+
let(:helper) { PennMARC::Production }
|
7
|
+
|
8
|
+
describe '.show' do
|
9
|
+
let(:record) { marc_record fields: fields }
|
10
|
+
|
11
|
+
let(:fields) do
|
12
|
+
[
|
13
|
+
marc_field(tag: '264', subfields: { a: 'Marabella, Trinidad, West Indies',
|
14
|
+
b: 'Queen Bishop Productions Limited',
|
15
|
+
c: '2016' }, indicator2: '0'),
|
16
|
+
marc_field(tag: '264', subfields: { a: 'Leeds', b: 'Peepal Tree Productions', c: '2019' }, indicator2: '0'),
|
17
|
+
marc_field(tag: '264', subfields: { a: 'Nowhere', b: 'Wasteland Publishing', c: '1999' }, indicator2: '1'),
|
18
|
+
marc_field(tag: '880', subfields: { a: 'Linked', b: 'Alternate Productions', c: '880', '6': '264' },
|
19
|
+
indicator2: '0')
|
20
|
+
]
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:values) { helper.show(record) }
|
24
|
+
|
25
|
+
it 'returns expected values' do
|
26
|
+
expect(values).to contain_exactly(
|
27
|
+
'Marabella, Trinidad, West Indies Queen Bishop Productions Limited 2016',
|
28
|
+
'Leeds Peepal Tree Productions 2019',
|
29
|
+
'Linked Alternate Productions 880'
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.distribution_show' do
|
35
|
+
let(:record) { marc_record fields: fields }
|
36
|
+
let(:fields) do
|
37
|
+
[
|
38
|
+
marc_field(tag: '264', subfields: { a: 'Marabella, Trinidad, West Indies',
|
39
|
+
b: 'Queen Bishop Distributors Limited',
|
40
|
+
c: '2016' }, indicator2: '2'),
|
41
|
+
marc_field(tag: '264', subfields: { a: 'Leeds', b: 'Peepal Tree Distributors', c: '2019' }, indicator2: '2'),
|
42
|
+
marc_field(tag: '264', subfields: { a: 'Nowhere', b: 'Wasteland Publishing', c: '1999' }, indicator2: '1'),
|
43
|
+
marc_field(tag: '880', subfields: { a: 'Linked', b: 'Alternate Distributors', c: '880', '6': '264' },
|
44
|
+
indicator2: '2')
|
45
|
+
]
|
46
|
+
end
|
47
|
+
let(:values) { helper.distribution_show(record) }
|
48
|
+
|
49
|
+
it 'returns expected values' do
|
50
|
+
expect(values).to contain_exactly(
|
51
|
+
'Marabella, Trinidad, West Indies Queen Bishop Distributors Limited 2016',
|
52
|
+
'Leeds Peepal Tree Distributors 2019',
|
53
|
+
'Linked Alternate Distributors 880'
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '.manufacture_show' do
|
59
|
+
let(:record) { marc_record fields: fields }
|
60
|
+
|
61
|
+
let(:fields) do
|
62
|
+
[
|
63
|
+
marc_field(tag: '264', subfields: { a: 'Marabella, Trinidad, West Indies',
|
64
|
+
b: 'Queen Bishop Manufacturers Limited',
|
65
|
+
c: '2016' }, indicator2: '3'),
|
66
|
+
marc_field(tag: '264', subfields: { a: 'Leeds', b: 'Peepal Tree Manufacturers', c: '2019' }, indicator2: '3'),
|
67
|
+
marc_field(tag: '264', subfields: { a: 'Nowhere', b: 'Wasteland Publishing', c: '1999' }, indicator2: '1'),
|
68
|
+
marc_field(tag: '880', subfields: { a: 'Linked', b: 'Alternate Manufacturers', c: '880', '6': '264' },
|
69
|
+
indicator2: '3')
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
let(:values) { helper.manufacture_show(record) }
|
74
|
+
|
75
|
+
it 'returns expected values' do
|
76
|
+
expect(values).to contain_exactly(
|
77
|
+
'Marabella, Trinidad, West Indies Queen Bishop Manufacturers Limited 2016',
|
78
|
+
'Leeds Peepal Tree Manufacturers 2019',
|
79
|
+
'Linked Alternate Manufacturers 880'
|
80
|
+
)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '.publication_values' do
|
85
|
+
context 'with date in 245 ǂf' do
|
86
|
+
let(:record) { marc_record fields: fields }
|
87
|
+
|
88
|
+
let(:fields) do
|
89
|
+
[
|
90
|
+
marc_field(tag: '245', subfields: { f: '1869-1941' }),
|
91
|
+
marc_field(tag: '264', subfields: { a: 'Marabella, Trinidad, West Indies',
|
92
|
+
b: 'Queen Bishop Publishing Limited',
|
93
|
+
c: '1920' }, indicator2: '1')
|
94
|
+
]
|
95
|
+
end
|
96
|
+
|
97
|
+
let(:values) { helper.publication_values(record) }
|
98
|
+
|
99
|
+
it 'returns expected values' do
|
100
|
+
expect(values).to contain_exactly('1869-1941',
|
101
|
+
'Marabella, Trinidad, West Indies Queen Bishop Publishing Limited 1920')
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'with 260, 261, or 262 fields' do
|
106
|
+
let(:record) { marc_record fields: fields }
|
107
|
+
|
108
|
+
let(:fields) do
|
109
|
+
[
|
110
|
+
marc_field(tag: '260', subfields: { a: ' Burnt Mill, Harlow, Essex, England', b: 'Longman',
|
111
|
+
c: '1985, c1956.' }),
|
112
|
+
marc_field(tag: '264', subfields: { a: 'Nowhere', b: 'Wasteland Publishers', c: '1999' }, indicator2: '1')
|
113
|
+
]
|
114
|
+
end
|
115
|
+
|
116
|
+
let(:values) { helper.publication_values(record) }
|
117
|
+
|
118
|
+
it 'returns expected values' do
|
119
|
+
expect(values).to contain_exactly('Burnt Mill, Harlow, Essex, England Longman 1985, c1956.')
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'without 260, 261, or 262 fields' do
|
124
|
+
let(:record) { marc_record fields: fields }
|
125
|
+
|
126
|
+
let(:fields) do
|
127
|
+
[
|
128
|
+
marc_field(tag: '264', subfields: { a: 'Nowhere', b: 'Wasteland Publishers', c: '1999' }, indicator2: '1'),
|
129
|
+
marc_field(tag: '264', subfields: { a: 'Leeds', b: 'Peepal Tree Productions', c: '2019' }, indicator2: '0'),
|
130
|
+
marc_field(tag: '264', subfields: { c: ' c2016' }, indicator2: '4')
|
131
|
+
]
|
132
|
+
end
|
133
|
+
|
134
|
+
let(:values) { helper.publication_values(record) }
|
135
|
+
|
136
|
+
it 'returns publication values from field 264' do
|
137
|
+
expect(values).to contain_exactly('Nowhere Wasteland Publishers 1999 , c2016')
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe '.publication_show' do
|
143
|
+
let(:record) { marc_record fields: fields }
|
144
|
+
|
145
|
+
let(:fields) do
|
146
|
+
[marc_field(tag: '245', subfields: { f: 'between 1800-1850' }),
|
147
|
+
marc_field(tag: '260', subfields: { a: ' Burnt Mill, Harlow, Essex, England', b: 'Longman',
|
148
|
+
c: '1985, c1956.' }),
|
149
|
+
marc_field(tag: '264', subfields: { a: 'Leeds', b: 'Peepal Tree Press', c: '2019' }, indicator2: '1'),
|
150
|
+
marc_field(tag: '880', subfields: { f: 'Alternate 1800-1850', '6': '245' }),
|
151
|
+
marc_field(tag: '880',
|
152
|
+
subfields: { a: 'Alternate England', b: 'Alternate Longman', c: 'Alternate 1985, c1956.',
|
153
|
+
'6': '260' }),
|
154
|
+
marc_field(tag: '880', subfields: { a: 'Linked', b: 'Alternate Publishers', c: '880', '6': '264' },
|
155
|
+
indicator2: '1')]
|
156
|
+
end
|
157
|
+
|
158
|
+
let(:values) { helper.publication_show(record) }
|
159
|
+
|
160
|
+
it 'returns expected values' do
|
161
|
+
expect(values).to contain_exactly('between 1800-1850',
|
162
|
+
'Burnt Mill, Harlow, Essex, England Longman 1985, c1956.',
|
163
|
+
'Leeds Peepal Tree Press 2019',
|
164
|
+
'Alternate 1800-1850',
|
165
|
+
'Alternate England Alternate Longman Alternate 1985, c1956.',
|
166
|
+
'Linked Alternate Publishers 880')
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe 'place_of_publication_show' do
|
171
|
+
let(:record) { marc_record fields: fields }
|
172
|
+
|
173
|
+
let(:fields) do
|
174
|
+
[marc_field(tag: '752', subfields: { a: 'United States', b: 'California', c: 'Los Angeles (County)',
|
175
|
+
d: 'Los Angeles', e: 'publication place', f: 'Little Tokyo',
|
176
|
+
g: 'North America', h: 'Earth' }),
|
177
|
+
marc_field(tag: '880', subfields: { a: 'US', b: 'Cali',
|
178
|
+
c: 'LA (County)', d: 'LA',
|
179
|
+
e: 'Alt publication place',
|
180
|
+
f: 'Alt Tokyo', g: 'NA',
|
181
|
+
h: 'Alt Earth', '6': '752' })]
|
182
|
+
end
|
183
|
+
|
184
|
+
let(:values) { helper.place_of_publication_show(record) }
|
185
|
+
|
186
|
+
it 'returns expected values' do
|
187
|
+
expect(values).to contain_exactly(
|
188
|
+
'United States California Los Angeles (County) Los Angeles Little Tokyo North America Earth publication place',
|
189
|
+
'US Cali LA (County) LA Alt Tokyo NA Alt Earth Alt publication place'
|
190
|
+
)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'PennMARC::Relation' do
|
4
|
+
include MarcSpecHelpers
|
5
|
+
|
6
|
+
let(:helper) { PennMARC::Relation }
|
7
|
+
let(:record) { marc_record fields: fields }
|
8
|
+
let(:relator_map) { { aut: 'Author', trl: 'Translator' } }
|
9
|
+
|
10
|
+
describe '.contained_in_show' do
|
11
|
+
let(:fields) do
|
12
|
+
[marc_field(tag: '773', subfields: { i: 'Contained in (work):', t: 'National geographic magazine',
|
13
|
+
w: '(OCoLC)12345' })]
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'returns only the specified subfields' do
|
17
|
+
expect(helper.contained_in_show(record)).to eq ['Contained in (work): National geographic magazine']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.chronology_show' do
|
22
|
+
let(:fields) do
|
23
|
+
[marc_field(tag: '650', indicator2: '4', subfields: { a: 'CHR Heading' }),
|
24
|
+
marc_field(tag: '650', indicator2: '4', subfields: { a: 'Regular Local Heading' }),
|
25
|
+
marc_field(tag: '650', indicator2: '1', subfields: { a: 'LoC Heading' }),
|
26
|
+
marc_field(tag: '880', indicator2: '4', subfields: { '6': '650', a: 'CHR Alt. Heading' }),
|
27
|
+
marc_field(tag: '880', indicator2: '4', subfields: { '6': '999', a: 'Another Alt.' })]
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns only the specified subfield data and linked alternate field with CHR prefix removed' do
|
31
|
+
expect(helper.chronology_show(record)).to eq ['Heading', 'Alt. Heading']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '.related_collections_show' do
|
36
|
+
let(:fields) do
|
37
|
+
[marc_field(tag: '544', subfields: { d: 'Penn Papers', c: 'USA' }),
|
38
|
+
marc_field(tag: '880', subfields: { '6': '544', d: 'Penn Papers Alt.' })]
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns all expected subfield data for field and linked alternate' do
|
42
|
+
expect(helper.related_collections_show(record)).to eq ['Penn Papers USA', 'Penn Papers Alt.']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '.publications_about_show' do
|
47
|
+
let(:fields) do
|
48
|
+
[marc_field(tag: '581', subfields: { '3': 'Preliminary Report', a: '"Super Important Research Topic", 1977' }),
|
49
|
+
marc_field(tag: '880', subfields: { '6': '581', '3': 'Alt. Preliminary Report' })]
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'returns all expected subfield data for field and linked alternate' do
|
53
|
+
expect(helper.publications_about_show(record)).to eq ['Preliminary Report "Super Important Research Topic", 1977',
|
54
|
+
'Alt. Preliminary Report']
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'related_work_show' do
|
59
|
+
let(:fields) do
|
60
|
+
[marc_field(tag: '700', indicator2: '', subfields: { i: 'Translation of (work):', a: 'Some Author',
|
61
|
+
t: 'Aphorisms', '4': 'trl' }),
|
62
|
+
marc_field(tag: '700', indicator2: '2', subfields: { i: 'Adaptation of (work):', t: 'Ignored' }),
|
63
|
+
marc_field(tag: '880', indicator2: '', subfields: { i: 'Alt. Prefix:', a: 'Alt. Author', t: 'Alt. Aphorisms',
|
64
|
+
'6': '700' })]
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'returns specified subfield values from specified field with blank indicator2' do
|
68
|
+
values = helper.related_work_show record, relator_map
|
69
|
+
expect(values).to contain_exactly 'Translation of: Some Author Aphorisms, Translator',
|
70
|
+
'Alt. Prefix: Alt. Author Alt. Aphorisms'
|
71
|
+
expect(values).not_to include 'Ignored'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '.contains_show' do
|
76
|
+
let(:fields) do
|
77
|
+
[marc_field(tag: '700', indicator2: '2', subfields: { i: 'Container of (work):', a: 'Some Author', t: 'Works',
|
78
|
+
'4': 'aut' }),
|
79
|
+
marc_field(tag: '700', indicator2: '', subfields: { i: 'Adaptation of (work):', t: 'Ignored' }),
|
80
|
+
marc_field(tag: '880', indicator2: '2', subfields: { i: 'Alt. Prefix:', a: 'Alt. Name', '6': '700' })]
|
81
|
+
end
|
82
|
+
|
83
|
+
it "returns specified subfield values from specified field with '2' in indicator2" do
|
84
|
+
values = helper.contains_show record, relator_map
|
85
|
+
expect(values).to contain_exactly 'Alt. Prefix: Alt. Name', 'Container of: Some Author Works, Author'
|
86
|
+
expect(values).not_to include 'Ignored'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '.constituent_unit_show' do
|
91
|
+
let(:fields) do
|
92
|
+
[marc_field(tag: '774', subfields: { i: 'Container of (manifestation)', a: 'Person, Some',
|
93
|
+
t: 'Private Correspondences', w: '(OCoLC)12345' }),
|
94
|
+
marc_field(tag: '880', subfields: { '6': '774', a: 'Alt. Person', t: 'Alt. Title' })]
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'returns specified subfield values from fields and linked alternate' do
|
98
|
+
expect(helper.constituent_unit_show(record)).to(
|
99
|
+
contain_exactly('Alt. Person Alt. Title',
|
100
|
+
'Container of (manifestation) Person, Some Private Correspondences')
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe '.has_supplement_show' do
|
106
|
+
let(:fields) do
|
107
|
+
[marc_field(tag: '770', subfields: { i: 'Supplement (work)', a: 'Person, Some',
|
108
|
+
t: 'Diaries, errata', w: '(OCoLC)12345' }),
|
109
|
+
marc_field(tag: '880', subfields: { '6': '770', a: 'Alt. Person', t: 'Alt. Title' })]
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'return all subfield values for the field and linked alternate' do
|
113
|
+
expect(helper.has_supplement_show(record)).to(
|
114
|
+
contain_exactly(
|
115
|
+
'Alt. Person Alt. Title', 'Supplement (work) Person, Some Diaries, errata (OCoLC)12345'
|
116
|
+
)
|
117
|
+
)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|