mods 0.0.23 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.coveralls.yml +1 -0
- data/.travis.yml +9 -2
- data/Gemfile +4 -0
- data/README.rdoc +8 -3
- data/lib/mods/reader.rb +26 -10
- data/lib/mods/record.rb +43 -21
- data/lib/mods/version.rb +1 -1
- data/mods.gemspec +2 -3
- data/spec/fixture_data/shpc1.mods.xml +43 -0
- data/spec/origin_info_spec.rb +18 -18
- data/spec/part_spec.rb +8 -8
- data/spec/reader_spec.rb +37 -21
- data/spec/record_info_spec.rb +27 -27
- data/spec/record_spec.rb +36 -23
- data/spec/related_item_spec.rb +16 -16
- data/spec/spec_helper.rb +2 -13
- data/spec/subject_spec.rb +41 -41
- data/spec/top_level_elmnts_simple_spec.rb +16 -16
- metadata +29 -55
- data/.rvmrc +0 -1
data/spec/part_spec.rb
CHANGED
@@ -7,11 +7,11 @@ describe "Mods <part> Element" do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should normalize dates" do
|
10
|
-
|
10
|
+
skip "to be implemented"
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
context "basic <part> terminology pieces" do
|
14
|
-
|
14
|
+
|
15
15
|
context "WITH namespaces" do
|
16
16
|
before(:all) do
|
17
17
|
@ex = @mods_rec.from_str("<mods #{@ns_decl}><part>
|
@@ -38,7 +38,7 @@ describe "Mods <part> Element" do
|
|
38
38
|
</detail>
|
39
39
|
</part></mods>").part
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
it "should be a NodeSet" do
|
43
43
|
[@ex, @ex2, @detail].each { |p| p.should be_an_instance_of(Nokogiri::XML::NodeSet) }
|
44
44
|
end
|
@@ -205,7 +205,7 @@ describe "Mods <part> Element" do
|
|
205
205
|
@date.size.should == 1
|
206
206
|
end
|
207
207
|
it "should recognize all date attributes except keyDate" do
|
208
|
-
Mods::DATE_ATTRIBS.reject { |n| n == 'keyDate' }.each { |a|
|
208
|
+
Mods::DATE_ATTRIBS.reject { |n| n == 'keyDate' }.each { |a|
|
209
209
|
@mods_rec.from_str("<mods #{@ns_decl}><part><date #{a}='attr_val'>zzz</date></part></mods>")
|
210
210
|
@mods_rec.part.date.send(a.to_sym).should == ['attr_val']
|
211
211
|
}
|
@@ -265,7 +265,7 @@ describe "Mods <part> Element" do
|
|
265
265
|
</detail>
|
266
266
|
</part></mods>", false).part
|
267
267
|
end
|
268
|
-
|
268
|
+
|
269
269
|
it "should be a NodeSet" do
|
270
270
|
[@ex, @ex2, @detail].each { |p| p.should be_an_instance_of(Nokogiri::XML::NodeSet) }
|
271
271
|
end
|
@@ -432,7 +432,7 @@ describe "Mods <part> Element" do
|
|
432
432
|
@date.size.should == 1
|
433
433
|
end
|
434
434
|
it "should recognize all date attributes except keyDate" do
|
435
|
-
Mods::DATE_ATTRIBS.reject { |n| n == 'keyDate' }.each { |a|
|
435
|
+
Mods::DATE_ATTRIBS.reject { |n| n == 'keyDate' }.each { |a|
|
436
436
|
@mods_rec.from_str("<mods><part><date #{a}='attr_val'>zzz</date></part></mods>", false)
|
437
437
|
@mods_rec.part.date.send(a.to_sym).should == ['attr_val']
|
438
438
|
}
|
@@ -468,4 +468,4 @@ describe "Mods <part> Element" do
|
|
468
468
|
|
469
469
|
|
470
470
|
end # basic <part> terminoology
|
471
|
-
end
|
471
|
+
end
|
data/spec/reader_spec.rb
CHANGED
@@ -11,24 +11,40 @@ describe "Mods::Reader" do
|
|
11
11
|
@example_ns_str = '<mods:mods xmlns:mods="http://www.loc.gov/mods/v3"><mods:note>ns</mods:note></mods:mods>'
|
12
12
|
@example_no_ns_str = '<mods><note>no ns</note></mods>'
|
13
13
|
@example_wrong_ns_str = '<mods xmlns="wrong"><note>wrong ns</note></mods>'
|
14
|
-
@doc_from_str_default_ns = Mods::Reader.new.from_str(@example_ns_str)
|
15
|
-
@doc_from_str_ns = Mods::Reader.new.from_str(@example_ns_str)
|
16
|
-
@doc_from_str_no_ns = Mods::Reader.new.from_str(@example_no_ns_str)
|
17
|
-
@doc_from_str_wrong_ns = Mods::Reader.new.from_str(@example_wrong_ns_str)
|
14
|
+
@doc_from_str_default_ns = Mods::Reader.new.from_str(@example_ns_str)
|
15
|
+
@doc_from_str_ns = Mods::Reader.new.from_str(@example_ns_str)
|
16
|
+
@doc_from_str_no_ns = Mods::Reader.new.from_str(@example_no_ns_str)
|
17
|
+
@doc_from_str_wrong_ns = Mods::Reader.new.from_str(@example_wrong_ns_str)
|
18
18
|
@from_url = Mods::Reader.new.from_url(@example_url)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
it "from_str should turn an xml string into a Nokogiri::XML::Document object" do
|
22
|
-
@doc_from_str_default_ns.
|
23
|
-
@doc_from_str_ns.
|
24
|
-
@doc_from_str_no_ns.
|
25
|
-
@doc_from_str_wrong_ns.
|
22
|
+
expect(@doc_from_str_default_ns).to be_instance_of(Nokogiri::XML::Document)
|
23
|
+
expect(@doc_from_str_ns).to be_instance_of(Nokogiri::XML::Document)
|
24
|
+
expect(@doc_from_str_no_ns).to be_instance_of(Nokogiri::XML::Document)
|
25
|
+
expect(@doc_from_str_wrong_ns).to be_instance_of(Nokogiri::XML::Document)
|
26
|
+
end
|
27
|
+
|
28
|
+
context "from_url" do
|
29
|
+
it "from_url should turn the contents at the url into a Nokogiri::XML::Document object" do
|
30
|
+
expect(@from_url).to be_instance_of(Nokogiri::XML::Document)
|
31
|
+
end
|
26
32
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
33
|
+
|
34
|
+
context "from_file" do
|
35
|
+
before(:all) do
|
36
|
+
@fixture_dir = File.join(File.dirname(__FILE__), 'fixture_data')
|
37
|
+
@fixture_mods_file = File.join(@fixture_dir, 'shpc1.mods.xml')
|
38
|
+
@from_file = Mods::Reader.new.from_file(@fixture_mods_file)
|
39
|
+
end
|
40
|
+
it "should turn the contents of a file into a Nokogiri::XML::Document object" do
|
41
|
+
expect(@from_file).to be_instance_of(Nokogiri::XML::Document)
|
42
|
+
end
|
43
|
+
it "should give a meaningful error if passed a bad file" do
|
44
|
+
expect(lambda{Mods::Record.new.from_file('/fake/file')}).to raise_error
|
45
|
+
end
|
30
46
|
end
|
31
|
-
|
47
|
+
|
32
48
|
context "namespace awareness" do
|
33
49
|
it "should care about namespace by default" do
|
34
50
|
r = Mods::Reader.new
|
@@ -58,13 +74,13 @@ describe "Mods::Reader" do
|
|
58
74
|
my_from_str_wrong_ns = r.from_str(@example_wrong_ns_str)
|
59
75
|
my_from_str_wrong_ns.xpath('/m:mods/m:note', @ns_hash).size.should == 0
|
60
76
|
my_from_str_wrong_ns.xpath('/mods/note').text.should == "wrong ns"
|
61
|
-
end
|
77
|
+
end
|
62
78
|
end
|
63
|
-
|
79
|
+
|
64
80
|
it "should do something useful when it gets unparseable XML" do
|
65
|
-
|
81
|
+
skip "need to implement error handling for bad xml"
|
66
82
|
end
|
67
|
-
|
83
|
+
|
68
84
|
context "normalizing mods" do
|
69
85
|
it "should not lose UTF-8 encoding" do
|
70
86
|
utf_mods = '<?xml version="1.0" encoding="UTF-8"?>
|
@@ -92,7 +108,7 @@ describe "Mods::Reader" do
|
|
92
108
|
r.mods_ng_xml.root.attributes.keys.should_not include('xsi:schemaLocation')
|
93
109
|
end
|
94
110
|
end
|
95
|
-
|
111
|
+
|
96
112
|
context "from_nk_node" do
|
97
113
|
before(:all) do
|
98
114
|
oai_resp = '<?xml version="1.0" encoding="UTF-8"?>
|
@@ -132,7 +148,7 @@ describe "Mods::Reader" do
|
|
132
148
|
mods_ng_doc.xpath('/m:mods/m:titleInfo/m:title', @ns_hash).size.should == 0
|
133
149
|
mods_ng_doc.xpath('/mods/titleInfo/title').text.should == "boo"
|
134
150
|
@r.namespace_aware = true
|
135
|
-
end
|
151
|
+
end
|
136
152
|
end # context from_nk_node
|
137
|
-
|
138
|
-
end
|
153
|
+
|
154
|
+
end
|
data/spec/record_info_spec.rb
CHANGED
@@ -7,15 +7,15 @@ describe "Mods <recordInfo> Element" do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should translate language codes" do
|
10
|
-
|
10
|
+
skip "to be implemented"
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should normalize dates" do
|
14
|
-
|
14
|
+
skip "to be implemented"
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
context "basic <record_info> terminology pieces" do
|
18
|
-
|
18
|
+
|
19
19
|
context "WITH namespaces" do
|
20
20
|
before(:all) do
|
21
21
|
@rec_info = @mods_rec.from_str("<mods #{@ns_decl}><recordInfo>
|
@@ -57,8 +57,8 @@ describe "Mods <recordInfo> Element" do
|
|
57
57
|
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.size.should == 1 }
|
58
58
|
end
|
59
59
|
it "should recognize language attributes on <recordInfo> element" do
|
60
|
-
|
61
|
-
Mods::LANG_ATTRIBS.each { |a|
|
60
|
+
skip "problem with xml:lang"
|
61
|
+
Mods::LANG_ATTRIBS.each { |a|
|
62
62
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo #{a}='val'><recordOrigin>nowhere</recordOrigin></recordInfo></mods>")
|
63
63
|
@mods_rec.record_info.send(a.to_sym).should == ['val']
|
64
64
|
}
|
@@ -86,7 +86,7 @@ describe "Mods <recordInfo> Element" do
|
|
86
86
|
@bnf.recordContentSource.authority.size.should == 0
|
87
87
|
end
|
88
88
|
it "should recognize all authority attributes" do
|
89
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
89
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
90
90
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo><recordContentSource #{a}='attr_val'>zzz</recordContentSource></recordInfo></mods>")
|
91
91
|
@mods_rec.record_info.recordContentSource.send(a.to_sym).should == ['attr_val']
|
92
92
|
}
|
@@ -111,7 +111,7 @@ describe "Mods <recordInfo> Element" do
|
|
111
111
|
@bnf.recordCreationDate.encoding.should == ['w3cdtf']
|
112
112
|
end
|
113
113
|
it "should recognize all date attributes" do
|
114
|
-
Mods::DATE_ATTRIBS.each { |a|
|
114
|
+
Mods::DATE_ATTRIBS.each { |a|
|
115
115
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo><recordCreationDate #{a}='attr_val'>zzz</recordCreationDate></recordInfo></mods>")
|
116
116
|
@mods_rec.record_info.recordCreationDate.send(a.to_sym).should == ['attr_val']
|
117
117
|
}
|
@@ -133,7 +133,7 @@ describe "Mods <recordInfo> Element" do
|
|
133
133
|
@rlin.recordChangeDate.encoding.should == ['iso8601']
|
134
134
|
end
|
135
135
|
it "should recognize all date attributes" do
|
136
|
-
Mods::DATE_ATTRIBS.each { |a|
|
136
|
+
Mods::DATE_ATTRIBS.each { |a|
|
137
137
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo><recordChangeDate #{a}='attr_val'>zzz</recordChangeDate></recordInfo></mods>")
|
138
138
|
@mods_rec.record_info.recordChangeDate.send(a.to_sym).should == ['attr_val']
|
139
139
|
}
|
@@ -201,9 +201,9 @@ describe "Mods <recordInfo> Element" do
|
|
201
201
|
end
|
202
202
|
|
203
203
|
# from http://www.loc.gov/standards/mods/userguide/recordinfo.html#languageofcataloging
|
204
|
-
# objectPart attribute defined for consistency with <language> . Unlikely to be used with <languageOfCataloging>
|
204
|
+
# objectPart attribute defined for consistency with <language> . Unlikely to be used with <languageOfCataloging>
|
205
205
|
it "objectType should get attribute value" do
|
206
|
-
|
206
|
+
skip "<languageOfCataloging objectType=''> to be implemented ... maybe ..."
|
207
207
|
end
|
208
208
|
|
209
209
|
context "<languageTerm> child element" do
|
@@ -224,7 +224,7 @@ describe "Mods <recordInfo> Element" do
|
|
224
224
|
|
225
225
|
context "<scriptTerm> child element" do
|
226
226
|
it "should do something" do
|
227
|
-
|
227
|
+
skip "<recordInfo><languageOfCataloging><scriptTerm> to be implemented"
|
228
228
|
end
|
229
229
|
end
|
230
230
|
end # <languageOfCataloging>
|
@@ -243,13 +243,13 @@ describe "Mods <recordInfo> Element" do
|
|
243
243
|
@bnf.descriptionStandard.map { |n| n.text }.should == []
|
244
244
|
end
|
245
245
|
it "should recognize all authority attributes" do
|
246
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
246
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
247
247
|
@mods_rec.from_str("<mods #{@ns_decl}><recordInfo><descriptionStandard #{a}='attr_val'>zzz</descriptionStandard></recordInfo></mods>")
|
248
248
|
@mods_rec.record_info.descriptionStandard.send(a.to_sym).should == ['attr_val']
|
249
249
|
}
|
250
250
|
end
|
251
251
|
end # <descriptionStandard>
|
252
|
-
|
252
|
+
|
253
253
|
end # WITH namespaces
|
254
254
|
|
255
255
|
context "WITHOUT namespaces" do
|
@@ -293,8 +293,8 @@ describe "Mods <recordInfo> Element" do
|
|
293
293
|
[@rec_info, @rec_info2, @bnf, @rlin].each { |ri| ri.size.should == 1 }
|
294
294
|
end
|
295
295
|
it "should recognize language attributes on <recordInfo> element" do
|
296
|
-
|
297
|
-
Mods::LANG_ATTRIBS.each { |a|
|
296
|
+
skip "problem with xml:lang"
|
297
|
+
Mods::LANG_ATTRIBS.each { |a|
|
298
298
|
@mods_rec.from_str("<mods><recordInfo #{a}='val'><recordOrigin>nowhere</recordOrigin></recordInfo></mods>", false)
|
299
299
|
@mods_rec.record_info.send(a.to_sym).should == ['val']
|
300
300
|
}
|
@@ -322,7 +322,7 @@ describe "Mods <recordInfo> Element" do
|
|
322
322
|
@bnf.recordContentSource.authority.size.should == 0
|
323
323
|
end
|
324
324
|
it "should recognize all authority attributes" do
|
325
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
325
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
326
326
|
@mods_rec.from_str("<mods><recordInfo><recordContentSource #{a}='attr_val'>zzz</recordContentSource></recordInfo></mods>", false)
|
327
327
|
@mods_rec.record_info.recordContentSource.send(a.to_sym).should == ['attr_val']
|
328
328
|
}
|
@@ -347,7 +347,7 @@ describe "Mods <recordInfo> Element" do
|
|
347
347
|
@bnf.recordCreationDate.encoding.should == ['w3cdtf']
|
348
348
|
end
|
349
349
|
it "should recognize all date attributes" do
|
350
|
-
Mods::DATE_ATTRIBS.each { |a|
|
350
|
+
Mods::DATE_ATTRIBS.each { |a|
|
351
351
|
@mods_rec.from_str("<mods><recordInfo><recordCreationDate #{a}='attr_val'>zzz</recordCreationDate></recordInfo></mods>", false)
|
352
352
|
@mods_rec.record_info.recordCreationDate.send(a.to_sym).should == ['attr_val']
|
353
353
|
}
|
@@ -369,7 +369,7 @@ describe "Mods <recordInfo> Element" do
|
|
369
369
|
@rlin.recordChangeDate.encoding.should == ['iso8601']
|
370
370
|
end
|
371
371
|
it "should recognize all date attributes" do
|
372
|
-
Mods::DATE_ATTRIBS.each { |a|
|
372
|
+
Mods::DATE_ATTRIBS.each { |a|
|
373
373
|
@mods_rec.from_str("<mods><recordInfo><recordChangeDate #{a}='attr_val'>zzz</recordChangeDate></recordInfo></mods>", false)
|
374
374
|
@mods_rec.record_info.recordChangeDate.send(a.to_sym).should == ['attr_val']
|
375
375
|
}
|
@@ -437,9 +437,9 @@ describe "Mods <recordInfo> Element" do
|
|
437
437
|
end
|
438
438
|
|
439
439
|
# from http://www.loc.gov/standards/mods/userguide/recordinfo.html#languageofcataloging
|
440
|
-
# objectPart attribute defined for consistency with <language> . Unlikely to be used with <languageOfCataloging>
|
440
|
+
# objectPart attribute defined for consistency with <language> . Unlikely to be used with <languageOfCataloging>
|
441
441
|
it "objectType should get attribute value" do
|
442
|
-
|
442
|
+
skip "<languageOfCataloging objectType=''> to be implemented ... maybe ..."
|
443
443
|
end
|
444
444
|
|
445
445
|
context "<languageTerm> child element" do
|
@@ -460,7 +460,7 @@ describe "Mods <recordInfo> Element" do
|
|
460
460
|
|
461
461
|
context "<scriptTerm> child element" do
|
462
462
|
it "should do something" do
|
463
|
-
|
463
|
+
skip "<recordInfo><languageOfCataloging><scriptTerm> to be implemented"
|
464
464
|
end
|
465
465
|
end
|
466
466
|
end # <languageOfCataloging>
|
@@ -479,15 +479,15 @@ describe "Mods <recordInfo> Element" do
|
|
479
479
|
@bnf.descriptionStandard.map { |n| n.text }.should == []
|
480
480
|
end
|
481
481
|
it "should recognize all authority attributes" do
|
482
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
482
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
483
483
|
@mods_rec.from_str("<mods><recordInfo><descriptionStandard #{a}='attr_val'>zzz</descriptionStandard></recordInfo></mods>", false)
|
484
484
|
@mods_rec.record_info.descriptionStandard.send(a.to_sym).should == ['attr_val']
|
485
485
|
}
|
486
486
|
end
|
487
487
|
end # <descriptionStandard>
|
488
|
-
|
488
|
+
|
489
489
|
end # WITHOUT namespaces
|
490
|
-
|
490
|
+
|
491
491
|
end # basic <record_info> terminology pieces
|
492
492
|
|
493
|
-
end
|
493
|
+
end
|
data/spec/record_spec.rb
CHANGED
@@ -7,8 +7,8 @@ describe "Mods::Record" do
|
|
7
7
|
@example_ns_str = "<mods #{@def_ns_decl}><note>default ns</note></mods>"
|
8
8
|
@example_no_ns_str = '<mods><note>no ns</note></mods>'
|
9
9
|
@example_record_url = 'http://www.loc.gov/standards/mods/modsrdf/examples/0001.xml'
|
10
|
-
@doc_from_str_ns = Mods::Reader.new.from_str(@example_ns_str)
|
11
|
-
@doc_from_str_no_ns = Mods::Reader.new.from_str(@example_no_ns_str)
|
10
|
+
@doc_from_str_ns = Mods::Reader.new.from_str(@example_ns_str)
|
11
|
+
@doc_from_str_no_ns = Mods::Reader.new.from_str(@example_no_ns_str)
|
12
12
|
end
|
13
13
|
|
14
14
|
context "from_str" do
|
@@ -31,18 +31,31 @@ describe "Mods::Record" do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
# Be able to create a new Mods::Record from a url
|
34
35
|
context "from_url" do
|
35
36
|
before(:all) do
|
36
37
|
@mods_doc = Mods::Record.new.from_url(@example_record_url)
|
37
38
|
end
|
38
|
-
it "should
|
39
|
-
@mods_doc.
|
39
|
+
it "should return a mods record" do
|
40
|
+
expect(@mods_doc).to be_a_kind_of(Mods::Record)
|
40
41
|
end
|
41
42
|
it "should raise an error on a bad url" do
|
42
43
|
lambda{Mods::Record.new.from_url("http://example.org/fake.xml")}.should raise_error
|
43
44
|
end
|
44
45
|
end
|
45
|
-
|
46
|
+
|
47
|
+
# Be able to create a new Mods::Record from a file
|
48
|
+
context "from_file" do
|
49
|
+
before(:all) do
|
50
|
+
@fixture_dir = File.join(File.dirname(__FILE__), 'fixture_data')
|
51
|
+
@fixture_mods_file = File.join(@fixture_dir, 'shpc1.mods.xml')
|
52
|
+
@mods_doc = Mods::Record.new.from_file(@fixture_mods_file)
|
53
|
+
end
|
54
|
+
it "should return a mods record" do
|
55
|
+
expect(@mods_doc).to be_a_kind_of(Mods::Record)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
46
59
|
context "from_nk_node" do
|
47
60
|
before(:all) do
|
48
61
|
oai_resp = '<?xml version="1.0" encoding="UTF-8"?>
|
@@ -76,7 +89,7 @@ describe "Mods::Record" do
|
|
76
89
|
</n:titleInfo>
|
77
90
|
</n:mods>
|
78
91
|
</metadata>'
|
79
|
-
ng_xml = Nokogiri::XML(bad_ns_wrapped)
|
92
|
+
ng_xml = Nokogiri::XML(bad_ns_wrapped)
|
80
93
|
@mods_node_no_ns = ng_xml.xpath('//n:mods', {'n'=>'http://www.not.mods.org'}).first
|
81
94
|
end
|
82
95
|
it "should have namespace aware parsing turned on by default" do
|
@@ -94,7 +107,7 @@ describe "Mods::Record" do
|
|
94
107
|
mods_ng_doc.title_info.title.map { |e| e.text }.should == ["What? No namespaces?"]
|
95
108
|
end
|
96
109
|
end # context from_nk_node
|
97
|
-
|
110
|
+
|
98
111
|
context "getting term values" do
|
99
112
|
before(:all) do
|
100
113
|
m = "<mods #{@def_ns_decl}>
|
@@ -108,7 +121,7 @@ describe "Mods::Record" do
|
|
108
121
|
@mods_rec = Mods::Record.new
|
109
122
|
@mods_rec.from_str(m)
|
110
123
|
end
|
111
|
-
|
124
|
+
|
112
125
|
context "term_value (single value result)" do
|
113
126
|
it "should return nil if there are no such values in the MODS" do
|
114
127
|
@mods_rec.term_value(:identifier).should == nil
|
@@ -158,9 +171,9 @@ describe "Mods::Record" do
|
|
158
171
|
it "should raise an error if the argument isn't a Symbol or an Array" do
|
159
172
|
expect { @mods_rec.term_values(@mods_rec.subject) }.to raise_error(ArgumentError, /term_values called with unrecognized argument class:.*NodeSet.*/)
|
160
173
|
end
|
161
|
-
end
|
174
|
+
end
|
162
175
|
end # getting term values
|
163
|
-
|
176
|
+
|
164
177
|
context "convenience methods for accessing tricky bits of terminology" do
|
165
178
|
before(:all) do
|
166
179
|
@mods_rec = Mods::Record.new
|
@@ -185,7 +198,7 @@ describe "Mods::Record" do
|
|
185
198
|
@mods_rec.alternative_titles.should == ['12']
|
186
199
|
end
|
187
200
|
end
|
188
|
-
|
201
|
+
|
189
202
|
context "personal_names" do
|
190
203
|
before(:all) do
|
191
204
|
@pers_name = 'Crusty'
|
@@ -193,7 +206,7 @@ describe "Mods::Record" do
|
|
193
206
|
@pers_role = 'creator'
|
194
207
|
@mods_w_pers_name_role = "<mods #{@def_ns_decl}><name type='personal'><namePart>#{@pers_name}</namePart>"
|
195
208
|
@given_family = '<mods xmlns="http://www.loc.gov/mods/v3"><name type="personal"><namePart type="given">Jorge Luis</namePart>
|
196
|
-
<namePart type="family">Borges</namePart></name></mods>'
|
209
|
+
<namePart type="family">Borges</namePart></name></mods>'
|
197
210
|
@given_family_date = '<mods xmlns="http://www.loc.gov/mods/v3"><name type="personal"><namePart type="given">Zaphod</namePart>
|
198
211
|
<namePart type="family">Beeblebrox</namePart>
|
199
212
|
<namePart type="date">1912-2362</namePart></name></mods>'
|
@@ -218,7 +231,7 @@ describe "Mods::Record" do
|
|
218
231
|
it "should prefer displayForm over namePart pieces" do
|
219
232
|
display_form_and_name_parts = '<mods xmlns="http://www.loc.gov/mods/v3"><name type="personal"><namePart type="given">Jorge Luis</namePart>
|
220
233
|
<namePart type="family">Borges</namePart>
|
221
|
-
<displayForm>display form</displayForm></name></mods>'
|
234
|
+
<displayForm>display form</displayForm></name></mods>'
|
222
235
|
@mods_rec.from_str(display_form_and_name_parts)
|
223
236
|
@mods_rec.personal_names.should include("display form")
|
224
237
|
end
|
@@ -244,7 +257,7 @@ describe "Mods::Record" do
|
|
244
257
|
@mods_rec.personal_names.should include("Borges, Jorge Luis")
|
245
258
|
end
|
246
259
|
it "should not include a comma when there is only a family or given name" do
|
247
|
-
[@family_only, @given_only].each { |mods_str|
|
260
|
+
[@family_only, @given_only].each { |mods_str|
|
248
261
|
@mods_rec.from_str(mods_str)
|
249
262
|
@mods_rec.personal_names.first.should_not match(/,/)
|
250
263
|
}
|
@@ -252,13 +265,13 @@ describe "Mods::Record" do
|
|
252
265
|
it "should include terms of address" do
|
253
266
|
@mods_rec.from_str(@all_name_parts)
|
254
267
|
@mods_rec.personal_names.first.should match(/Mr./)
|
255
|
-
end
|
256
|
-
end # personal_names
|
257
|
-
|
268
|
+
end
|
269
|
+
end # personal_names
|
270
|
+
|
258
271
|
context "personal_names_w_dates" do
|
259
272
|
before(:all) do
|
260
273
|
@given_family = '<mods xmlns="http://www.loc.gov/mods/v3"><name type="personal"><namePart type="given">Jorge Luis</namePart>
|
261
|
-
<namePart type="family">Borges</namePart></name></mods>'
|
274
|
+
<namePart type="family">Borges</namePart></name></mods>'
|
262
275
|
@given_family_date = '<mods xmlns="http://www.loc.gov/mods/v3"><name type="personal"><namePart type="given">Zaphod</namePart>
|
263
276
|
<namePart type="family">Beeblebrox</namePart>
|
264
277
|
<namePart type="date">1912-2362</namePart></name></mods>'
|
@@ -276,13 +289,13 @@ describe "Mods::Record" do
|
|
276
289
|
@mods_rec.personal_names_w_dates.first.should match(/, 1912-2362$/)
|
277
290
|
@mods_rec.from_str(@all_name_parts)
|
278
291
|
@mods_rec.personal_names_w_dates.first.should match(/, date$/)
|
279
|
-
end
|
292
|
+
end
|
280
293
|
it "should be just the personal_name if no date is available" do
|
281
294
|
@mods_rec.from_str(@given_family)
|
282
295
|
@mods_rec.personal_names_w_dates.first.should == 'Borges, Jorge Luis'
|
283
296
|
end
|
284
297
|
end
|
285
|
-
|
298
|
+
|
286
299
|
context "corporate_names" do
|
287
300
|
before(:all) do
|
288
301
|
@corp_name = 'ABC corp'
|
@@ -295,18 +308,18 @@ describe "Mods::Record" do
|
|
295
308
|
corp_role = 'lithographer'
|
296
309
|
mods_w_corp_name_role = "<mods #{@def_ns_decl}><name type='corporate'><namePart>#{@corp_name}</namePart>
|
297
310
|
<role><roleTerm type='text'>#{corp_role}</roleTerm></role></name></mods>"
|
298
|
-
@mods_rec.from_str(mods_w_corp_name_role)
|
311
|
+
@mods_rec.from_str(mods_w_corp_name_role)
|
299
312
|
@mods_rec.corporate_names.first.should_not match(corp_role)
|
300
313
|
end
|
301
314
|
|
302
315
|
it "should prefer displayForm over namePart pieces" do
|
303
316
|
display_form_and_name_parts = "<mods #{@def_ns_decl}><name type='corporate'><namePart>Food, Inc.</namePart>
|
304
|
-
<displayForm>display form</displayForm></name></mods>"
|
317
|
+
<displayForm>display form</displayForm></name></mods>"
|
305
318
|
@mods_rec.from_str(display_form_and_name_parts)
|
306
319
|
@mods_rec.corporate_names.should include("display form")
|
307
320
|
end
|
308
321
|
end # corporate_names
|
309
|
-
|
322
|
+
|
310
323
|
context "languages" do
|
311
324
|
before(:all) do
|
312
325
|
@simple = "<mods #{@def_ns_decl}><language>Greek</language></mods>"
|