stanford-mods 1.1.5 → 1.2.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.
- checksums.yaml +4 -4
- data/.hound.yml +2 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +12 -0
- data/.travis.yml +12 -13
- data/Gemfile +5 -2
- data/Rakefile +11 -7
- data/config/mappings_hash.rb +1 -1
- data/lib/stanford-mods/name.rb +84 -0
- data/lib/stanford-mods/physical_location.rb +83 -0
- data/lib/stanford-mods/searchworks.rb +1 -2
- data/lib/stanford-mods/version.rb +1 -1
- data/lib/stanford-mods.rb +2 -37
- data/spec/name_spec.rb +385 -206
- data/spec/physical_location_spec.rb +254 -0
- data/spec/searchworks_title_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- metadata +9 -2
data/spec/name_spec.rb
CHANGED
@@ -1,242 +1,421 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "name/author concepts" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
let(:smods_rec) { Stanford::Mods::Record.new }
|
5
|
+
let(:mods_start) { "<mods xmlns=\"#{Mods::MODS_NS}\">" }
|
6
|
+
let(:mods_end) { "</mods>" }
|
7
|
+
|
8
8
|
context "main_author_w_date" do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
<namePart>plain_other_role_mr</namePart>
|
39
|
-
<role><roleTerm type='text' authority='marcrelator'>Actor</roleTerm></role>
|
40
|
-
</name>"
|
9
|
+
let(:plain_no_role) { "<name><namePart>plain_no_role</namePart></name>" }
|
10
|
+
let(:plain_creator_code) { "<name>
|
11
|
+
<namePart>plain_creator_code</namePart>
|
12
|
+
<role><roleTerm type='code' authority='marcrelator'>cre</roleTerm></role>
|
13
|
+
</name>" }
|
14
|
+
let(:plain_creator_text) { "<name>
|
15
|
+
<namePart>plain_creator_text</namePart>
|
16
|
+
<role><roleTerm type='text' authority='marcrelator'>Creator</roleTerm></role>
|
17
|
+
</name>" }
|
18
|
+
let(:plain_creator_non_mr) { "<name>
|
19
|
+
<namePart>plain_creator_non_mr</namePart>
|
20
|
+
<role><roleTerm type='text'>Creator</roleTerm></role>
|
21
|
+
</name>" }
|
22
|
+
let(:plain_author_code) { "<name>
|
23
|
+
<namePart>plain_author_code</namePart>
|
24
|
+
<role><roleTerm type='code' authority='marcrelator'>aut</roleTerm></role>
|
25
|
+
</name>" }
|
26
|
+
let(:plain_author_text) { "<name>
|
27
|
+
<namePart>plain_author_text</namePart>
|
28
|
+
<role><roleTerm type='text' authority='marcrelator'>Author</roleTerm></role>
|
29
|
+
</name>" }
|
30
|
+
let(:plain_author_non_mr) { "<name>
|
31
|
+
<namePart>plain_author_non_mr</namePart>
|
32
|
+
<role><roleTerm type='text'>Author</roleTerm></role>
|
33
|
+
</name>" }
|
34
|
+
let(:plain_other_role_mr) { "<name>
|
35
|
+
<namePart>plain_other_role_mr</namePart>
|
36
|
+
<role><roleTerm type='text' authority='marcrelator'>Actor</roleTerm></role>
|
37
|
+
</name>" }
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
<namePart type='personal'>personal_author_text</namePart>
|
49
|
-
<role><roleTerm type='text' authority='marcrelator'>Author</roleTerm></role>
|
50
|
-
</name>"
|
51
|
-
@personal_other_role = "<name>
|
39
|
+
let(:personal_no_role) { "<name><namePart type='personal'>personal_no_role</namePart></name>" }
|
40
|
+
let(:personal_creator_code) { "<name>
|
41
|
+
<namePart type='personal'>personal_creator_code</namePart>
|
42
|
+
<role><roleTerm type='code' authority='marcrelator'>cre</roleTerm></role>
|
43
|
+
</name>" }
|
44
|
+
let(:personal_author_text) { "<name>
|
52
45
|
<namePart type='personal'>personal_author_text</namePart>
|
53
|
-
<role><roleTerm type='text' authority='marcrelator'>
|
54
|
-
</name>"
|
55
|
-
|
56
|
-
|
57
|
-
<
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
46
|
+
<role><roleTerm type='text' authority='marcrelator'>Author</roleTerm></role>
|
47
|
+
</name>" }
|
48
|
+
let(:personal_other_role) { "<name>
|
49
|
+
<namePart type='personal'>personal_author_text</namePart>
|
50
|
+
<role><roleTerm type='text' authority='marcrelator'>Auctioneer</roleTerm></role>
|
51
|
+
</name>" }
|
52
|
+
let(:corp_no_role) { "<name><namePart type='corporate'>corp_no_role</namePart></name>" }
|
53
|
+
let(:corp_author_code) { "<name>
|
54
|
+
<namePart type='corporate'>corp_author_code</namePart>
|
55
|
+
<role><roleTerm type='code' authority='marcrelator'>aut</roleTerm></role>
|
56
|
+
</name>" }
|
57
|
+
let(:corp_creator_text) { "<name>
|
58
|
+
<namePart type='corporate'>corp_creator_text</namePart>
|
59
|
+
<role><roleTerm type='text' authority='marcrelator'>Creator</roleTerm></role>
|
60
|
+
</name>" }
|
61
|
+
let(:other_no_role) { "<name><namePart type='conference'>conference_no_role</namePart></name>" }
|
66
62
|
context "marcrelator role Creator" do
|
67
|
-
it "
|
68
|
-
|
69
|
-
expect(
|
63
|
+
it "finds role with roleTerm type text" do
|
64
|
+
smods_rec.from_str(mods_start + plain_creator_text + mods_end)
|
65
|
+
expect(smods_rec.main_author_w_date).to eq('plain_creator_text')
|
70
66
|
end
|
71
|
-
it "
|
72
|
-
|
73
|
-
expect(
|
67
|
+
it "finds role with roleTerm type code" do
|
68
|
+
smods_rec.from_str(mods_start + plain_creator_code + mods_end)
|
69
|
+
expect(smods_rec.main_author_w_date).to eq('plain_creator_code')
|
74
70
|
end
|
75
|
-
it "
|
76
|
-
|
77
|
-
expect(
|
71
|
+
it "skips names when role isn't marcrelator authority" do
|
72
|
+
smods_rec.from_str(mods_start + plain_creator_non_mr + mods_end)
|
73
|
+
expect(smods_rec.main_author_w_date).to be_nil
|
78
74
|
end
|
79
|
-
it "
|
80
|
-
|
81
|
-
expect(
|
82
|
-
|
83
|
-
expect(
|
75
|
+
it "skips names without roles in favor of marcrelator role of 'Creator'" do
|
76
|
+
smods_rec.from_str(mods_start + personal_no_role + plain_creator_text + other_no_role + mods_end)
|
77
|
+
expect(smods_rec.main_author_w_date).to eq('plain_creator_text')
|
78
|
+
smods_rec.from_str(mods_start + corp_no_role + plain_creator_code + mods_end)
|
79
|
+
expect(smods_rec.main_author_w_date).to eq('plain_creator_code')
|
84
80
|
end
|
85
|
-
it "
|
86
|
-
|
87
|
-
expect(
|
88
|
-
|
89
|
-
expect(
|
81
|
+
it "does not care about name type" do
|
82
|
+
smods_rec.from_str(mods_start + personal_creator_code + corp_creator_text + mods_end)
|
83
|
+
expect(smods_rec.main_author_w_date).to eq('personal_creator_code')
|
84
|
+
smods_rec.from_str(mods_start + personal_no_role + corp_creator_text + mods_end)
|
85
|
+
expect(smods_rec.main_author_w_date).to eq('corp_creator_text')
|
90
86
|
end
|
91
|
-
end
|
87
|
+
end # marcrelator role Creator
|
92
88
|
|
93
89
|
context "marcrelator role Author" do
|
94
|
-
it "
|
95
|
-
|
96
|
-
expect(
|
90
|
+
it "finds role with roleTerm type text" do
|
91
|
+
smods_rec.from_str(mods_start + plain_author_text + mods_end)
|
92
|
+
expect(smods_rec.main_author_w_date).to eq('plain_author_text')
|
97
93
|
end
|
98
|
-
it "
|
99
|
-
|
100
|
-
expect(
|
94
|
+
it "finds role with roleTerm type code" do
|
95
|
+
smods_rec.from_str(mods_start + plain_author_code + mods_end)
|
96
|
+
expect(smods_rec.main_author_w_date).to eq('plain_author_code')
|
101
97
|
end
|
102
|
-
it "
|
103
|
-
|
104
|
-
expect(
|
98
|
+
it "skips names when role isn't marcrelator authority" do
|
99
|
+
smods_rec.from_str(mods_start + plain_author_non_mr + mods_end)
|
100
|
+
expect(smods_rec.main_author_w_date).to be_nil
|
105
101
|
end
|
106
|
-
it "
|
107
|
-
|
108
|
-
expect(
|
109
|
-
|
110
|
-
expect(
|
102
|
+
it "skips names without roles in favor of marcrelator role of 'Author'" do
|
103
|
+
smods_rec.from_str(mods_start + personal_no_role + plain_author_text + other_no_role + mods_end)
|
104
|
+
expect(smods_rec.main_author_w_date).to eq('plain_author_text')
|
105
|
+
smods_rec.from_str(mods_start + corp_no_role + personal_no_role + plain_author_code + mods_end)
|
106
|
+
expect(smods_rec.main_author_w_date).to eq('plain_author_code')
|
111
107
|
end
|
112
|
-
it "
|
113
|
-
|
114
|
-
expect(
|
115
|
-
|
116
|
-
expect(
|
108
|
+
it "doesn't care about name type" do
|
109
|
+
smods_rec.from_str(mods_start + personal_author_text + corp_author_code + mods_end)
|
110
|
+
expect(smods_rec.main_author_w_date).to eq('personal_author_text')
|
111
|
+
smods_rec.from_str(mods_start + personal_no_role + corp_author_code + mods_end)
|
112
|
+
expect(smods_rec.main_author_w_date).to eq('corp_author_code')
|
117
113
|
end
|
118
|
-
end
|
114
|
+
end # marcrelator role Author
|
119
115
|
|
120
|
-
it "
|
121
|
-
|
122
|
-
expect(
|
116
|
+
it "is a String" do
|
117
|
+
smods_rec.from_str(mods_start + personal_author_text + corp_creator_text + mods_end)
|
118
|
+
expect(smods_rec.main_author_w_date).to be_an_instance_of(String)
|
123
119
|
end
|
124
120
|
|
125
|
-
it "
|
126
|
-
|
127
|
-
expect(
|
128
|
-
|
129
|
-
expect(
|
121
|
+
it "takes first name with marcrelator role of 'Creator' or 'Author'" do
|
122
|
+
smods_rec.from_str(mods_start + personal_author_text + corp_creator_text + mods_end)
|
123
|
+
expect(smods_rec.main_author_w_date).to eq('personal_author_text')
|
124
|
+
smods_rec.from_str(mods_start + corp_creator_text + personal_creator_code + mods_end)
|
125
|
+
expect(smods_rec.main_author_w_date).to eq('corp_creator_text')
|
130
126
|
end
|
131
127
|
|
132
|
-
it "
|
133
|
-
|
134
|
-
expect(
|
128
|
+
it "takes the first name without a role if there are no instances of marcrelator role 'Creator' or 'Actor'" do
|
129
|
+
smods_rec.from_str(mods_start + plain_author_non_mr + personal_other_role + personal_no_role + plain_no_role + mods_end)
|
130
|
+
expect(smods_rec.main_author_w_date).to eq('personal_no_role')
|
135
131
|
end
|
136
132
|
|
137
|
-
it "
|
138
|
-
|
139
|
-
expect(
|
133
|
+
it "nil if there is no name with marcrelator role of 'Creator' or 'Author' and no name without a role" do
|
134
|
+
smods_rec.from_str(mods_start + plain_author_non_mr + personal_other_role + mods_end)
|
135
|
+
expect(smods_rec.main_author_w_date).to be_nil
|
140
136
|
end
|
141
137
|
|
142
|
-
it "
|
143
|
-
m = "<mods #{
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
138
|
+
it "uses the display name if it is present" do
|
139
|
+
m = "<mods xmlns=\"#{Mods::MODS_NS}\">
|
140
|
+
<name type='personal'>
|
141
|
+
<namePart type='given'>John</namePart>
|
142
|
+
<namePart type='family'>Huston</namePart>
|
143
|
+
<displayForm>q</displayForm>
|
144
|
+
</name>
|
145
|
+
<name type='personal'><namePart>Crusty The Clown</namePart></name>
|
146
|
+
<name type='corporate'><namePart>Watchful Eye</namePart></name>
|
147
|
+
<name type='corporate'>
|
148
|
+
<namePart>Exciting Prints</namePart>
|
149
|
+
<role><roleTerm type='text'>lithographer</roleTerm></role>
|
150
|
+
</name>
|
151
|
+
</mods>"
|
152
|
+
smods_rec.from_str(m)
|
153
|
+
expect(smods_rec.main_author_w_date).to eq('q')
|
154
|
+
end
|
155
|
+
it "includes dates, when available" do
|
156
|
+
m = "<mods xmlns=\"#{Mods::MODS_NS}\">
|
157
|
+
<name type='personal'>
|
158
|
+
<namePart>personal</namePart>
|
159
|
+
<namePart type='date'>1984-</namePart>
|
160
|
+
</name>
|
161
|
+
</mods>"
|
162
|
+
smods_rec.from_str(m)
|
163
|
+
expect(smods_rec.main_author_w_date).to eq('personal, 1984-')
|
164
|
+
m = "<mods xmlns=\"#{Mods::MODS_NS}\">
|
165
|
+
<name>
|
166
|
+
<namePart>plain</namePart>
|
167
|
+
<namePart type='date'>1954-</namePart>
|
168
|
+
</name>
|
169
|
+
</mods>"
|
170
|
+
smods_rec.from_str(m)
|
171
|
+
expect(smods_rec.main_author_w_date).to eq('plain, 1954-')
|
172
|
+
m = "<mods xmlns=\"#{Mods::MODS_NS}\">
|
173
|
+
<name type='corporate'>
|
174
|
+
<namePart>corporate</namePart>
|
175
|
+
<namePart type='date'>1990-</namePart>
|
176
|
+
</name>
|
177
|
+
</mods>"
|
178
|
+
smods_rec.from_str(m)
|
179
|
+
expect(smods_rec.main_author_w_date).to eq('corporate, 1990-')
|
177
180
|
end
|
178
181
|
end # main_author_w_date
|
179
182
|
|
180
183
|
context "additional_authors_w_dates" do
|
181
|
-
|
182
|
-
m = "<mods #{
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
expect(
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
expect(
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
expect(
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
expect(
|
236
|
-
|
237
|
-
|
238
|
-
|
184
|
+
let(:addl_authors) do
|
185
|
+
m = "<mods xmlns=\"#{Mods::MODS_NS}\">
|
186
|
+
<name type='personal'>
|
187
|
+
<namePart type='given'>John</namePart>
|
188
|
+
<namePart type='family'>Huston</namePart>
|
189
|
+
<displayForm>q</displayForm>
|
190
|
+
</name>
|
191
|
+
<name type='personal'>
|
192
|
+
<namePart>Crusty The Clown</namePart>
|
193
|
+
<namePart type='date'>1990-</namePart>
|
194
|
+
</name>
|
195
|
+
<name type='corporate'>
|
196
|
+
<namePart>Watchful Eye</namePart>
|
197
|
+
<namePart type='date'>1850-</namePart>
|
198
|
+
</name>
|
199
|
+
<name type='corporate'>
|
200
|
+
<namePart>Exciting Prints</namePart>
|
201
|
+
<role><roleTerm type='text'>lithographer</roleTerm></role>
|
202
|
+
</name>
|
203
|
+
<name>
|
204
|
+
<namePart>plain</namePart>
|
205
|
+
</name>
|
206
|
+
<name type='conference'>
|
207
|
+
<namePart>conference</namePart>
|
208
|
+
</name>
|
209
|
+
<name type='family'>
|
210
|
+
<namePart>family</namePart>
|
211
|
+
</name>
|
212
|
+
</mods>"
|
213
|
+
smods_rec.from_str(m)
|
214
|
+
smods_rec.additional_authors_w_dates
|
215
|
+
end
|
216
|
+
it "is an Array of Strings" do
|
217
|
+
expect(addl_authors).to be_an_instance_of(Array)
|
218
|
+
expect(addl_authors.first).to be_an_instance_of(String)
|
219
|
+
end
|
220
|
+
it "does not include main author" do
|
221
|
+
expect(addl_authors).not_to include(smods_rec.main_author_w_date)
|
222
|
+
end
|
223
|
+
it "includes personal authors that are not main author" do
|
224
|
+
expect(addl_authors).to include('Crusty The Clown, 1990-')
|
225
|
+
end
|
226
|
+
it "includes corporate (and other) authors that are not main author" do
|
227
|
+
expect(addl_authors).to include('Watchful Eye, 1850-')
|
228
|
+
expect(addl_authors).to include('Exciting Prints')
|
229
|
+
end
|
230
|
+
it "includes plain authors" do
|
231
|
+
expect(addl_authors).to include('plain')
|
232
|
+
end
|
233
|
+
it "includes conference and other typed authors" do
|
234
|
+
expect(addl_authors).to include('conference')
|
235
|
+
expect(addl_authors).to include('family')
|
236
|
+
end
|
237
|
+
it "includes dates, when available" do
|
238
|
+
expect(addl_authors).to include('Crusty The Clown, 1990-')
|
239
|
+
expect(addl_authors).to include('Watchful Eye, 1850-')
|
240
|
+
end
|
241
|
+
it "does not include roles" do
|
242
|
+
expect(addl_authors.find { |a| a =~ Regexp.new('lithographer') }).to be_nil
|
239
243
|
end
|
240
244
|
end # additional_authors_w_dates
|
241
245
|
|
246
|
+
context '#non_collector_person_authors' do
|
247
|
+
let(:name) { 'Hermione Grainger' }
|
248
|
+
let(:name2) { 'Ron Weasley' }
|
249
|
+
context 'has personal names that are not collectors' do
|
250
|
+
it 'only non-collector persons' do
|
251
|
+
name_snippet =
|
252
|
+
<<-EOF
|
253
|
+
<name type="personal">
|
254
|
+
<namePart>#{name}</namePart>
|
255
|
+
<role>
|
256
|
+
<roleTerm type="code" authority="marcrelator">cre</roleTerm>
|
257
|
+
</role>
|
258
|
+
</name>
|
259
|
+
<name type="personal">
|
260
|
+
<namePart>#{name2}</namePart>
|
261
|
+
<role>
|
262
|
+
<roleTerm type="code" authority="marcrelator">con</roleTerm>
|
263
|
+
</role>
|
264
|
+
</name>
|
265
|
+
EOF
|
266
|
+
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
267
|
+
expect(smods_rec.non_collector_person_authors).to include(name, name2)
|
268
|
+
end
|
269
|
+
it 'some collectors, some non-collectors' do
|
270
|
+
name_snippet =
|
271
|
+
<<-EOF
|
272
|
+
<name type="personal">
|
273
|
+
<namePart>#{name}</namePart>
|
274
|
+
<role>
|
275
|
+
<roleTerm type="code" authority="marcrelator">cre</roleTerm>
|
276
|
+
</role>
|
277
|
+
</name>
|
278
|
+
<name type="personal">
|
279
|
+
<namePart>#{name2}</namePart>
|
280
|
+
<role>
|
281
|
+
<roleTerm type="code" authority="marcrelator">col</roleTerm>
|
282
|
+
</role>
|
283
|
+
</name>
|
284
|
+
EOF
|
285
|
+
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
286
|
+
expect(smods_rec.non_collector_person_authors).to eq [name]
|
287
|
+
end
|
288
|
+
end
|
289
|
+
it 'nil if only collectors' do
|
290
|
+
name_snippet =
|
291
|
+
<<-EOF
|
292
|
+
<name type="personal">
|
293
|
+
<namePart>#{name}</namePart>
|
294
|
+
<role>
|
295
|
+
<roleTerm type="code" authority="marcrelator">col</roleTerm>
|
296
|
+
</role>
|
297
|
+
</name>
|
298
|
+
<name type="personal">
|
299
|
+
<namePart>Ron Weasley</namePart>
|
300
|
+
<role>
|
301
|
+
<roleTerm type="code" authority="marcrelator">col</roleTerm>
|
302
|
+
</role>
|
303
|
+
</name>
|
304
|
+
EOF
|
305
|
+
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
306
|
+
expect(smods_rec.non_collector_person_authors).to eq nil
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
context '#collectors_w_dates' do
|
311
|
+
let(:collector_name) { 'Dr. Seuss' }
|
312
|
+
context 'valueURI for roleTerm' do
|
313
|
+
it 'roleTerm has value' do
|
314
|
+
name_snippet =
|
315
|
+
<<-EOF
|
316
|
+
<name type="personal">
|
317
|
+
<namePart>#{collector_name}</namePart>
|
318
|
+
<role>
|
319
|
+
<roleTerm type="text" authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/col">Collector</roleTerm>
|
320
|
+
</role>
|
321
|
+
</name>
|
322
|
+
EOF
|
323
|
+
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
324
|
+
expect(smods_rec.collectors_w_dates).to eq [collector_name]
|
325
|
+
end
|
326
|
+
it 'empty roleTerm' do
|
327
|
+
name_snippet =
|
328
|
+
<<-EOF
|
329
|
+
<name type="personal">
|
330
|
+
<namePart>#{collector_name}</namePart>
|
331
|
+
<role>
|
332
|
+
<roleTerm authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/col" />
|
333
|
+
</role>
|
334
|
+
</name>
|
335
|
+
EOF
|
336
|
+
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
337
|
+
expect(smods_rec.collectors_w_dates).to eq [collector_name]
|
338
|
+
end
|
339
|
+
end
|
340
|
+
context 'no valueURI for roleTerm' do
|
341
|
+
it 'collector marc relator code' do
|
342
|
+
name_snippet =
|
343
|
+
<<-EOF
|
344
|
+
<name type="personal">
|
345
|
+
<namePart>#{collector_name}</namePart>
|
346
|
+
<role>
|
347
|
+
<roleTerm type="code" authority="marcrelator">col</roleTerm>
|
348
|
+
</role>
|
349
|
+
</name>
|
350
|
+
EOF
|
351
|
+
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
352
|
+
expect(smods_rec.collectors_w_dates).to eq [collector_name]
|
353
|
+
end
|
354
|
+
it 'collector marc relator text' do
|
355
|
+
name_snippet =
|
356
|
+
<<-EOF
|
357
|
+
<name type="personal">
|
358
|
+
<namePart>#{collector_name}</namePart>
|
359
|
+
<role>
|
360
|
+
<roleTerm type="text" authority="marcrelator">Collector</roleTerm>
|
361
|
+
</role>
|
362
|
+
</name>
|
363
|
+
EOF
|
364
|
+
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
365
|
+
expect(smods_rec.collectors_w_dates).to eq [collector_name]
|
366
|
+
end
|
367
|
+
end
|
368
|
+
it 'does not include non-collectors' do
|
369
|
+
name_snippet =
|
370
|
+
<<-EOF
|
371
|
+
<name type="personal">
|
372
|
+
<namePart>#{collector_name}</namePart>
|
373
|
+
<role>
|
374
|
+
<roleTerm type="text" authority="marcrelator">Collector</roleTerm>
|
375
|
+
</role>
|
376
|
+
</name>
|
377
|
+
<name type="personal">
|
378
|
+
<namePart>Freddy</namePart>
|
379
|
+
<role>
|
380
|
+
<roleTerm type='code' authority='marcrelator'>cre</roleTerm>
|
381
|
+
</role>
|
382
|
+
</name>
|
383
|
+
EOF
|
384
|
+
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
385
|
+
expect(smods_rec.collectors_w_dates).to eq [collector_name]
|
386
|
+
end
|
387
|
+
it 'multiple collectors' do
|
388
|
+
addl_name = 'Feigenbaum, Edward A.'
|
389
|
+
name_snippet =
|
390
|
+
<<-EOF
|
391
|
+
<name type="personal">
|
392
|
+
<namePart>#{collector_name}</namePart>
|
393
|
+
<role>
|
394
|
+
<roleTerm type="text" authority="marcrelator">Collector</roleTerm>
|
395
|
+
</role>
|
396
|
+
</name>
|
397
|
+
<name type="personal">
|
398
|
+
<namePart>#{addl_name}</namePart>
|
399
|
+
<role>
|
400
|
+
<roleTerm type='code' authority='marcrelator'>col</roleTerm>
|
401
|
+
</role>
|
402
|
+
</name>
|
403
|
+
EOF
|
404
|
+
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
405
|
+
expect(smods_rec.collectors_w_dates).to include(collector_name, addl_name)
|
406
|
+
end
|
407
|
+
it 'nil if no collectors' do
|
408
|
+
name_snippet =
|
409
|
+
<<-EOF
|
410
|
+
<name type="personal">
|
411
|
+
<namePart>Freddy</namePart>
|
412
|
+
<role>
|
413
|
+
<roleTerm type='code' authority='marcrelator'>cre</roleTerm>
|
414
|
+
</role>
|
415
|
+
</name>
|
416
|
+
EOF
|
417
|
+
smods_rec.from_str(mods_start + name_snippet + mods_end)
|
418
|
+
expect(smods_rec.collectors_w_dates).to eq nil
|
419
|
+
end
|
420
|
+
end
|
242
421
|
end
|