pennmarc 1.0.2 → 1.0.4
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 +4 -4
- data/.gitleaks.toml +2 -0
- data/README.md +2 -2
- data/lib/pennmarc/helpers/date.rb +4 -8
- data/lib/pennmarc/helpers/format.rb +2 -2
- data/lib/pennmarc/helpers/identifier.rb +44 -11
- data/lib/pennmarc/helpers/language.rb +23 -8
- data/lib/pennmarc/mappers.rb +6 -2
- data/lib/pennmarc/mappings/iso639-3-languages.yml +7916 -0
- data/lib/pennmarc/version.rb +1 -1
- data/spec/lib/pennmarc/helpers/date_spec.rb +16 -0
- data/spec/lib/pennmarc/helpers/identifer_spec.rb +21 -5
- data/spec/lib/pennmarc/helpers/language_spec.rb +56 -8
- data/spec/lib/pennmarc/parser_spec.rb +3 -3
- metadata +8 -6
- /data/lib/pennmarc/mappings/{language.yml → iso639-2-languages.yml} +0 -0
data/lib/pennmarc/version.rb
CHANGED
@@ -27,6 +27,22 @@ describe 'PennMARC::Date' do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe '.added' do
|
30
|
+
context 'with a robust itm tag' do
|
31
|
+
let(:fields) do
|
32
|
+
[marc_field(tag: 'itm', subfields: { g: 'VanPeltLib', i: 'Tw .156', q: '2023-10-19' })]
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns only the expected date_added value' do
|
36
|
+
expect(helper.added(record)).to eq DateTime.strptime('2023-10-19', '%Y-%m-%d')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'does not output any warning to STDOUT' do
|
40
|
+
expect {
|
41
|
+
helper.added(record)
|
42
|
+
}.to_not output(a_string_including('Error parsing date in date added subfield')).to_stdout
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
30
46
|
context "with date formatted '%Y-%m-%d'" do
|
31
47
|
let(:fields) { [marc_field(tag: 'itm', subfields: { q: '2023-06-28' })] }
|
32
48
|
|
@@ -17,13 +17,15 @@ describe 'PennMARC::Identifier' do
|
|
17
17
|
let(:record) do
|
18
18
|
marc_record fields: [
|
19
19
|
marc_field(tag: '020', subfields: { a: '9781594205071', z: '1555975275' }),
|
20
|
-
marc_field(tag: '022',
|
20
|
+
marc_field(tag: '022',
|
21
|
+
subfields: { a: '0008-6533', l: '0300-7162', m: 'cancelled', y: 'incorrect', z: '0799-5946' })
|
21
22
|
]
|
22
23
|
end
|
23
24
|
|
24
25
|
it 'returns expected search values' do
|
25
26
|
expect(helper.isxn_search(record)).to contain_exactly('9781594205071', '1555975275', '9781555975272',
|
26
|
-
'1594205078', '0300-7162', '0008-6533', '0799-5946
|
27
|
+
'1594205078', '0300-7162', '0008-6533', '0799-5946',
|
28
|
+
'cancelled', 'incorrect')
|
27
29
|
end
|
28
30
|
|
29
31
|
it 'converts ISBN10 values to ISBN13' do
|
@@ -62,7 +64,7 @@ describe 'PennMARC::Identifier' do
|
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
|
-
describe '.
|
67
|
+
describe '.oclc_id_show' do
|
66
68
|
let(:record) do
|
67
69
|
marc_record fields: [
|
68
70
|
marc_field(tag: '035', subfields: { a: '(PU)4422776-penndb-Voyager' }),
|
@@ -72,7 +74,21 @@ describe 'PennMARC::Identifier' do
|
|
72
74
|
end
|
73
75
|
|
74
76
|
it 'returns expected show values' do
|
75
|
-
expect(helper.
|
77
|
+
expect(helper.oclc_id_show(record)).to eq '610094484'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '.oclc_id_search' do
|
82
|
+
let(:record) do
|
83
|
+
marc_record fields: [
|
84
|
+
marc_field(tag: '035', subfields: { a: '(PU)4422776-penndb-Voyager' }),
|
85
|
+
marc_field(tag: '035', subfields: { z: '(OCoLC)ocn610094484' }),
|
86
|
+
marc_field(tag: '035', subfields: { a: '(OCoLC)ocn1483169584' })
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'returns expected search values' do
|
91
|
+
expect(helper.oclc_id_search(record)).to contain_exactly('610094484', '1483169584')
|
76
92
|
end
|
77
93
|
end
|
78
94
|
|
@@ -146,4 +162,4 @@ describe 'PennMARC::Identifier' do
|
|
146
162
|
'10.1038/sdata.2016.18', '10.18574/9781479842865')
|
147
163
|
end
|
148
164
|
end
|
149
|
-
end
|
165
|
+
end
|
@@ -4,27 +4,75 @@ describe 'PennMARC::Language' do
|
|
4
4
|
include MarcSpecHelpers
|
5
5
|
|
6
6
|
let(:helper) { PennMARC::Language }
|
7
|
-
let(:
|
8
|
-
{ eng: 'English', und: 'Undetermined' }
|
7
|
+
let(:iso_639_2_mapping) do
|
8
|
+
{ eng: 'English', und: 'Undetermined', fre: 'French', ger: 'German', ulw: 'Ulwa' }
|
9
|
+
end
|
10
|
+
let(:iso_639_3_mapping) do
|
11
|
+
{ eng: 'American', und: 'Undetermined', fre: 'Francais', ger: 'Deutsch', twf: 'Northern Tiwa' }
|
9
12
|
end
|
10
13
|
let(:record) do
|
11
14
|
marc_record fields: [
|
12
15
|
marc_control_field(tag: '008', value: ' eng'),
|
16
|
+
marc_field(tag: '041', subfields: { '2': 'iso639-2', a: 'eng', b: 'fre', d: 'ger' }),
|
13
17
|
marc_field(tag: '546', subfields: { a: 'Great', c: 'Content', '6': 'Not Included' }),
|
14
18
|
marc_field(tag: '546', subfields: { b: 'More!', '8': 'Not Included' }),
|
15
19
|
marc_field(tag: '880', subfields: { c: 'Mas!', '6': '546', '8': 'Not Included' })
|
16
20
|
]
|
17
21
|
end
|
18
22
|
|
19
|
-
describe '.search' do
|
20
|
-
it 'returns the expected display value' do
|
21
|
-
expect(helper.search(record, language_map: mapping)).to eq 'English'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
23
|
describe '.show' do
|
26
24
|
it 'returns the expected show values' do
|
27
25
|
expect(helper.show(record)).to contain_exactly 'Great Content', 'More!', 'Mas!'
|
28
26
|
end
|
29
27
|
end
|
28
|
+
|
29
|
+
describe '.search' do
|
30
|
+
context 'when using iso 639-2 spec' do
|
31
|
+
it 'returns the expected display values from iso639-2' do
|
32
|
+
expect(helper.values(record,
|
33
|
+
iso_639_2_mapping: iso_639_2_mapping,
|
34
|
+
iso_639_3_mapping: iso_639_3_mapping)).to contain_exactly('English', 'French', 'German')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when using iso639-3 spec' do
|
39
|
+
let(:record) do
|
40
|
+
marc_record fields: [marc_field(tag: '041', subfields: { '2': 'iso639-3', a: 'eng', b: 'fre', d: 'ger' }),
|
41
|
+
marc_field(tag: '041', subfields: { '2': 'iso639-3', a: 'twf' })]
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'returns the expected display values from iso639-3' do
|
45
|
+
expect(helper.values(record,
|
46
|
+
iso_639_2_mapping: iso_639_2_mapping,
|
47
|
+
iso_639_3_mapping: iso_639_3_mapping)).to contain_exactly('American', 'Francais',
|
48
|
+
'Deutsch', 'Northern Tiwa')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when using multiple specs' do
|
53
|
+
let(:record) do
|
54
|
+
marc_record fields: [marc_field(tag: '041', subfields: { '2': 'iso639-3', a: 'eng', b: 'fre', d: 'ger' }),
|
55
|
+
marc_field(tag: '041', subfields: { '2': 'iso639-2', a: 'ulw' })]
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'returns the expected display values from iso639-3' do
|
59
|
+
expect(helper.values(record,
|
60
|
+
iso_639_2_mapping: iso_639_2_mapping,
|
61
|
+
iso_639_3_mapping: iso_639_3_mapping)).to contain_exactly('American', 'Francais',
|
62
|
+
'Deutsch', 'Ulwa')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'with an empty record' do
|
67
|
+
let(:record) do
|
68
|
+
marc_record fields: [marc_field(tag: '041', subfields: { c: 'test' })]
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns undetermined when there are no values' do
|
72
|
+
expect(helper.values(record,
|
73
|
+
iso_639_2_mapping: iso_639_2_mapping,
|
74
|
+
iso_639_3_mapping: iso_639_3_mapping)).to contain_exactly('Undetermined')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
30
78
|
end
|
@@ -8,12 +8,12 @@ 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.
|
11
|
+
expect(parser.language_values(record)).to contain_exactly 'English'
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'delegates to helper modules properly with extra params' do
|
15
15
|
bogus_map = { eng: 'American' }
|
16
|
-
expect(parser.
|
16
|
+
expect(parser.language_values(record, iso_639_2_mapping: bogus_map)).to contain_exactly 'American'
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'raises an exception if the method call is invalid' do
|
@@ -23,7 +23,7 @@ describe PennMARC::Parser do
|
|
23
23
|
|
24
24
|
describe '#respond_to?' do
|
25
25
|
it 'returns true if a helper has the expected method' do
|
26
|
-
expect(parser).to respond_to :
|
26
|
+
expect(parser).to respond_to :language_values
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'returns false if a helper does not have the expected method' do
|
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.
|
4
|
+
version: 1.0.4
|
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-10-
|
13
|
+
date: 2023-10-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -77,6 +77,7 @@ extensions: []
|
|
77
77
|
extra_rdoc_files: []
|
78
78
|
files:
|
79
79
|
- ".gitignore"
|
80
|
+
- ".gitleaks.toml"
|
80
81
|
- ".rspec"
|
81
82
|
- ".rubocop.yml"
|
82
83
|
- ".rubocop_todo.yml"
|
@@ -107,7 +108,8 @@ files:
|
|
107
108
|
- lib/pennmarc/helpers/subject.rb
|
108
109
|
- lib/pennmarc/helpers/title.rb
|
109
110
|
- lib/pennmarc/mappers.rb
|
110
|
-
- lib/pennmarc/mappings/
|
111
|
+
- lib/pennmarc/mappings/iso639-2-languages.yml
|
112
|
+
- lib/pennmarc/mappings/iso639-3-languages.yml
|
111
113
|
- lib/pennmarc/mappings/locations.yml
|
112
114
|
- lib/pennmarc/mappings/relator.yml
|
113
115
|
- lib/pennmarc/parser.rb
|
@@ -140,7 +142,7 @@ licenses:
|
|
140
142
|
- MIT
|
141
143
|
metadata:
|
142
144
|
rubygems_mfa_required: 'true'
|
143
|
-
post_install_message:
|
145
|
+
post_install_message:
|
144
146
|
rdoc_options: []
|
145
147
|
require_paths:
|
146
148
|
- lib
|
@@ -156,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
158
|
version: '0'
|
157
159
|
requirements: []
|
158
160
|
rubygems_version: 3.4.10
|
159
|
-
signing_key:
|
161
|
+
signing_key:
|
160
162
|
specification_version: 4
|
161
163
|
summary: Penn Libraries Catalog MARC parsing wisdom for cross-project usage
|
162
164
|
test_files: []
|
File without changes
|