pennmarc 1.0.24 → 1.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +8 -9
  3. data/lib/pennmarc/enriched.rb +1 -0
  4. data/lib/pennmarc/helpers/access.rb +8 -6
  5. data/lib/pennmarc/helpers/creator.rb +139 -65
  6. data/lib/pennmarc/helpers/edition.rb +5 -3
  7. data/lib/pennmarc/helpers/identifier.rb +12 -0
  8. data/lib/pennmarc/helpers/note.rb +24 -19
  9. data/lib/pennmarc/helpers/production.rb +113 -20
  10. data/lib/pennmarc/helpers/subject.rb +10 -4
  11. data/lib/pennmarc/helpers/title.rb +39 -26
  12. data/lib/pennmarc/test/marc_helpers.rb +83 -0
  13. data/lib/pennmarc/util.rb +98 -69
  14. data/lib/pennmarc/version.rb +1 -1
  15. data/lib/pennmarc.rb +7 -0
  16. data/spec/lib/pennmarc/helpers/access_spec.rb +11 -2
  17. data/spec/lib/pennmarc/helpers/citation_spec.rb +0 -2
  18. data/spec/lib/pennmarc/helpers/classification_spec.rb +0 -2
  19. data/spec/lib/pennmarc/helpers/creator_spec.rb +103 -2
  20. data/spec/lib/pennmarc/helpers/database_spec.rb +0 -2
  21. data/spec/lib/pennmarc/helpers/date_spec.rb +0 -2
  22. data/spec/lib/pennmarc/helpers/edition_spec.rb +4 -2
  23. data/spec/lib/pennmarc/helpers/format_spec.rb +0 -2
  24. data/spec/lib/pennmarc/helpers/genre_spec.rb +0 -2
  25. data/spec/lib/pennmarc/helpers/identifer_spec.rb +14 -2
  26. data/spec/lib/pennmarc/helpers/inventory_spec.rb +0 -2
  27. data/spec/lib/pennmarc/helpers/language_spec.rb +0 -2
  28. data/spec/lib/pennmarc/helpers/link_spec.rb +0 -2
  29. data/spec/lib/pennmarc/helpers/location_spec.rb +0 -2
  30. data/spec/lib/pennmarc/helpers/note_spec.rb +22 -29
  31. data/spec/lib/pennmarc/helpers/production_spec.rb +121 -22
  32. data/spec/lib/pennmarc/helpers/relation_spec.rb +0 -2
  33. data/spec/lib/pennmarc/helpers/series_spec.rb +0 -2
  34. data/spec/lib/pennmarc/helpers/subject_spec.rb +16 -2
  35. data/spec/lib/pennmarc/helpers/title_spec.rb +20 -2
  36. data/spec/lib/pennmarc/marc_util_spec.rb +0 -2
  37. data/spec/lib/pennmarc/parser_spec.rb +1 -1
  38. data/spec/spec_helper.rb +7 -0
  39. data/spec/support/fixture_helpers.rb +10 -0
  40. metadata +4 -3
  41. data/spec/support/marc_spec_helpers.rb +0 -85
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe 'PennMARC::Location' do
4
- include MarcSpecHelpers
5
-
6
4
  let(:helper) { PennMARC::Location }
7
5
  let(:enriched_marc) { PennMARC::Enriched }
8
6
  let(:mapping) { location_map }
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe 'PennMARC::Note' do
4
- include MarcSpecHelpers
5
-
6
4
  let(:helper) { PennMARC::Note }
5
+ let(:record) { marc_record(fields: fields) }
7
6
 
8
7
  describe '.notes_show' do
9
- let(:record) { marc_record(fields: fields) }
10
8
  let(:fields) do
