pennmarc 1.0.3 → 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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PennMARC
4
- VERSION = '1.0.3'
4
+ VERSION = '1.0.4'
5
5
  end
@@ -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
 
@@ -4,27 +4,75 @@ describe 'PennMARC::Language' do
4
4
  include MarcSpecHelpers
5
5
 
6
6
  let(:helper) { PennMARC::Language }
7
- let(:mapping) do
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.language_search(record)).to eq 'English'
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.language_search(record, language_map: bogus_map)).to eq 'American'
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 :language_search
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pennmarc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
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-10-12 00:00:00.000000000 Z
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/language.yml
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