pennmarc 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/.rubocop_todo.yml +37 -21
  4. data/Gemfile.lock +3 -0
  5. data/README.md +12 -2
  6. data/lib/pennmarc/helpers/creator.rb +24 -20
  7. data/lib/pennmarc/helpers/edition.rb +15 -13
  8. data/lib/pennmarc/helpers/format.rb +3 -3
  9. data/lib/pennmarc/helpers/genre.rb +5 -4
  10. data/lib/pennmarc/helpers/helper.rb +1 -0
  11. data/lib/pennmarc/helpers/identifier.rb +32 -15
  12. data/lib/pennmarc/helpers/language.rb +3 -3
  13. data/lib/pennmarc/helpers/location.rb +10 -10
  14. data/lib/pennmarc/helpers/note.rb +0 -2
  15. data/lib/pennmarc/helpers/relation.rb +7 -7
  16. data/lib/pennmarc/helpers/series.rb +19 -31
  17. data/lib/pennmarc/helpers/subject.rb +11 -11
  18. data/lib/pennmarc/helpers/title.rb +1 -1
  19. data/lib/pennmarc/mappers.rb +31 -0
  20. data/lib/pennmarc/parser.rb +36 -62
  21. data/lib/pennmarc/util.rb +10 -11
  22. data/lib/pennmarc/version.rb +5 -0
  23. data/pennmarc.gemspec +5 -1
  24. data/spec/lib/pennmarc/helpers/creator_spec.rb +9 -9
  25. data/spec/lib/pennmarc/helpers/edition_spec.rb +3 -2
  26. data/spec/lib/pennmarc/helpers/format_spec.rb +1 -1
  27. data/spec/lib/pennmarc/helpers/genre_spec.rb +1 -1
  28. data/spec/lib/pennmarc/helpers/identifer_spec.rb +43 -14
  29. data/spec/lib/pennmarc/helpers/language_spec.rb +1 -1
  30. data/spec/lib/pennmarc/helpers/location_spec.rb +8 -8
  31. data/spec/lib/pennmarc/helpers/relation_spec.rb +2 -2
  32. data/spec/lib/pennmarc/helpers/series_spec.rb +6 -5
  33. data/spec/lib/pennmarc/helpers/subject_spec.rb +1 -1
  34. data/spec/lib/pennmarc/parser_spec.rb +22 -1
  35. metadata +7 -8
  36. data/legacy/indexer.rb +0 -568
  37. data/legacy/marc.rb +0 -2964
  38. data/legacy/test_file_output.json +0 -49
@@ -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_mapping: mapping,
14
+ expect(helper.location(record: record, location_map: mapping,
15
15
  display_value: :library)).to contain_exactly('LIBRA')
