pennmarc 0.0.2 → 1.0.0

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.rubocop_todo.yml +151 -0
  4. data/Gemfile +1 -1
  5. data/lib/pennmarc/helpers/creator.rb +47 -13
  6. data/lib/pennmarc/helpers/database.rb +8 -8
  7. data/lib/pennmarc/helpers/date.rb +16 -15
  8. data/lib/pennmarc/helpers/edition.rb +14 -11
  9. data/lib/pennmarc/helpers/format.rb +16 -5
  10. data/lib/pennmarc/helpers/genre.rb +12 -11
  11. data/lib/pennmarc/helpers/identifier.rb +16 -7
  12. data/lib/pennmarc/helpers/language.rb +1 -1
  13. data/lib/pennmarc/helpers/link.rb +6 -0
  14. data/lib/pennmarc/helpers/location.rb +14 -14
  15. data/lib/pennmarc/helpers/note.rb +52 -2
  16. data/lib/pennmarc/helpers/relation.rb +9 -9
  17. data/lib/pennmarc/helpers/series.rb +182 -85
  18. data/lib/pennmarc/helpers/subject.rb +11 -11
  19. data/lib/pennmarc/helpers/title.rb +1 -1
  20. data/lib/pennmarc/parser.rb +2 -99
  21. data/lib/pennmarc/util.rb +11 -11
  22. data/pennmarc.gemspec +2 -2
  23. data/spec/lib/pennmarc/helpers/citation_spec.rb +1 -2
  24. data/spec/lib/pennmarc/helpers/creator_spec.rb +46 -11
  25. data/spec/lib/pennmarc/helpers/date_spec.rb +5 -5
  26. data/spec/lib/pennmarc/helpers/edition_spec.rb +1 -4
  27. data/spec/lib/pennmarc/helpers/format_spec.rb +29 -9
  28. data/spec/lib/pennmarc/helpers/genre_spec.rb +3 -3
  29. data/spec/lib/pennmarc/helpers/identifer_spec.rb +15 -0
  30. data/spec/lib/pennmarc/helpers/location_spec.rb +9 -8
  31. data/spec/lib/pennmarc/helpers/note_spec.rb +67 -2
  32. data/spec/lib/pennmarc/helpers/series_spec.rb +54 -0
  33. data/spec/lib/pennmarc/helpers/subject_spec.rb +8 -8
  34. data/spec/lib/pennmarc/helpers/title_spec.rb +3 -1
  35. data/spec/lib/pennmarc/marc_util_spec.rb +9 -8
  36. data/spec/lib/pennmarc/parser_spec.rb +2 -2
  37. data/spec/spec_helper.rb +1 -1
  38. metadata +7 -17
@@ -11,9 +11,9 @@ describe 'PennMARC::Location' do
11
11
  let(:record) { marc_record(fields: [marc_field(tag: 'itm', subfields: { g: 'stor' })]) }
12
12
 
13
13
  it 'returns expected value' do