11
9
  [
12
10
  marc_field(tag: '500',
@@ -39,7 +37,6 @@ describe 'PennMARC::Note' do
39
37
  end
40
38
 
41
39
  describe '.local_notes_show' do
42
- let(:record) { marc_record(fields: fields) }
43
40
  let(:fields) do
44
41
  [
45
42
  marc_field(tag: '561', subfields: { a: 'Athenaeum copy: ', u: 'No URI' }),
@@ -76,7 +73,6 @@ describe 'PennMARC::Note' do
76
73
  end
77
74
 
78
75
  describe '.provenance_show' do
79
- let(:record) { marc_record(fields: fields) }
80
76
  let(:fields) do
81
77
  [
82
78
  marc_field(tag: '561', subfields: { a: 'Not Athenaeum copy: ', u: 'No URI' }, indicator1: '1', indicator2: ' '),
@@ -99,29 +95,35 @@ describe 'PennMARC::Note' do
99
95
  end
100
96
  end
101
97
 
102
- describe '.contents_show' do
103
- let(:record) { marc_record(fields: fields) }
98
+ describe '.contents_values' do
104
99
  let(:fields) do
105
- [
106
- marc_field(tag: '505', subfields: { a: 'Formatted content notes', g: 'Misc Info', r: 'Responsible Agent',
107
- t: 'A Title', u: 'URI' }),
108
- marc_field(tag: '880', subfields: { a: 'Alt Formatted content notes', g: ' Alt Misc Info',
109
- r: 'Alt Responsible Agent', t: 'Alt Title', u: 'Alt URI', '6': '505' })
110
- ]
100
+ [marc_field(tag: '505', subfields: { a: 'Formatted content notes', g: 'Misc Info', r: 'Responsible Agent',
101
+ t: 'A Title', u: 'URI' }),
102
+ marc_field(tag: '880', subfields: { a: 'Alt Formatted content notes', g: ' Alt Misc Info',
103
+ r: 'Alt Responsible Agent', t: 'Alt Title', u: 'Alt URI', '6': '505' })]
111
104
  end
112
105
 
113
- let(:values) { helper.contents_show(record) }
106
+ context 'with vernacular included' do
107
+ let(:values) { helper.contents_values(record) }
114
108
 
115
- it 'returns expected values from 505 and its linked alternate' do
116
- expect(values).to contain_exactly(
117
- 'Formatted content notes Misc Info Responsible Agent A Title URI',
118
- 'Alt Formatted content notes Alt Misc Info Alt Responsible Agent Alt Title Alt URI'
119
- )
109
+ it 'returns expected values from 505 and its linked alternate' do
110
+ expect(values).to contain_exactly(
111
+ 'Formatted content notes Misc Info Responsible Agent A Title URI',
112
+ 'Alt Formatted content notes Alt Misc Info Alt Responsible Agent Alt Title Alt URI'
113
+ )
114
+ end
115
+ end
116
+
117
+ context 'with vernacular excluded' do
118
+ let(:values) { helper.contents_values(record, with_alternate: false) }
119
+
120
+ it 'returns expected values from 505 but not its linked alternate' do
121
+ expect(values).to contain_exactly('Formatted content notes Misc Info Responsible Agent A Title URI')
122
+ end
120
123
  end
121
124
  end
122
125
 
123
126
  describe '.access_restriction_show' do
124
- let(:record) { marc_record(fields: fields) }
125
127
  let(:fields) do
126
128
  [
127
129
  marc_field(tag: '506', subfields: { a: 'Open to users with valid PennKey', b: 'Donor', c: 'Appointment Only',
@@ -129,7 +131,6 @@ describe 'PennMARC::Note' do
129
131
  g: '20300101', q: 'Van Pelt', u: 'URI', '2': 'star' })
130
132
  ]
131
133
  end
132
-
133
134
  let(:values) { helper.access_restriction_show(record) }
134
135
 
135
136
  it 'returns expected values from 506' do
@@ -141,8 +142,6 @@ describe 'PennMARC::Note' do
141
142
  end
142
143
 
143
144
  describe '.finding_aid_show' do
144
- let(:record) { marc_record(fields: fields) }
145
-
146
145
  let(:fields) do
147
146
  [
148
147
  marc_field(tag: '555', subfields: { a: 'Finding aid', b: 'Source', c: 'Item level control',
@@ -151,7 +150,6 @@ describe 'PennMARC::Note' do
151
150
  d: 'Alt citation', u: 'Alt URI', '3': 'Alt Materials', '6': '555' })
152
151
  ]
153
152
  end
154
-
155
153
  let(:values) { helper.finding_aid_show(record) }
156
154
 
157
155
  it 'returns expected values from 555 and its linked alternate' do
@@ -163,15 +161,12 @@ describe 'PennMARC::Note' do
163
161
  end
164
162
 
165
163
  describe '.participant_show' do
166
- let(:record) { marc_record(fields: fields) }
167
-
168
164
  let(:fields) do
169
165
  [
170
166
  marc_field(tag: '511', subfields: { a: 'Narrator: Some Dev' }),
171
167
  marc_field(tag: '880', subfields: { a: 'Alt Participant', '6': '511' })
172
168
  ]
173
169
  end
174
-
175
170
  let(:values) { helper.participant_show(record) }
176
171
 
177
172
  it 'returns expected values from 511 and its linked alternate' do
@@ -180,8 +175,6 @@ describe 'PennMARC::Note' do
180
175
  end
181
176
 
182
177
  describe '.credits_show' do
183
- let(:record) { marc_record(fields: fields) }
184
-
185
178
  let(:fields) do
186
179
  [
187
180
  marc_field(tag: '508', subfields: { a: 'Music: Some Dev' }),
@@ -1,13 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe 'PennMARC::Production' do
4
- include MarcSpecHelpers
5
-
6
4
  let(:helper) { PennMARC::Production }
5
+ let(:record) { marc_record fields: fields }
7
6
 
8
7
  describe '.show' do
9
- let(:record) { marc_record fields: fields }
10
-
11
8
  let(:fields) do
12
9
  [
13
10
  marc_field(tag: '264', subfields: { a: 'Marabella, Trinidad, West Indies',
@@ -19,7 +16,6 @@ describe 'PennMARC::Production' do
19
16
  indicator2: '0')
20
17
  ]
21
18
  end
22
-
23
19
  let(:values) { helper.show(record) }
24
20
 
25
21
  it 'returns expected values' do
@@ -31,6 +27,21 @@ describe 'PennMARC::Production' do
31
27
  end
32
28
  end
33
29
 
30
+ describe '.search' do
31
+ let(:fields) do
32
+ [
33
+ marc_field(tag: '260', subfields: { a: 'Marabella, Trinidad, West Indies',
34
+ b: 'Ramjohn Publishing', c: '1999' }, indicator2: '0'),
35
+ marc_field(tag: '264', subfields: { a: 'Leeds', b: 'Peepal Tree Productions', c: '2019' }, indicator2: '0'),
36
+ marc_field(tag: '264', subfields: { a: 'Nowhere', b: 'Wasteland Publishing', c: '1999' }, indicator2: '1')
37
+ ]
38
+ end
39
+
40
+ it 'returns expected values' do
41
+ expect(helper.search(record)).to contain_exactly('Wasteland Publishing', 'Ramjohn Publishing')
42
+ end
43
+ end
44
+
34
45
  describe '.distribution_show' do
35
46
  let(:record) { marc_record fields: fields }
36
47
  let(:fields) do
@@ -57,7 +68,6 @@ describe 'PennMARC::Production' do
57
68
 
58
69
  describe '.manufacture_show' do
59
70
  let(:record) { marc_record fields: fields }
60
-
61
71
  let(:fields) do
62
72
  [
63
73
  marc_field(tag: '264', subfields: { a: 'Marabella, Trinidad, West Indies',
@@ -69,7 +79,6 @@ describe 'PennMARC::Production' do
69
79
  indicator2: '3')
70
80
  ]
71
81
  end
72
-
73
82
  let(:values) { helper.manufacture_show(record) }
74
83
 
75
84
  it 'returns expected values' do
@@ -83,8 +92,6 @@ describe 'PennMARC::Production' do
83
92
 
84
93
  describe '.publication_values' do
85
94
  context 'with date in 245 ǂf' do
86
- let(:record) { marc_record fields: fields }
87
-
88
95
  let(:fields) do
89
96
  [
90
97
  marc_field(tag: '245', subfields: { f: '1869-1941' }),
@@ -93,7 +100,6 @@ describe 'PennMARC::Production' do
93
100
  c: '1920' }, indicator2: '1')
94
101
  ]
95
102
  end
96
-
97
103
  let(:values) { helper.publication_values(record) }
98
104
 
99
105
  it 'returns expected values' do
@@ -103,16 +109,13 @@ describe 'PennMARC::Production' do
103
109
  end
104
110
 
105
111
  context 'with 260, 261, or 262 fields' do
106
- let(:record) { marc_record fields: fields }
107
-
108
112
  let(:fields) do
109
113
  [
110
- marc_field(tag: '260', subfields: { a: ' Burnt Mill, Harlow, Essex, England', b: 'Longman',
114
+ marc_field(tag: '260', subfields: { a: 'Burnt Mill, Harlow, Essex, England', b: 'Longman',
111
115
  c: '1985, c1956.' }),
112
116
  marc_field(tag: '264', subfields: { a: 'Nowhere', b: 'Wasteland Publishers', c: '1999' }, indicator2: '1')
113
117
  ]
114
118
  end
115
-
116
119
  let(:values) { helper.publication_values(record) }
117
120
 
118
121
  it 'returns expected values' do
@@ -121,8 +124,6 @@ describe 'PennMARC::Production' do
121
124
  end
122
125
 
123
126
  context 'without 260, 261, or 262 fields' do
124
- let(:record) { marc_record fields: fields }
125
-
126
127
  let(:fields) do
127
128
  [
128
129
  marc_field(tag: '264', subfields: { a: 'Nowhere', b: 'Wasteland Publishers', c: '1999' }, indicator2: '1'),
@@ -130,7 +131,6 @@ describe 'PennMARC::Production' do
130
131
  marc_field(tag: '264', subfields: { c: ' c2016' }, indicator2: '4')
131
132
  ]
132
133
  end
133
-
134
134
  let(:values) { helper.publication_values(record) }
135
135
 
136
136
  it 'returns publication values from field 264' do
@@ -140,8 +140,6 @@ describe 'PennMARC::Production' do
140
140
  end
141
141
 
142
142
  describe '.publication_show' do
143
- let(:record) { marc_record fields: fields }
144
-
145
143
  let(:fields) do
146
144
  [marc_field(tag: '245', subfields: { f: 'between 1800-1850' }),
147
145
  marc_field(tag: '260', subfields: { a: ' Burnt Mill, Harlow, Essex, England', b: 'Longman',
@@ -154,7 +152,6 @@ describe 'PennMARC::Production' do
154
152
  marc_field(tag: '880', subfields: { a: 'Linked', b: 'Alternate Publishers', c: '880', '6': '264' },
155
153
  indicator2: '1')]
156
154
  end
157
-
158
155
  let(:values) { helper.publication_show(record) }
159
156
 
160
157
  it 'returns expected values' do
@@ -167,9 +164,38 @@ describe 'PennMARC::Production' do
167
164
  end
168
165
  end
169
166
 
170
- describe 'place_of_publication_show' do
167
+ describe '.publication_citation_show' do
171
168
  let(:record) { marc_record fields: fields }
172
169
 
170
+ let(:fields) do
171
+ [marc_field(tag: '245', subfields: { f: 'between 1800-1850' }),
172
+ marc_field(tag: '260', subfields: { a: ' Burnt Mill, Harlow, Essex, England', b: 'Longman',
173
+ c: '1985, c1956.' }),
174
+ marc_field(tag: '264', subfields: { a: 'Leeds', b: 'Peepal Tree Press', c: '2019' }, indicator2: '1'),
175
+ marc_field(tag: '880', subfields: { f: 'Alternate 1800-1850', '6': '245' }),
176
+ marc_field(tag: '880',
177
+ subfields: { a: 'Alternate England', b: 'Alternate Longman', c: 'Alternate 1985, c1956.',
178
+ '6': '260' }),
179
+ marc_field(tag: '880', subfields: { a: 'Linked', b: 'Alternate Publishers', c: '880', '6': '264' },
180
+ indicator2: '1')]
181
+ end
182
+ let(:values) { helper.publication_citation_show(record) }
183
+ let(:values_no_year) { helper.publication_citation_show(record, with_year: false) }
184
+
185
+ it 'returns publication citation values' do
186
+ expect(values).to contain_exactly('between 1800-1850',
187
+ 'Burnt Mill, Harlow, Essex, England Longman 1985, c1956.',
188
+ 'Leeds Peepal Tree Press 2019')
189
+ end
190
+
191
+ it 'returns publication citation values without year' do
192
+ expect(values_no_year).to contain_exactly('between 1800-1850',
193
+ 'Burnt Mill, Harlow, Essex, England Longman',
194
+ 'Leeds Peepal Tree Press')
195
+ end
196
+ end
197
+
198
+ describe 'place_of_publication_show' do
173
199
  let(:fields) do
174
200
  [marc_field(tag: '752', subfields: { a: 'United States', b: 'California', c: 'Los Angeles (County)',
175
201
  d: 'Los Angeles', e: 'publication place', f: 'Little Tokyo',
@@ -180,7 +206,6 @@ describe 'PennMARC::Production' do
180
206
  f: 'Alt Tokyo', g: 'NA',
181
207
  h: 'Alt Earth', '6': '752' })]
182
208
  end
183
-
184
209
  let(:values) { helper.place_of_publication_show(record) }
185
210
 
186
211
  it 'returns expected values' do
@@ -190,4 +215,78 @@ describe 'PennMARC::Production' do
190
215
  )
191
216
  end
192
217
  end
218
+
219
+ describe 'place_of_publication_search' do
220
+ let(:values) { helper.place_of_publication_search(record) }
221
+
222
+ context 'with publication info in the 26x fields' do
223
+ let(:fields) do
224
+ [marc_field(tag: '260', subfields: { a: 'Marabella, Trinidad, West Indies',
225
+ b: 'Ramjohn Publishing', c: '1999' }, indicator2: '0'),
226
+ marc_field(tag: '264', subfields: { a: 'Leeds', b: 'Peepal Tree Productions', c: '2019' }, indicator2: '0'),
227
+ marc_field(tag: '264', subfields: { a: 'Nowhere', b: 'Wasteland Publishing', c: '1983' }, indicator2: '1')]
228
+ end
229
+
230
+ it 'returns expected values' do
231
+ expect(values).to contain_exactly('Marabella, Trinidad, West Indies', 'Nowhere')
232
+ end
233
+ end
234
+
235
+ context 'with publication info in 752' do
236
+ let(:fields) do
237
+ [marc_field(tag: '752', subfields: { a: 'United States', b: 'California', c: 'Los Angeles (County)',
238
+ d: 'Los Angeles', e: 'publication place', f: 'Little Tokyo',
239
+ g: 'North America', h: 'Earth' })]
240
+ end
241
+
242
+ it 'returns expected values' do
243
+ expect(values).to contain_exactly(
244
+ 'United States California Los Angeles (County) Los Angeles Little Tokyo North America Earth'
245
+ )
246
+ end
247
+ end
248
+ end
249
+
250
+ describe 'publication_ris_place_of_pub' do
251
+ let(:record) { marc_record fields: fields }
252
+ let(:fields) do
253
+ [marc_field(tag: '245', subfields: { f: 'between 1800-1850' }),
254
+ marc_field(tag: '260', subfields: { a: ' Burnt Mill, Harlow, Essex, England', b: 'Longman',
255
+ c: '1985, c1956.' }),
256
+ marc_field(tag: '264', subfields: { a: 'Leeds', b: 'Peepal Tree Press', c: '2019' }, indicator2: '1'),
257
+ marc_field(tag: '880', subfields: { f: 'Alternate 1800-1850', '6': '245' }),
258
+ marc_field(tag: '880',
259
+ subfields: { a: 'Alternate England', b: 'Alternate Longman', c: 'Alternate 1985, c1956.',
260
+ '6': '260' }),
261
+ marc_field(tag: '880', subfields: { a: 'Linked', b: 'Alternate Publishers', c: '880', '6': '264' },
262
+ indicator2: '1')]
263
+ end
264
+
265
+ let(:values) { helper.publication_ris_place_of_pub(record) }
266
+
267
+ it 'returns expected values' do
268
+ expect(values).to contain_exactly('between 1800-1850', 'Burnt Mill, Harlow, Essex, England', 'Leeds')
269
+ end
270
+ end
271
+
272
+ describe 'publication_ris_publisher' do
273
+ let(:record) { marc_record fields: fields }
274
+ let(:fields) do
275
+ [marc_field(tag: '245', subfields: { f: 'between 1800-1850' }),
276
+ marc_field(tag: '260', subfields: { a: ' Burnt Mill, Harlow, Essex, England', b: 'Longman',
277
+ c: '1985, c1956.' }),
278
+ marc_field(tag: '264', subfields: { a: 'Leeds', b: 'Peepal Tree Press', c: '2019' }, indicator2: '1'),
279
+ marc_field(tag: '880', subfields: { f: 'Alternate 1800-1850', '6': '245' }),
280
+ marc_field(tag: '880',
281
+ subfields: { a: 'Alternate England', b: 'Alternate Longman', c: 'Alternate 1985, c1956.',
282
+ '6': '260' }),
283
+ marc_field(tag: '880', subfields: { a: 'Linked', b: 'Alternate Publishers', c: '880', '6': '264' },
284
+ indicator2: '1')]
285
+ end
286
+ let(:values) { helper.publication_ris_publisher(record) }
287
+
288
+ it 'returns expected values' do
289
+ expect(values).to contain_exactly('between 1800-1850', 'Longman', 'Peepal Tree Press')
290
+ end
291
+ end
193
292
  end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe 'PennMARC::Relation' do
4
- include MarcSpecHelpers
5
-
6
4
  let(:helper) { PennMARC::Relation }
7
5
  let(:record) { marc_record fields: fields }
8
6
  let(:relator_map) { { aut: 'Author', trl: 'Translator' } }
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe 'PennMARC::Series' do
4
- include MarcSpecHelpers
5
-
6
4
  let(:helper) { PennMARC::Series }
7
5
  let(:mapping) { { aut: 'Author' } }
8
6
  let(:record) do
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe 'PennMARC::Subject' do
4
- include MarcSpecHelpers
5
-
6
4
  let(:helper) { PennMARC::Subject }
7
5
  let(:relator_map) do
8
6
  { dpc: 'Depicted' }
@@ -288,6 +286,22 @@ describe 'PennMARC::Subject' do
288
286
  'Early works to 1950.')
289
287
  end
290
288
  end
289
+
290
+ context 'with a mix of allowed and disallowed heading sources' do
291
+ let(:fields) do
292
+ [marc_field(tag: '650', indicator2: '7', subfields: {
293
+ '2': 'fast',
294
+ a: 'Philosophy in motion pictures.',
295
+ '0': 'http://id.loc.gov/authorities/subjects/sh92003501'
296
+ }),
297
+ marc_field(tag: '650', indicator2: '7', subfields: { '2': 'gnd', a: 'Filmästhetik.' }),
298
+ marc_field(tag: '650', indicator2: '6', subfields: { a: 'Cinéma et arts.' })]
299
+ end
300
+
301
+ it 'includes only permitted headings from approved ontologies' do
302
+ expect(values).to contain_exactly 'Philosophy in motion pictures.'
303
+ end
304
+ end
291
305
  end
292
306
 
293
307
  describe '.childrens_show' do
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe 'PennMARC::Title' do
4
- include MarcSpecHelpers
5
-
6
4
  let(:helper) { PennMARC::Title }
7
5
 
8
6
  describe '.search' do
@@ -249,4 +247,24 @@ describe 'PennMARC::Title' do
249
247
  expect(values).not_to include 'Linkage', '247'
250
248
  end
251
249
  end
250
+
251
+ describe '.host_bib_record?' do
252
+ let(:record) { marc_record fields: [marc_field(tag: '245', subfields: subfields)] }
253
+
254
+ context 'with a host record' do
255
+ let(:subfields) { { a: "#{PennMARC::Title::HOST_BIB_TITLE} for 123456789" } }
256
+
257
+ it 'returns true' do
258
+ expect(helper.host_bib_record?(record)).to be true
259
+ end
260
+ end
261
+
262
+ context 'with a non-host record' do
263
+ let(:subfields) { { a: 'Regular record' } }
264
+
265
+ it 'returns false' do
266
+ expect(helper.host_bib_record?(record)).to be false
267
+ end
268
+ end
269
+ end
252
270
  end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe 'PennMARC::Util' do
4
- include MarcSpecHelpers
5
-
6
4
  subject(:util) do
7
5
  Class.new { extend PennMARC::Util }
8
6
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe PennMARC::Parser do
4
- include MarcSpecHelpers
4
+ include FixtureHelpers
5
5
 
6
6
  subject(:parser) { described_class.new }
7
7
 
data/spec/spec_helper.rb CHANGED
@@ -2,8 +2,12 @@
2
2
 
3
3
  $LOAD_PATH.unshift(__dir__) unless $LOAD_PATH.include?(__dir__)
4
4
 
5
+ # Require spec-specific helpers dir
5
6
  Dir[File.join(__dir__, 'support', '**', '*.rb')].each { |f| require f }
6
7
 
8
+ # Require test helpers from gem lib
9
+ Dir[File.join(__dir__, '../lib/pennmarc/test', '*.rb')].each { |f| require f }
10
+
7
11
  require 'pennmarc'
8
12
 
9
13
  # This file was generated by the `rspec --init` command. Conventionally, all
@@ -22,6 +26,9 @@ require 'pennmarc'
22
26
  #
23
27
  # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
24
28
  RSpec.configure do |config|
29
+ # Include MarcHelpers by default
30
+ config.include(PennMARC::Test::MarcHelpers)
31
+
25
32
  # rspec-expectations config goes here. You can use an alternate
26
33
  # assertion/expectation library such as wrong or the stdlib/minitest
27
34
  # assertions if you prefer.
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FixtureHelpers
4
+ # Get the path for a test MARC XML file
5
+ # @param [String] filename of MARCXML fixture
6
+ # @return [String] full path of MARCXML fixture
7
+ def marc_xml_path(filename)
8
+ File.join File.dirname(__FILE__), '..', 'fixtures', 'marcxml', filename
9
+ end
10
+ 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.24
4
+ version: 1.0.26
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-06-18 00:00:00.000000000 Z
13
+ date: 2024-07-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -123,6 +123,7 @@ files:
123
123
  - lib/pennmarc/mappings/locations.yml
124
124
  - lib/pennmarc/mappings/relator.yml
125
125
  - lib/pennmarc/parser.rb
126
+ - lib/pennmarc/test/marc_helpers.rb
126
127
  - lib/pennmarc/util.rb
127
128
  - lib/pennmarc/version.rb
128
129
  - pennmarc.gemspec
@@ -150,7 +151,7 @@ files:
150
151
  - spec/lib/pennmarc/marc_util_spec.rb
151
152
  - spec/lib/pennmarc/parser_spec.rb
152
153
  - spec/spec_helper.rb
153
- - spec/support/marc_spec_helpers.rb
154
+ - spec/support/fixture_helpers.rb
154
155
  homepage: https://gitlab.library.upenn.edu/dld/catalog/pennmarc
155
156
  licenses:
156
157
  - MIT
@@ -1,85 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'nokogiri'
4
- require 'marc'
5
-
6
- module MarcSpecHelpers
7
- # Return a MARC::XMLReader that will parse a given file and return MARC::Record objects
8
- # @param [String] filename of MARCXML fixture
9
- # @return [MARC::Record, NilClass]
10
- def record_from(filename)
11
- MARC::XMLReader.new(marc_xml_path(filename)).first
12
- end
13
-
14
- # Get the path for a test MARC XML file
15
- # @param [String] filename of MARCXML fixture
16
- # @return [String] full path of MARCXML fixture
17
- def marc_xml_path(filename)
18
- File.join File.dirname(__FILE__), '..', 'fixtures', 'marcxml', filename
19
- end
20
-
21
- # Create an isolated MARC::Subfield object for use in specs or as part of a MARC::Field
22
- # @param [String] code
23
- # @param [String] value
24
- # @return [MARC::Subfield]
25
- def marc_subfield(code, value)
26
- MARC::Subfield.new code.to_s, value
27
- end
28
-
29
- # Return a new ControlField (000-009)
30
- # @param [String] tag
31
- # @param [String] value
32
- # @return [MARC::ControlField]
33
- def marc_control_field(tag:, value:)
34
- MARC::ControlField.new tag, value
35
- end
36
-
37
- # Create an isolated MARC::DataField object for use in specs
38
- # Can pass in tag, indicators and subfields (using simple hash structure). E.g.,
39
- # marc_field(tag: '650', indicator2: '7'),
40
- # subfields: { a: 'Tax planning',
41
- # m: ['Multiple', 'Subfields']
42
- # z: 'United States.',
43
- # '0': http://id.loc.gov/authorities/subjects/sh2008112546 }
44
- # )
45
- # @param [String (frozen)] tag MARC tag, e.g., 001, 665
46
- # @param [String (frozen)] indicator1 MARC indicator, e.g., 0
47
- # @param [String (frozen)] indicator2
48
- # @param [Hash] subfields hash of subfield values as code => value or code => [value, value]
49
- # @return [MARC::DataField]
50
- def marc_field(tag: 'TST', indicator1: ' ', indicator2: ' ', subfields: {})
51
- subfield_objects = subfields.each_with_object([]) do |(code, value), array|
52
- Array.wrap(value).map { |v| array << marc_subfield(code, v) }
53
- end
54
- MARC::DataField.new tag, indicator1, indicator2, *subfield_objects
55
- end
56
-
57
- # Return a MARC::Record containing passed in DataFields
58
- # @param [Array<MARC::DataField>] fields
59
- # @param [String, nil] leader
60
- # @return [MARC::Record]
61
- def marc_record(fields: [], leader: nil)
62
- record = MARC::Record.new
63
- fields.each { |field| record << field }
64
- record.leader = leader if leader
65
- record
66
- end
67
-
68
- # Mock map for location lookup using Location helper
69
- # The location codes :dent and :stor are the two outermost keys
70
- # :specific_location, :library, :display are the inner keys that store location values
71
- # @example
72
- # location_map[:stor][:library] #=> 'LIBRA'
73
- # @return [Hash]
74
- def location_map
75
- { dent: { specific_location: 'Levy Dental Medicine Library - Stacks',
76
- library: ['Health Sciences Libraries', 'Levy Dental Medicine Library'],
77
- display: 'Levy Dental Medicine Library - Stacks' },
78
- stor: { specific_location: 'LIBRA',
79
- library: 'LIBRA',
80
- display: 'LIBRA' },
81
- vanp: { specific_location: 'Van Pelt - Stacks',
82
- library: 'Van Pelt-Dietrich Library Center',
83
- display: 'Van Pelt Library' } }
84
- end
85
- end