16
- expect(helper.location(record: record, location_mapping: mapping,
16
+ expect(helper.location(record: record, location_map: 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_mapping: mapping,
25
+ expect(helper.location(record: record, location_map: mapping,
26
26
  display_value: :library)).to contain_exactly('LIBRA')
27
- expect(helper.location(record: record, location_mapping: mapping,
27
+ expect(helper.location(record: record, location_map: mapping,
28
28
  display_value: 'specific_location')).to contain_exactly('LIBRA')
29
29
  end
30
30
  end
@@ -36,7 +36,7 @@ describe 'PennMARC::Location' do
36
36
  end
37
37
 
38
38
  it 'returns item location' do
39
- expect(helper.location(record: record, location_mapping: mapping,
39
+ expect(helper.location(record: record, location_map: mapping,
40
40
  display_value: :library)).to contain_exactly('LIBRA')
41
41
  end
42
42
  end
@@ -45,7 +45,7 @@ describe 'PennMARC::Location' do
45
45
  let(:record) { marc_record(fields: [marc_field(tag: 'itm', subfields: { g: %w[dent] })]) }
46
46
 
47
47
  it 'returns expected value' do
48
- expect(helper.location(record: record, location_mapping: mapping,
48
+ expect(helper.location(record: record, location_map: mapping,
49
49
  display_value: :library)).to contain_exactly('Health Sciences Libraries',
50
50
  'Levy Dental Medicine Library')
51
51
  end
@@ -55,7 +55,7 @@ describe 'PennMARC::Location' do
55
55
  let(:record) { marc_record(fields: [marc_field(tag: '852', subfields: { g: 'stor' })]) }
56
56
 
57
57
  it 'returns expected value' do
58
- expect(helper.location(record: record, location_mapping: mapping, display_value: :library)).to be_empty
58
+ expect(helper.location(record: record, location_map: mapping, display_value: :library)).to be_empty
59
59
  end
60
60
  end
61
61
 
@@ -63,7 +63,7 @@ describe 'PennMARC::Location' do
63
63
  let(:record) { marc_record(fields: [marc_field(tag: 'itm', subfields: { g: 'stor' }), marc_field(tag: 'prt')]) }
64
64
 
65
65
  it 'returns expected value' do
66
- expect(helper.location(record: record, location_mapping: mapping,
66
+ expect(helper.location(record: record, location_map: mapping,
67
67
  display_value: :library)).to contain_exactly('LIBRA', 'Online library')
68
68
  end
69
69
  end
@@ -65,7 +65,7 @@ describe 'PennMARC::Relation' do
65
65
  end
66
66
 
67
67
  it 'returns specified subfield values from specified field with blank indicator2' do
68
- values = helper.related_work_show record, relator_map
68
+ values = helper.related_work_show record, relator_map: relator_map
69
69
  expect(values).to contain_exactly 'Translation of: Some Author Aphorisms, Translator',
70
70
  'Alt. Prefix: Alt. Author Alt. Aphorisms'
71
71
  expect(values).not_to include 'Ignored'
@@ -81,7 +81,7 @@ describe 'PennMARC::Relation' do
81
81
  end
82
82
 
83
83
  it "returns specified subfield values from specified field with '2' in indicator2" do
84
- values = helper.contains_show record, relator_map
84
+ values = helper.contains_show record, relator_map: relator_map
85
85
  expect(values).to contain_exactly 'Alt. Prefix: Alt. Name', 'Container of: Some Author Works, Author'
86
86
  expect(values).not_to include 'Ignored'
87
87
  end
@@ -6,7 +6,8 @@ describe 'PennMARC::Series' do
6
6
  let(:helper) { PennMARC::Series }
7
7
  let(:mapping) { { aut: 'Author' } }
8
8
  let(:record) do
9
- marc_record fields: [marc_field(tag: '490', subfields: { a: 'Teachings of the feathered pillow' }),
9
+ marc_record fields: [marc_field(tag: '410', subfields: { a: 'Evil Giant Megacorp' }),
10
+ marc_field(tag: '490', subfields: { a: 'Teachings of the feathered pillow' }),
10
11
  marc_field(tag: '880', subfields: { '6': '490', a: 'Учения пернатой подушки' }),
11
12
  marc_field(tag: '800', subfields: { a: 'Bean Bagatolvski', d: '1997-', v: 'bk. 1' }),
12
13
  marc_field(tag: '780', subfields: { a: 'National Comfort Association' }),
@@ -18,21 +19,21 @@ describe 'PennMARC::Series' do
18
19
 
19
20
  describe '.show' do
20
21
  it 'returns the series' do
21
- expect(helper.show(record, mapping)).to contain_exactly('Bean Bagatolvski 1997- bk. 1',
22
+ expect(helper.show(record, relator_map: mapping)).to contain_exactly('Bean Bagatolvski 1997- bk. 1',
22
23
  'Teachings of the feathered pillow',
23
- 'Учения пернатой подушки')
24
+ 'Учения пернатой подушки', 'Evil Giant Megacorp')
24
25
  end
25
26
  end
26
27
 
27
28
  describe '.values' do
28
29
  it 'returns the values' do
29
- expect(helper.values(record, mapping)).to contain_exactly('Bean Bagatolvski 1997- bk. 1.')
30
+ expect(helper.values(record, relator_map: mapping)).to contain_exactly('Bean Bagatolvski 1997- bk. 1.')
30
31
  end
31
32
  end
32
33
 
33
34
  describe '.search' do
34
35
  it 'returns the search values' do
35
- expect(helper.search(record)).to contain_exactly('Bean Bagatolvski 1997- bk. 1')
36
+ expect(helper.search(record)).to contain_exactly('Bean Bagatolvski 1997- bk. 1', 'Evil Giant Megacorp')
36
37
  end
37
38
 
38
39
  it 'returns an empty array if no values are found' do
@@ -10,7 +10,7 @@ describe 'PennMARC::Subject' do
10
10
 
11
11
  describe '.search' do
12
12
  let(:record) { marc_record fields: fields }
13
- let(:values) { helper.search(record, relator_map) }
13
+ let(:values) { helper.search(record, relator_map: relator_map) }
14
14
 
15
15
  context 'with a mix of included and excluded tags' do
16
16
  let(:fields) do
@@ -8,6 +8,27 @@ describe PennMARC::Parser do
8
8
  let(:record) { record_from 'test.xml' }
9
9
 
10
10
  it 'delegates to helper modules properly' do
11
- expect { parser.title_show(record) }.not_to raise_exception
11
+ expect(parser.language_search(record)).to eq 'English'
12
+ end
13
+
14
+ it 'delegates to helper modules properly with extra params' do
15
+ bogus_map = { eng: 'American' }
16
+ expect(parser.language_search(record, language_map: bogus_map)).to eq 'American'
17
+ end
18
+
19
+ it 'raises an exception if the method call is invalid' do
20
+ expect { parser.title(record) }.to raise_error NoMethodError
21
+ expect { parser.title_nope(record) }.to raise_error NoMethodError
22
+ end
23
+
24
+ describe '#respond_to?' do
25
+ it 'returns true if a helper has the expected method' do
26
+ expect(parser).to respond_to :language_search
27
+ end
28
+
29
+ it 'returns false if a helper does not have the expected method' do
30
+ expect(parser).not_to respond_to :language_nope
31
+ expect(parser).not_to respond_to :nope
32
+ end
12
33
  end
13
34
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pennmarc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Kanning
8
8
  - Amrey Mathurin
9
9
  - Patrick Perkins
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-07-28 00:00:00.000000000 Z
13
+ date: 2023-10-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -84,9 +84,6 @@ files:
84
84
  - Gemfile
85
85
  - Gemfile.lock
86
86
  - README.md
87
- - legacy/indexer.rb
88
- - legacy/marc.rb
89
- - legacy/test_file_output.json
90
87
  - lib/pennmarc.rb
91
88
  - lib/pennmarc/encoding_level.rb
92
89
  - lib/pennmarc/enriched_marc.rb
@@ -109,11 +106,13 @@ files:
109
106
  - lib/pennmarc/helpers/series.rb
110
107
  - lib/pennmarc/helpers/subject.rb
111
108
  - lib/pennmarc/helpers/title.rb
109
+ - lib/pennmarc/mappers.rb
112
110
  - lib/pennmarc/mappings/language.yml
113
111
  - lib/pennmarc/mappings/locations.yml
114
112
  - lib/pennmarc/mappings/relator.yml
115
113
  - lib/pennmarc/parser.rb
116
114
  - lib/pennmarc/util.rb
115
+ - lib/pennmarc/version.rb
117
116
  - pennmarc.gemspec
118
117
  - spec/fixtures/marcxml/test.xml
119
118
  - spec/lib/pennmarc/helpers/citation_spec.rb
@@ -141,7 +140,7 @@ licenses:
141
140
  - MIT
142
141
  metadata:
143
142
  rubygems_mfa_required: 'true'
144
- post_install_message:
143
+ post_install_message:
145
144
  rdoc_options: []
146
145
  require_paths:
147
146
  - lib
@@ -157,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
156
  version: '0'
158
157
  requirements: []
159
158
  rubygems_version: 3.4.10
160
- signing_key:
159
+ signing_key:
161
160
  specification_version: 4
162
161
  summary: Penn Libraries Catalog MARC parsing wisdom for cross-project usage
163
162
  test_files: []