14
- expect(helper.location(record: record, location_map: mapping,
14
+ expect(helper.location(record: record, location_mapping: mapping,
15
15
  display_value: :library)).to contain_exactly('LIBRA')
16
- expect(helper.location(record:, location_map: mapping,
16
+ expect(helper.location(record: record, location_mapping: mapping,
17
17
  display_value: 'specific_location')).to contain_exactly('LIBRA')
18
18
  end
19
19
  end
@@ -22,9 +22,9 @@ describe 'PennMARC::Location' do
22
22
  let(:record) { marc_record(fields: [marc_field(tag: 'hld', subfields: { c: 'stor' })]) }
23
23
 
24
24
  it 'returns expected value' do
25
- expect(helper.location(record: record, location_map: mapping,
25
+ expect(helper.location(record: record, location_mapping: mapping,
26
26
  display_value: :library)).to contain_exactly('LIBRA')
27
- expect(helper.location(record: record, location_map: mapping,
27
+ expect(helper.location(record: record, location_mapping: mapping,
28
28
  display_value: 'specific_location')).to contain_exactly('LIBRA')
29
29
  end
30
30
  end
@@ -34,8 +34,9 @@ describe 'PennMARC::Location' do
34
34
  marc_record(fields: [marc_field(tag: 'itm', subfields: { g: 'stor' }),
35
35
  marc_field(tag: 'hld', subfields: { c: 'dent' })])
36
36
  end
37
+
37
38
  it 'returns item location' do
38
- expect(helper.location(record: record, location_map: mapping,
39
+ expect(helper.location(record: record, location_mapping: mapping,
39
40
  display_value: :library)).to contain_exactly('LIBRA')
40
41
  end
41
42
  end
@@ -44,7 +45,7 @@ describe 'PennMARC::Location' do
44
45
  let(:record) { marc_record(fields: [marc_field(tag: 'itm', subfields: { g: %w[dent] })]) }
45
46
 
46
47
  it 'returns expected value' do
47
- expect(helper.location(record: record, location_map: mapping,
48
+ expect(helper.location(record: record, location_mapping: mapping,
48
49
  display_value: :library)).to contain_exactly('Health Sciences Libraries',
49
50
  'Levy Dental Medicine Library')
50
51
  end
@@ -54,7 +55,7 @@ describe 'PennMARC::Location' do
54
55
  let(:record) { marc_record(fields: [marc_field(tag: '852', subfields: { g: 'stor' })]) }
55
56
 
56
57
  it 'returns expected value' do
57
- expect(helper.location(record: record, location_map: mapping, display_value: :library)).to be_empty
58
+ expect(helper.location(record: record, location_mapping: mapping, display_value: :library)).to be_empty
58
59
  end
59
60
  end
60
61
 
@@ -62,7 +63,7 @@ describe 'PennMARC::Location' do
62
63
  let(:record) { marc_record(fields: [marc_field(tag: 'itm', subfields: { g: 'stor' }), marc_field(tag: 'prt')]) }
63
64
 
64
65
  it 'returns expected value' do
65
- expect(helper.location(record: record, location_map: mapping,
66
+ expect(helper.location(record: record, location_mapping: mapping,
66
67
  display_value: :library)).to contain_exactly('LIBRA', 'Online library')
67
68
  end
68
69
  end
@@ -199,7 +199,7 @@ describe 'PennMARC::Note' do
199
199
 
200
200
  let(:fields) do
201
201
  [
202
- marc_field(tag: '545', subfields: { a: 'A Creator', b: 'Additional Info', 'u': 'URI' }),
202
+ marc_field(tag: '545', subfields: { a: 'A Creator', b: 'Additional Info', u: 'URI' }),
203
203
  marc_field(tag: '880', subfields: { a: 'Alt Bio', b: 'Alt Info', u: 'Alt URI', '6': '545' })
204
204
  ]
205
205
  end
@@ -217,7 +217,7 @@ describe 'PennMARC::Note' do
217
217
 
218
218
  let(:fields) do
219
219
  [
220
- marc_field(tag: '520', subfields: { a: 'An Abstract', b: 'Additional Summary', 'c': 'ProQuest' }),
220
+ marc_field(tag: '520', subfields: { a: 'An Abstract', b: 'Additional Summary', c: 'ProQuest' }),
221
221
  marc_field(tag: '880', subfields: { a: 'Alt Abstract', b: 'Alt Additional Summary', c: 'Alt ProQuest',
222
222
  '6': '520' })
223
223
  ]
@@ -229,5 +229,70 @@ describe 'PennMARC::Note' do
229
229
  expect(values).to contain_exactly('An Abstract Additional Summary ProQuest',
230
230
  'Alt Abstract Alt Additional Summary Alt ProQuest')
231
231
  end
232
+
233
+ describe '.arrangement_show' do
234
+ let(:record) { marc_record(fields: fields) }
235
+
236
+ let(:fields) do
237
+ [
238
+ marc_field(tag: '351', subfields: { a: 'Organized into five subseries', b: 'Arrangement pattern', c: 'Series',
239
+ '3': 'materials' }),
240
+ marc_field(tag: '880', subfields: { a: 'Alt organization', b: 'Alt arrangement', c: 'Alt hierarchical level',
241
+ '3': 'Alt materials', '6': '351' })
242
+ ]
243
+ end
244
+
245
+ let(:values) { helper.arrangement_show(record) }
246
+
247
+ it 'returns expected values from 351 and its linked alternate' do
248
+ expect(values).to contain_exactly('Organized into five subseries Arrangement pattern Series materials',
249
+ 'Alt organization Alt arrangement Alt hierarchical level Alt materials')
250
+ end
251
+ end
252
+
253
+ describe '.system_details_show' do
254
+ let(:record) { marc_record(fields: fields) }
255
+
256
+ let(:fields) do
257
+ [
258
+ marc_field(tag: '538', subfields: { a: 'Blu-ray, region A, 1080p High Definition, full screen (1.33:1)',
259
+ i: 'display text for URI', u: 'http://www.universal.resource/locator ',
260
+ '3': ['Blu-ray disc.', '2015'] }),
261
+ marc_field(tag: '344', subfields: { a: 'digital', b: 'optical', c: '1.4 m/s', g: 'stereo',
262
+ h: 'digital recording', '3': 'audio disc' }),
263
+ marc_field(tag: '345', subfields: { a: '1 film reel (25 min.)', b: '24 fps', '3': 'Polyester print' }),
264
+ marc_field(tag: '346', subfields: { a: 'VHS', b: 'NTSC', '3': 'original videocassette' }),
265
+ marc_field(tag: '347', subfields: { a: 'video file', b: 'DVD video', e: 'region', '3': 'DVD' }),
266
+ marc_field(tag: '880', subfields: { a: 'Alt system details', i: 'Alternative display text', u: 'Alt URI',
267
+ '3': 'Alt materials.', '6': '538' }),
268
+ marc_field(tag: '880', subfields: { a: 'Alt recording', b: 'Alt medium', c: 'Alt playing speed',
269
+ g: 'Alt channel',
270
+ h: 'Alt characteristic', '3': 'Alt materials.',
271
+ '6': '344' }),
272
+ marc_field(tag: '880', subfields: { a: 'Alt presentation format', b: 'Alt projection speed',
273
+ '3': 'Alt materials.', '6': '345' }),
274
+ marc_field(tag: '880', subfields: { a: 'Alt video format', b: 'Alt broadcast', '3': 'Alt materials.',
275
+ '6': '346' }),
276
+ marc_field(tag: '880', subfields: { a: 'Alt file type', b: 'Alt encoding', '3': 'Alt materials.',
277
+ '6': 'Alt region' })
278
+
279
+ ]
280
+ end
281
+
282
+ let(:values) { helper.system_details_show(record) }
283
+
284
+ it 'returns expected from 5xx and 3xx fields and their linked alternates' do
285
+ expect(values).to contain_exactly(
286
+ 'Blu-ray disc: 2015 Blu-ray, region A, 1080p High Definition, full screen (1.33:1) display
287
+ text for URI http://www.universal.resource/locator'.squish,
288
+ 'audio disc digital optical 1.4 m/s stereo digital recording', 'Polyester print 1 film reel (25 min.) 24 fps',
289
+ 'original videocassette VHS NTSC', 'DVD video file DVD video region',
290
+ 'Alt materials Alt system details Alternative display text Alt URI',
291
+ 'Alt materials Alt recording Alt medium Alt playing speed Alt channel Alt characteristic',
292
+ 'Alt materials Alt presentation format Alt projection speed',
293
+ 'Alt materials Alt video format Alt broadcast'
294
+ )
295
+ end
296
+ end
232
297
  end
233
298
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe 'PennMARC::Series' do
4
+ include MarcSpecHelpers
5
+
6
+ let(:helper) { PennMARC::Series }
7
+ let(:mapping) { { aut: 'Author' } }
8
+ let(:record) do
9
+ marc_record fields: [marc_field(tag: '490', subfields: { a: 'Teachings of the feathered pillow' }),
10
+ marc_field(tag: '880', subfields: { '6': '490', a: 'Учения пернатой подушки' }),
11
+ marc_field(tag: '800', subfields: { a: 'Bean Bagatolvski', d: '1997-', v: 'bk. 1' }),
12
+ marc_field(tag: '780', subfields: { a: 'National Comfort Association' }),
13
+ marc_field(tag: '785', subfields: { a: 'NCA quarterly comfortology bulletin' })]
14
+ end
15
+ let(:empty_record) do
16
+ marc_record fields: [marc_field(tag: '666', subfields: { a: 'test' })]
17
+ end
18
+
19
+ describe '.show' do
20
+ it 'returns the series' do
21
+ expect(helper.show(record, mapping)).to contain_exactly('Bean Bagatolvski 1997- bk. 1',
22
+ 'Teachings of the feathered pillow',
23
+ 'Учения пернатой подушки')
24
+ end
25
+ end
26
+
27
+ describe '.values' do
28
+ it 'returns the values' do
29
+ expect(helper.values(record, mapping)).to contain_exactly('Bean Bagatolvski 1997- bk. 1.')
30
+ end
31
+ end
32
+
33
+ describe '.search' do
34
+ it 'returns the search values' do
35
+ expect(helper.search(record)).to contain_exactly('Bean Bagatolvski 1997- bk. 1')
36
+ end
37
+
38
+ it 'returns an empty array if no values are found' do
39
+ expect(helper.search(empty_record)).to be_empty
40
+ end
41
+ end
42
+
43
+ describe '.get_continues_display' do
44
+ it 'gets continues for display' do
45
+ expect(helper.get_continues_display(record)).to contain_exactly('National Comfort Association')
46
+ end
47
+ end
48
+
49
+ describe '.get_continued_by_display' do
50
+ it 'gets continued by display' do
51
+ expect(helper.get_continued_by_display(record)).to contain_exactly('NCA quarterly comfortology bulletin')
52
+ end
53
+ end
54
+ end
@@ -61,11 +61,11 @@ describe 'PennMARC::Subject' do
61
61
  end
62
62
 
63
63
  describe '.facet' do
64
- let(:record) { marc_record fields: }
64
+ let(:record) { marc_record fields: fields }
65
65
  let(:values) { helper.facet(record) }
66
66
 
67
67
  # TODO: find some more inspiring examples in the corpus
68
- context 'for a record with poorly-coded heading values' do
68
+ context 'with a record with poorly-coded heading values' do
69
69
  let(:fields) { [marc_field(tag: '650', indicator2: '0', subfields: { a: 'Subject - Heading' })] }
70
70
 
71
71
  it 'properly normalizes the heading value' do
@@ -73,7 +73,7 @@ describe 'PennMARC::Subject' do
73
73
  end
74
74
  end
75
75
 
76
- context 'for a record with 650 headings with a ǂa that starts with PRO or CHR' do
76
+ context 'with a record with 650 headings with a ǂa that starts with PRO or CHR' do
77
77
  let(:fields) do
78
78
  [marc_field(tag: '650', indicator2: '4', subfields: { a: '%CHR 1998', '5': 'PU' }),
79
79
  marc_field(tag: '650', indicator2: '4', subfields: { a: 'PRO Potok, Adena (donor) (Potok Collection copy)',
@@ -85,7 +85,7 @@ describe 'PennMARC::Subject' do
85
85
  end
86
86
  end
87
87
 
88
- context 'for a record with an indicator2 value of 3, 5 or 6' do
88
+ context 'with a record with an indicator2 value of 3, 5 or 6' do
89
89
  let(:fields) do
90
90
  [marc_field(tag: '650', indicator2: '3', subfields: { a: 'Nope' }),
91
91
  marc_field(tag: '650', indicator2: '5', subfields: { a: 'Nope' }),
@@ -97,7 +97,7 @@ describe 'PennMARC::Subject' do
97
97
  end
98
98
  end
99
99
 
100
- context 'for a record with a valid tag, indicator2 and source specified' do
100
+ context 'with a record with a valid tag, indicator2 and source specified' do
101
101
  let(:fields) do
102
102
  [marc_field(tag: '650', indicator2: '7',
103
103
  subfields: {
@@ -129,7 +129,7 @@ describe 'PennMARC::Subject' do
129
129
  end
130
130
 
131
131
  describe '.show' do
132
- let(:record) { marc_record fields: }
132
+ let(:record) { marc_record fields: fields }
133
133
  let(:values) { helper.facet(record) }
134
134
 
135
135
  context 'with a variety of headings' do
@@ -145,8 +145,8 @@ describe 'PennMARC::Subject' do
145
145
  end
146
146
 
147
147
  it 'shows all valid subject headings without duplicates' do
148
- expect(helper.show(record)).to match_array ['Nephrology--Periodicals', 'Nephrology',
149
- 'Kidney Diseases', 'Local Heading']
148
+ expect(helper.show(record)).to contain_exactly('Nephrology--Periodicals', 'Nephrology', 'Kidney Diseases',
149
+ 'Local Heading')
150
150
  end
151
151
  end
152
152
 
@@ -20,7 +20,9 @@ describe 'PennMARC::Title' do
20
20
  end
21
21
  end
22
22
 
23
- xdescribe '.search_aux'
23
+ describe '.search_aux' do
24
+ it 'returns search aux values', pending: 'Not implemented yet'
25
+ end
24
26
 
25
27
  describe '.show' do
26
28
  let(:record) { marc_record fields: [marc_field(tag: '245', subfields: subfields)] }
@@ -20,11 +20,11 @@ describe 'PennMARC::Util' do
20
20
  let(:field) { marc_field subfields: { a: '123' } }
21
21
 
22
22
  it 'returns true if the specified subfield value matches the regex' do
23
- expect(util.subfield_value?(field, 'a', /123/)).to be_truthy
23
+ expect(util).to be_subfield_value(field, 'a', /123/)
24
24
  end
25
25
 
26
26
  it 'returns false if the subfield value does not match the regex' do
27
- expect(util.subfield_value?(field, 'a', /\D/)).to be_falsey
27
+ expect(util).not_to be_subfield_value(field, 'a', /\D/)
28
28
  end
29
29
  end
30
30
 
@@ -66,12 +66,12 @@ describe 'PennMARC::Util' do
66
66
  let(:field) { marc_field subfields: { a: 'Defined' } }
67
67
 
68
68
  it 'returns true if subfield is present on a field' do
69
- expect(util.subfield_defined?(field, :a)).to be_truthy
70
- expect(util.subfield_defined?(field, 'a')).to be_truthy
69
+ expect(util).to be_subfield_defined(field, :a)
70
+ expect(util).to be_subfield_defined(field, 'a')
71
71
  end
72
72
 
73
73
  it 'returns false if a subfield is not present on a field' do
74
- expect(util.subfield_defined?(field, :b)).to be_falsey
74
+ expect(util).not_to be_subfield_defined(field, :b)
75
75
  end
76
76
  end
77
77
 
@@ -79,12 +79,12 @@ describe 'PennMARC::Util' do
79
79
  let(:field) { marc_field subfields: { a: 'Defined' } }
80
80
 
81
81
  it 'returns true if subfield is not present on a field' do
82
- expect(util.subfield_undefined?(field, :b)).to be_truthy
83
- expect(util.subfield_undefined?(field, 'b')).to be_truthy
82
+ expect(util).to be_subfield_undefined(field, :b)
83
+ expect(util).to be_subfield_undefined(field, 'b')
84
84
  end
85
85
 
86
86
  it 'returns false if a subfield is present on a field' do
87
- expect(util.subfield_undefined?(field, :a)).to be_falsey
87
+ expect(util).not_to be_subfield_undefined(field, :a)
88
88
  end
89
89
  end
90
90
 
@@ -173,6 +173,7 @@ describe 'PennMARC::Util' do
173
173
 
174
174
  describe '.remove_paren_value_from_subfield_i' do
175
175
  let(:field) { marc_field(tag: '666', subfields: { i: 'Test(Remove).' }) }
176
+
176
177
  it 'removes the parentheses value from subfield i' do
177
178
  expect(util.remove_paren_value_from_subfield_i(field)).to eq('Test')
178
179
  end
@@ -3,10 +3,10 @@
3
3
  describe PennMARC::Parser do
4
4
  include MarcSpecHelpers
5
5
 
6
- let(:record) { record_from 'test.xml' }
7
-
8
6
  subject(:parser) { described_class.new }
9
7
 
8
+ let(:record) { record_from 'test.xml' }
9
+
10
10
  it 'delegates to helper modules properly' do
11
11
  expect { parser.title_show(record) }.not_to raise_exception
12
12
  end
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  $LOAD_PATH.unshift(__dir__) unless $LOAD_PATH.include?(__dir__)
4
4
 
5
- Dir[File.join(__dir__, 'support', '**', '*.rb')].sort.each { |f| require f }
5
+ Dir[File.join(__dir__, 'support', '**', '*.rb')].each { |f| require f }
6
6
 
7
7
  require 'pennmarc'
8
8
 
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: 0.0.2
4
+ version: 1.0.0
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: 2023-07-17 00:00:00.000000000 Z
13
+ date: 2023-07-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -68,20 +68,6 @@ dependencies:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
70
  version: '1.15'
71
- - !ruby/object:Gem::Dependency
72
- name: rspec
73
- requirement: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - "~>"
76
- - !ruby/object:Gem::Version
77
- version: '3.12'
78
- type: :development
79
- prerelease: false
80
- version_requirements: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - "~>"
83
- - !ruby/object:Gem::Version
84
- version: '3.12'
85
71
  description: |-
86
72
  This gem provides methods for parsing a Penn Libraries MARCXML record into string, array and date
87
73
  objects for use in discovery or preservation applications.
@@ -92,6 +78,8 @@ extra_rdoc_files: []
92
78
  files:
93
79
  - ".gitignore"
94
80
  - ".rspec"
81
+ - ".rubocop.yml"
82
+ - ".rubocop_todo.yml"
95
83
  - ".ruby-version"
96
84
  - Gemfile
97
85
  - Gemfile.lock
@@ -141,6 +129,7 @@ files:
141
129
  - spec/lib/pennmarc/helpers/note_spec.rb
142
130
  - spec/lib/pennmarc/helpers/production_spec.rb
143
131
  - spec/lib/pennmarc/helpers/relation_spec.rb
132
+ - spec/lib/pennmarc/helpers/series_spec.rb
144
133
  - spec/lib/pennmarc/helpers/subject_spec.rb
145
134
  - spec/lib/pennmarc/helpers/title_spec.rb
146
135
  - spec/lib/pennmarc/marc_util_spec.rb
@@ -150,7 +139,8 @@ files:
150
139
  homepage: https://gitlab.library.upenn.edu/dld/catalog/pennmarc
151
140
  licenses:
152
141
  - MIT
153
- metadata: {}
142
+ metadata:
143
+ rubygems_mfa_required: 'true'
154
144
  post_install_message:
155
145
  rdoc_options: []
156
146
  require_paths: