mods 2.4.0 → 3.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.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +24 -0
- data/.gitignore +1 -0
- data/Gemfile +0 -4
- data/README.md +1 -3
- data/lib/mods/date.rb +51 -17
- data/lib/mods/marc_country_codes.rb +12 -10
- data/lib/mods/nom_terminology.rb +110 -849
- data/lib/mods/reader.rb +9 -39
- data/lib/mods/record.rb +13 -28
- data/lib/mods/version.rb +1 -1
- data/mods.gemspec +3 -3
- data/spec/fixture_data/hp566jq8781.xml +334 -0
- data/spec/integration/parker_spec.rb +217 -0
- data/spec/{date_spec.rb → lib/date_spec.rb} +8 -1
- data/spec/lib/language_spec.rb +123 -0
- data/spec/lib/location_spec.rb +175 -0
- data/spec/lib/name_spec.rb +368 -0
- data/spec/lib/origin_info_spec.rb +134 -0
- data/spec/lib/part_spec.rb +162 -0
- data/spec/lib/physical_description_spec.rb +72 -0
- data/spec/{reader_spec.rb → lib/reader_spec.rb} +1 -41
- data/spec/lib/record_info_spec.rb +114 -0
- data/spec/lib/record_spec.rb +287 -0
- data/spec/lib/related_item_spec.rb +124 -0
- data/spec/lib/subject_spec.rb +427 -0
- data/spec/lib/title_spec.rb +108 -0
- data/spec/lib/top_level_elmnts_simple_spec.rb +169 -0
- data/spec/spec_helper.rb +87 -6
- data/spec/support/fixtures.rb +9 -0
- metadata +61 -43
- data/.coveralls.yml +0 -1
- data/.travis.yml +0 -6
- data/spec/language_spec.rb +0 -118
- data/spec/location_spec.rb +0 -295
- data/spec/name_spec.rb +0 -759
- data/spec/origin_info_spec.rb +0 -447
- data/spec/part_spec.rb +0 -471
- data/spec/physical_description_spec.rb +0 -144
- data/spec/record_info_spec.rb +0 -493
- data/spec/record_spec.rb +0 -356
- data/spec/related_item_spec.rb +0 -305
- data/spec/subject_spec.rb +0 -809
- data/spec/title_spec.rb +0 -226
- data/spec/top_level_elmnts_simple_spec.rb +0 -369
data/spec/origin_info_spec.rb
DELETED
@@ -1,447 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe "Mods <originInfo> Element" do
|
5
|
-
before(:all) do
|
6
|
-
@mods_rec = Mods::Record.new
|
7
|
-
@ns_decl = "xmlns='#{Mods::MODS_NS}'"
|
8
|
-
@kolb = "<mods>
|
9
|
-
<originInfo>
|
10
|
-
<dateCreated>1537-1553.</dateCreated>
|
11
|
-
<dateCreated point='start'>1537</dateCreated>
|
12
|
-
<dateCreated point='end'>1553</dateCreated>
|
13
|
-
</originInfo></mods>"
|
14
|
-
@reid_dennis = "<mods><originInfo><dateIssued>1852</dateIssued></originInfo></mods>"
|
15
|
-
@walters = "<mods><originInfo>
|
16
|
-
<place>
|
17
|
-
<placeTerm type='text'>Iran</placeTerm>
|
18
|
-
</place>
|
19
|
-
<dateIssued>22 Rabīʿ II 889 AH / 1484 CE</dateIssued>
|
20
|
-
<issuance>monographic</issuance>
|
21
|
-
</originInfo>
|
22
|
-
</mods>"
|
23
|
-
@simple = "<mods><originInfo><dateIssued>circa 1900</dateIssued></originInfo></mods>"
|
24
|
-
@ew = "<mods><originInfo>
|
25
|
-
<place>
|
26
|
-
<placeTerm type='text'>Reichenau Abbey, Lake Constance, Germany</placeTerm>
|
27
|
-
</place>
|
28
|
-
<dateIssued>Middle of the 11th century CE</dateIssued>
|
29
|
-
<issuance>monographic</issuance>
|
30
|
-
</originInfo>
|
31
|
-
</mods>"
|
32
|
-
@e = "<mods><originInfo>
|
33
|
-
<place>
|
34
|
-
<placeTerm type='code' authority='marccountry'>au</placeTerm>
|
35
|
-
</place>
|
36
|
-
<place>
|
37
|
-
<placeTerm type='text'>[Austria?</placeTerm>
|
38
|
-
</place>
|
39
|
-
<dateIssued>circa 1180-1199]</dateIssued>
|
40
|
-
<issuance>monographic</issuance>
|
41
|
-
</originInfo></mods>"
|
42
|
-
@f = "<mods> <originInfo>
|
43
|
-
<place>
|
44
|
-
<placeTerm authority='marccountry' type='code'>cau</placeTerm>
|
45
|
-
</place>
|
46
|
-
<dateIssued encoding='marc' keyDate='yes' point='start'>1850</dateIssued>
|
47
|
-
<dateIssued encoding='marc' point='end'>1906</dateIssued>
|
48
|
-
<issuance>monographic</issuance>
|
49
|
-
</originInfo>
|
50
|
-
</mods>"
|
51
|
-
@ex = "<mods><originInfo>
|
52
|
-
<place>
|
53
|
-
<placeTerm>France and Italy</placeTerm>
|
54
|
-
</place>
|
55
|
-
<dateCreated keyDate='yes' qualifier='inferred'>173-?</dateCreated>
|
56
|
-
</originInfo>
|
57
|
-
</mods>"
|
58
|
-
@ex1 = "<mods><originInfo>
|
59
|
-
<publisher>Robot Publishing</publisher>
|
60
|
-
<place>
|
61
|
-
<placeTerm>France</placeTerm>
|
62
|
-
</place>
|
63
|
-
<place>
|
64
|
-
<placeTerm>Italy</placeTerm>
|
65
|
-
</place>
|
66
|
-
<dateCreated keyDate='yes' qualifier='inferred'>173-?</dateCreated>
|
67
|
-
<dateIssued>1850</dateIssued>
|
68
|
-
</originInfo>
|
69
|
-
</mods>"
|
70
|
-
@ex2 = "<mods><originInfo>
|
71
|
-
<place>
|
72
|
-
<placeTerm type='code' authority='marccountry'>enk</placeTerm>
|
73
|
-
</place>
|
74
|
-
<place>
|
75
|
-
<placeTerm type='text'>[London]</placeTerm>
|
76
|
-
</place>
|
77
|
-
<publisher>Bunney & Gold</publisher>
|
78
|
-
<dateIssued>1799</dateIssued>
|
79
|
-
<dateIssued encoding='marc' keyDate='yes'>1799</dateIssued>
|
80
|
-
<issuance>monographic</issuance>
|
81
|
-
</originInfo>
|
82
|
-
</mods>"
|
83
|
-
@ex3 = "<mods><originInfo>
|
84
|
-
<place>
|
85
|
-
<placeTerm type='code' authority='marccountry'>xx</placeTerm>
|
86
|
-
</place>
|
87
|
-
<place>
|
88
|
-
<placeTerm type='text'>[s.l. : s.n.]</placeTerm>
|
89
|
-
</place>
|
90
|
-
<dateIssued>1780?]</dateIssued>
|
91
|
-
<dateIssued encoding='marc' keyDate='yes'>178u</dateIssued>
|
92
|
-
<issuance>monographic</issuance>
|
93
|
-
</originInfo>
|
94
|
-
</mods>"
|
95
|
-
@ex4 = "<mods><originInfo>
|
96
|
-
<place>
|
97
|
-
<placeTerm type='code' authority='marccountry'>fr</placeTerm>
|
98
|
-
</place>
|
99
|
-
<place>
|
100
|
-
<placeTerm type='text'>[S.l.]</placeTerm>
|
101
|
-
</place>
|
102
|
-
<publisher>[s.n.]</publisher>
|
103
|
-
<dateIssued>[1740.]</dateIssued>
|
104
|
-
<dateIssued encoding='marc' point='start' qualifier='questionable' keyDate='yes'>1740</dateIssued>
|
105
|
-
<dateIssued encoding='marc' point='end' qualifier='questionable'>1749</dateIssued>
|
106
|
-
<issuance>monographic</issuance>
|
107
|
-
</originInfo>
|
108
|
-
</mods>"
|
109
|
-
@ex5 = "<mods><originInfo>
|
110
|
-
<place>
|
111
|
-
<placeTerm type='code' authority='marccountry'>xx</placeTerm>
|
112
|
-
</place>
|
113
|
-
<place>
|
114
|
-
<placeTerm type='text'>[S.l.]</placeTerm>
|
115
|
-
</place>
|
116
|
-
<publisher>Olney</publisher>
|
117
|
-
<dateIssued>1844</dateIssued>
|
118
|
-
<dateIssued encoding='marc' keyDate='yes'>1844</dateIssued>
|
119
|
-
<issuance>monographic</issuance>
|
120
|
-
</originInfo>
|
121
|
-
</mods>"
|
122
|
-
@ex6 = "<mods><originInfo>
|
123
|
-
<place>
|
124
|
-
<placeTerm type='code' authority='marccountry'>enk</placeTerm>
|
125
|
-
</place>
|
126
|
-
<place>
|
127
|
-
<placeTerm type='text'>[London</placeTerm>
|
128
|
-
</place>
|
129
|
-
<publisher>Printed for William Innys and Joseph Richardson ... [et al.]</publisher>
|
130
|
-
<dateIssued>1752]</dateIssued>
|
131
|
-
<dateIssued encoding='marc' keyDate='yes'>1752</dateIssued>
|
132
|
-
<issuance>monographic</issuance>
|
133
|
-
</originInfo>
|
134
|
-
</mods>"
|
135
|
-
@ex7 = "<mods><originInfo>
|
136
|
-
<place>
|
137
|
-
<placeTerm authority='marccountry' type='code'>fr</placeTerm>
|
138
|
-
</place>
|
139
|
-
<place>
|
140
|
-
<placeTerm type='text'>[S.l.]</placeTerm>
|
141
|
-
</place>
|
142
|
-
<publisher>[s.n.]</publisher>
|
143
|
-
<dateIssued>[1740.]</dateIssued>
|
144
|
-
<dateIssued encoding='marc' keyDate='yes' point='start' qualifier='questionable'>1740</dateIssued>
|
145
|
-
<dateIssued encoding='marc' point='end' qualifier='questionable'>1749</dateIssued>
|
146
|
-
<issuance>monographic</issuance>
|
147
|
-
</originInfo>
|
148
|
-
</mods>"
|
149
|
-
|
150
|
-
xml = "<originInfo>
|
151
|
-
<dateCreated encoding='w3cdtf' keyDate='yes' point='start' qualifier='approximate'>250 B.C.</dateCreated>
|
152
|
-
<dateCreated encoding='w3cdtf' keyDate='yes' point='end' qualifier='approximate'>150 B.C.</dateCreated>
|
153
|
-
</originInfo>"
|
154
|
-
|
155
|
-
end
|
156
|
-
|
157
|
-
context "parsing date values" do
|
158
|
-
it "should cope with slop" do
|
159
|
-
skip "to be implemented"
|
160
|
-
end
|
161
|
-
it "should know something about various date encodings: w3cdtf, iso8601, marc, edtf, temper" do
|
162
|
-
skip "to be implemented"
|
163
|
-
end
|
164
|
-
it "should know the only valid values for point attribute are 'start' and 'end'" do
|
165
|
-
skip "to be implemented"
|
166
|
-
end
|
167
|
-
it "should know the only valid value for keyDate attribute is 'yes" do
|
168
|
-
skip "to be implemented"
|
169
|
-
end
|
170
|
-
it "should know the only valid values for qualifier attribute: approximate, inferred, questionable" do
|
171
|
-
skip "to be implemented"
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
context "parsing issuance" do
|
176
|
-
it "should know the only valid values are: continuing, monographic, single unit, multipart monograph, serial, integrating resource" do
|
177
|
-
skip "to be implemented"
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
context "parsing publisher" do
|
182
|
-
it "should ignore s.n. value (from MARC)" do
|
183
|
-
skip "to be implemented"
|
184
|
-
end
|
185
|
-
it "should leave square brackets alone, except for s.n." do
|
186
|
-
skip "to be implemented"
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
context "parsing placeTerm" do
|
191
|
-
it "should be able to translate marccountry codes" do
|
192
|
-
skip "to be implemented"
|
193
|
-
end
|
194
|
-
it "should ignore s.l. value (from MARC)" do
|
195
|
-
skip "to be implemented"
|
196
|
-
end
|
197
|
-
it "should be forgiving of square brackets (from MARC), matched or unmatched" do
|
198
|
-
skip "to be implemented"
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
|
203
|
-
context "basic <originInfo> terminology pieces" do
|
204
|
-
|
205
|
-
context "WITH namespaces" do
|
206
|
-
context "<place> child element" do
|
207
|
-
before(:all) do
|
208
|
-
@place_term_text = "<mods #{@ns_decl}><originInfo><place><placeTerm type='text'>Iran</placeTerm></place></originInfo></mods>"
|
209
|
-
@place_term_plain_mult = "<mods #{@ns_decl}><originInfo>
|
210
|
-
<place><placeTerm>France</placeTerm></place>
|
211
|
-
<place><placeTerm>Italy</placeTerm></place></originInfo></mods>"
|
212
|
-
@place_term_code = "<mods #{@ns_decl}><originInfo><place><placeTerm authority='marccountry' type='code'>fr</placeTerm></place></originInfo></mods>"
|
213
|
-
@yuck1 = "<mods #{@ns_decl}><originInfo><place><placeTerm type='text'>[S.l.]</placeTerm></place></originInfo></mods>"
|
214
|
-
@yuck2 = "<mods #{@ns_decl}><originInfo><place><placeTerm type='text'>[London</placeTerm></place></originInfo></mods>"
|
215
|
-
@yuck3 = "<mods #{@ns_decl}><originInfo><place><placeTerm type='text'>[s.l. : s.n.]</placeTerm></place></originInfo></mods>"
|
216
|
-
@yuck4 = "<mods #{@ns_decl}><originInfo><place><placeTerm type='text'>[London]</placeTerm></place></originInfo></mods>"
|
217
|
-
end
|
218
|
-
context "<placeTerm> child element" do
|
219
|
-
it "should get element values" do
|
220
|
-
vals = @mods_rec.from_str(@place_term_plain_mult).origin_info.place.placeTerm.map { |e| e.text}
|
221
|
-
expect(vals.size).to eq(2)
|
222
|
-
expect(vals).to include("France")
|
223
|
-
expect(vals).to include("Italy")
|
224
|
-
end
|
225
|
-
it "should get authority attribute" do
|
226
|
-
expect(@mods_rec.from_str(@place_term_code).origin_info.place.placeTerm.authority).to eq(["marccountry"])
|
227
|
-
end
|
228
|
-
it "should get type(_at) attribute" do
|
229
|
-
expect(@mods_rec.from_str(@place_term_code).origin_info.place.placeTerm.type_at).to eq(["code"])
|
230
|
-
end
|
231
|
-
end # placeTerm
|
232
|
-
end # place
|
233
|
-
|
234
|
-
context "<publisher> child element" do
|
235
|
-
before(:all) do
|
236
|
-
@ex = "<mods #{@ns_decl}><originInfo><publisher>Olney</publisher></origin_info></mods>"
|
237
|
-
@yuck1 = "<mods #{@ns_decl}><originInfo><publisher>[s.n.]</publisher></originInfo></mods>"
|
238
|
-
@yuck2 = "<mods #{@ns_decl}><originInfo><publisher>Printed for William Innys and Joseph Richardson ... [et al.]</publisher></originInfo></mods>"
|
239
|
-
end
|
240
|
-
it "should get element values" do
|
241
|
-
vals = @mods_rec.from_str("<mods #{@ns_decl}><originInfo><publisher>Olney</publisher></origin_info></mods>").origin_info.publisher
|
242
|
-
expect(vals.map { |n| n.text }).to eq(["Olney"])
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
describe '#as_object' do
|
247
|
-
describe '#key_dates' do
|
248
|
-
it 'should extract the date with the keyDate attribute' do
|
249
|
-
@mods_rec.from_str("<mods #{@ns_decl}><originInfo><dateCreated>other date</dateCreated><dateCreated keyDate='yes'>key date</dateCreated></originInfo></mods>")
|
250
|
-
expect(@mods_rec.origin_info.as_object.first.key_dates.first.text).to eq 'key date'
|
251
|
-
end
|
252
|
-
it 'should extract a date range when the keyDate attribute is on the start of the range' do
|
253
|
-
@mods_rec.from_str("<mods #{@ns_decl}><originInfo><dateCreated point='end'>other date</dateCreated><dateCreated keyDate='yes' point='start'>key date</dateCreated></originInfo></mods>")
|
254
|
-
expect(@mods_rec.origin_info.as_object.first.key_dates.first.text).to eq 'key date'
|
255
|
-
expect(@mods_rec.origin_info.as_object.first.key_dates.last.text).to eq 'other date'
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
context "<xxxDate> child elements" do
|
261
|
-
it "should recognize each element" do
|
262
|
-
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
263
|
-
@mods_rec.from_str("<mods #{@ns_decl}><originInfo><#{elname}>date</#{elname}></originInfo></mods>")
|
264
|
-
expect(@mods_rec.origin_info.send(elname.to_sym).map { |n| n.text }).to eq(["date"])
|
265
|
-
}
|
266
|
-
end
|
267
|
-
it "should recognize encoding attribute on each element" do
|
268
|
-
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
269
|
-
@mods_rec.from_str("<mods #{@ns_decl}><originInfo><#{elname} encoding='foo'>date</#{elname}></originInfo></mods>")
|
270
|
-
expect(@mods_rec.origin_info.send(elname.to_sym).encoding).to eq(["foo"])
|
271
|
-
}
|
272
|
-
end
|
273
|
-
it "should recognize keyDate attribute" do
|
274
|
-
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
275
|
-
@mods_rec.from_str("<mods #{@ns_decl}><originInfo><#{elname} keyDate='foo'>date</#{elname}></originInfo></mods>")
|
276
|
-
expect(@mods_rec.origin_info.send(elname.to_sym).keyDate).to eq(["foo"])
|
277
|
-
}
|
278
|
-
end
|
279
|
-
it "should recognize point attribute" do
|
280
|
-
# NOTE: values allowed are 'start' and 'end'
|
281
|
-
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
282
|
-
@mods_rec.from_str("<mods #{@ns_decl}><originInfo><#{elname} point='foo'>date</#{elname}></originInfo></mods>")
|
283
|
-
expect(@mods_rec.origin_info.send(elname.to_sym).point).to eq(["foo"])
|
284
|
-
}
|
285
|
-
end
|
286
|
-
it "should recognize qualifier attribute" do
|
287
|
-
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
288
|
-
@mods_rec.from_str("<mods #{@ns_decl}><originInfo><#{elname} qualifier='foo'>date</#{elname}></originInfo></mods>")
|
289
|
-
expect(@mods_rec.origin_info.send(elname.to_sym).qualifier).to eq(["foo"])
|
290
|
-
}
|
291
|
-
end
|
292
|
-
it "should recognize type attribute only on dateOther" do
|
293
|
-
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
294
|
-
@mods_rec.from_str("<mods #{@ns_decl}><originInfo><#{elname} type='foo'>date</#{elname}></originInfo></mods>")
|
295
|
-
if elname == 'dateOther'
|
296
|
-
expect(@mods_rec.origin_info.send(elname.to_sym).type_at).to eq(["foo"])
|
297
|
-
else
|
298
|
-
expect { @mods_rec.origin_info.send(elname.to_sym).type_at}.to raise_exception(NoMethodError, /type_at/)
|
299
|
-
end
|
300
|
-
}
|
301
|
-
end
|
302
|
-
end # <xxxDate> child elements
|
303
|
-
|
304
|
-
it "<edition> child element" do
|
305
|
-
xml = "<mods #{@ns_decl}><originInfo><edition>7th ed.</edition></originInfo></mods>"
|
306
|
-
expect(@mods_rec.from_str(xml).origin_info.edition.map { |n| n.text }).to eq(['7th ed.'])
|
307
|
-
end
|
308
|
-
|
309
|
-
context "<issuance> child element" do
|
310
|
-
before(:all) do
|
311
|
-
@ex = "<mods #{@ns_decl}><originInfo><issuance>monographic</issuance></originInfo></mods>"
|
312
|
-
end
|
313
|
-
it "should get element value" do
|
314
|
-
expect(@mods_rec.from_str(@ex).origin_info.issuance.map { |n| n.text }).to eq(['monographic'])
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|
318
|
-
context "<frequency> child element" do
|
319
|
-
before(:all) do
|
320
|
-
xml = "<mods #{@ns_decl}><originInfo><frequency authority='marcfrequency'>Annual</frequency></originInfo></mods>"
|
321
|
-
@origin_info = @mods_rec.from_str(xml).origin_info
|
322
|
-
end
|
323
|
-
it "should get element value" do
|
324
|
-
expect(@origin_info.frequency.map { |n| n.text }).to eq(["Annual"])
|
325
|
-
end
|
326
|
-
it "should recognize the authority attribute" do
|
327
|
-
expect(@origin_info.frequency.authority).to eq(["marcfrequency"])
|
328
|
-
end
|
329
|
-
end
|
330
|
-
end # WITH namspaces
|
331
|
-
|
332
|
-
context "WITHOUT namespaces" do
|
333
|
-
context "<place> child element" do
|
334
|
-
before(:all) do
|
335
|
-
@place_term_text = "<mods><originInfo><place><placeTerm type='text'>Iran</placeTerm></place></originInfo></mods>"
|
336
|
-
@place_term_plain_mult = "<mods><originInfo>
|
337
|
-
<place><placeTerm>France</placeTerm></place>
|
338
|
-
<place><placeTerm>Italy</placeTerm></place></originInfo></mods>"
|
339
|
-
@place_term_code = "<mods><originInfo><place><placeTerm authority='marccountry' type='code'>fr</placeTerm></place></originInfo></mods>"
|
340
|
-
@yuck1 = "<mods><originInfo><place><placeTerm type='text'>[S.l.]</placeTerm></place></originInfo></mods>"
|
341
|
-
@yuck2 = "<mods><originInfo><place><placeTerm type='text'>[London</placeTerm></place></originInfo></mods>"
|
342
|
-
@yuck3 = "<mods><originInfo><place><placeTerm type='text'>[s.l. : s.n.]</placeTerm></place></originInfo></mods>"
|
343
|
-
@yuck4 = "<mods><originInfo><place><placeTerm type='text'>[London]</placeTerm></place></originInfo></mods>"
|
344
|
-
end
|
345
|
-
context "<placeTerm> child element" do
|
346
|
-
it "should get element values" do
|
347
|
-
vals = @mods_rec.from_str(@place_term_plain_mult, false).origin_info.place.placeTerm.map { |e| e.text}
|
348
|
-
expect(vals.size).to eq(2)
|
349
|
-
expect(vals).to include("France")
|
350
|
-
expect(vals).to include("Italy")
|
351
|
-
end
|
352
|
-
it "should get authority attribute" do
|
353
|
-
expect(@mods_rec.from_str(@place_term_code, false).origin_info.place.placeTerm.authority).to eq(["marccountry"])
|
354
|
-
end
|
355
|
-
it "should get type(_at) attribute" do
|
356
|
-
expect(@mods_rec.from_str(@place_term_code, false).origin_info.place.placeTerm.type_at).to eq(["code"])
|
357
|
-
end
|
358
|
-
end # placeTerm
|
359
|
-
end # place
|
360
|
-
|
361
|
-
context "<publisher> child element" do
|
362
|
-
before(:all) do
|
363
|
-
@ex = "<mods><originInfo><publisher>Olney</publisher></origin_info></mods>"
|
364
|
-
@yuck1 = "<mods><originInfo><publisher>[s.n.]</publisher></originInfo></mods>"
|
365
|
-
@yuck2 = "<mods><originInfo><publisher>Printed for William Innys and Joseph Richardson ... [et al.]</publisher></originInfo></mods>"
|
366
|
-
end
|
367
|
-
it "should get element values" do
|
368
|
-
vals = @mods_rec.from_str("<mods><originInfo><publisher>Olney</publisher></origin_info></mods>", false).origin_info.publisher
|
369
|
-
expect(vals.map { |n| n.text }).to eq(["Olney"])
|
370
|
-
end
|
371
|
-
end
|
372
|
-
|
373
|
-
context "<xxxDate> child elements" do
|
374
|
-
it "should recognize each element" do
|
375
|
-
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
376
|
-
@mods_rec.from_str("<mods><originInfo><#{elname}>date</#{elname}></originInfo></mods>", false)
|
377
|
-
expect(@mods_rec.origin_info.send(elname.to_sym).map { |n| n.text }).to eq(["date"])
|
378
|
-
}
|
379
|
-
end
|
380
|
-
it "should recognize encoding attribute on each element" do
|
381
|
-
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
382
|
-
@mods_rec.from_str("<mods><originInfo><#{elname} encoding='foo'>date</#{elname}></originInfo></mods>", false)
|
383
|
-
expect(@mods_rec.origin_info.send(elname.to_sym).encoding).to eq(["foo"])
|
384
|
-
}
|
385
|
-
end
|
386
|
-
it "should recognize keyDate attribute" do
|
387
|
-
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
388
|
-
@mods_rec.from_str("<mods><originInfo><#{elname} keyDate='foo'>date</#{elname}></originInfo></mods>", false)
|
389
|
-
expect(@mods_rec.origin_info.send(elname.to_sym).keyDate).to eq(["foo"])
|
390
|
-
}
|
391
|
-
end
|
392
|
-
it "should recognize point attribute" do
|
393
|
-
# NOTE: values allowed are 'start' and 'end'
|
394
|
-
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
395
|
-
@mods_rec.from_str("<mods><originInfo><#{elname} point='foo'>date</#{elname}></originInfo></mods>", false)
|
396
|
-
expect(@mods_rec.origin_info.send(elname.to_sym).point).to eq(["foo"])
|
397
|
-
}
|
398
|
-
end
|
399
|
-
it "should recognize qualifier attribute" do
|
400
|
-
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
401
|
-
@mods_rec.from_str("<mods><originInfo><#{elname} qualifier='foo'>date</#{elname}></originInfo></mods>", false)
|
402
|
-
expect(@mods_rec.origin_info.send(elname.to_sym).qualifier).to eq(["foo"])
|
403
|
-
}
|
404
|
-
end
|
405
|
-
it "should recognize type attribute only on dateOther" do
|
406
|
-
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
407
|
-
@mods_rec.from_str("<mods><originInfo><#{elname} type='foo'>date</#{elname}></originInfo></mods>", false)
|
408
|
-
if elname == 'dateOther'
|
409
|
-
expect(@mods_rec.origin_info.send(elname.to_sym).type_at).to eq(["foo"])
|
410
|
-
else
|
411
|
-
expect { @mods_rec.origin_info.send(elname.to_sym).type_at}.to raise_exception(NoMethodError, /type_at/)
|
412
|
-
end
|
413
|
-
}
|
414
|
-
end
|
415
|
-
end # <xxxDate> child elements
|
416
|
-
|
417
|
-
it "<edition> child element" do
|
418
|
-
xml = "<mods><originInfo><edition>7th ed.</edition></originInfo></mods>"
|
419
|
-
expect(@mods_rec.from_str(xml, false).origin_info.edition.map { |n| n.text }).to eq(['7th ed.'])
|
420
|
-
end
|
421
|
-
|
422
|
-
context "<issuance> child element" do
|
423
|
-
before(:all) do
|
424
|
-
@ex = "<mods><originInfo><issuance>monographic</issuance></originInfo></mods>"
|
425
|
-
end
|
426
|
-
it "should get element value" do
|
427
|
-
expect(@mods_rec.from_str(@ex, false).origin_info.issuance.map { |n| n.text }).to eq(['monographic'])
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
|
-
context "<frequency> child element" do
|
432
|
-
before(:all) do
|
433
|
-
xml = "<mods><originInfo><frequency authority='marcfrequency'>Annual</frequency></originInfo></mods>"
|
434
|
-
@origin_info = @mods_rec.from_str(xml, false).origin_info
|
435
|
-
end
|
436
|
-
it "should get element value" do
|
437
|
-
expect(@origin_info.frequency.map { |n| n.text }).to eq(["Annual"])
|
438
|
-
end
|
439
|
-
it "should recognize the authority attribute" do
|
440
|
-
expect(@origin_info.frequency.authority).to eq(["marcfrequency"])
|
441
|
-
end
|
442
|
-
end
|
443
|
-
end # WITHOUT namspaces
|
444
|
-
|
445
|
-
end # basic terminology
|
446
|
-
|
447
|
-
end
|