mods 0.0.23 → 1.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 +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/related_item_spec.rb
CHANGED
@@ -5,13 +5,13 @@ describe "Mods <relatedItem> Element" do
|
|
5
5
|
@mods_rec = Mods::Record.new
|
6
6
|
@ns_decl = "xmlns='#{Mods::MODS_NS}'"
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should associate the right pieces with the right <relatedItem> elements" do
|
10
|
-
|
10
|
+
skip "to be implemented (Mods::RelatedItem object)"
|
11
11
|
end
|
12
12
|
|
13
13
|
context "basic <related_item> terminology pieces" do
|
14
|
-
|
14
|
+
|
15
15
|
context "WITH namespaces" do
|
16
16
|
before(:all) do
|
17
17
|
@rel_it1 = @mods_rec.from_str("<mods #{@ns_decl}><relatedItem displayLabel='Bibliography' type='host'>
|
@@ -57,7 +57,7 @@ describe "Mods <relatedItem> Element" do
|
|
57
57
|
<typeOfResource collection='yes'/>
|
58
58
|
</relatedItem></mods>").related_item
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
it ".relatedItem should be a NodeSet" do
|
62
62
|
[@rel_it1, @rel_it_mult, @rel_it2, @coll_ex].each { |ri| ri.should be_an_instance_of(Nokogiri::XML::NodeSet) }
|
63
63
|
end
|
@@ -74,7 +74,7 @@ describe "Mods <relatedItem> Element" do
|
|
74
74
|
[@rel_it1, @rel_it_mult, @coll_ex].each { |ri| ri.id_at.size.should == 0 }
|
75
75
|
end
|
76
76
|
it "relatedItem.displayLabel should match displayLabel attribute" do
|
77
|
-
@rel_it1.displayLabel.should == ['Bibliography']
|
77
|
+
@rel_it1.displayLabel.should == ['Bibliography']
|
78
78
|
@rel_it_mult.displayLabel.should == ['From:']
|
79
79
|
[@rel_it2, @coll_ex].each { |ri| ri.displayLabel.size.should == 0 }
|
80
80
|
end
|
@@ -134,7 +134,7 @@ describe "Mods <relatedItem> Element" do
|
|
134
134
|
it "relatedItem.recordInfo.recordIdentifier.source should match <relatedItem><recordInfo><recordIdentifier source> attribute" do
|
135
135
|
@rel_it1.recordInfo.recordIdentifier.source.should == ['Gallica ARK']
|
136
136
|
end
|
137
|
-
end # <recordInfo> child element
|
137
|
+
end # <recordInfo> child element
|
138
138
|
|
139
139
|
context "<titleInfo> child element" do
|
140
140
|
it "relatedItem.titleInfo.title should access <relatedItem><titleInfo><title>" do
|
@@ -142,7 +142,7 @@ describe "Mods <relatedItem> Element" do
|
|
142
142
|
@rel_it_mult.titleInfo.title.map { |n| n.text }.should == ['Complete atlas, or, Distinct view of the known world', 'Complete atlas, or, Distinct view of the known world']
|
143
143
|
@rel_it2.titleInfo.title.map { |n| n.text }.should == ['Nuppineula.']
|
144
144
|
@coll_ex.titleInfo.title.map { |n| n.text }.should == ['The Collier Collection of the Revs Institute for Automotive Research']
|
145
|
-
end
|
145
|
+
end
|
146
146
|
end # <titleInfo> child element
|
147
147
|
|
148
148
|
context "<typeOfResource> child element" do
|
@@ -153,9 +153,9 @@ describe "Mods <relatedItem> Element" do
|
|
153
153
|
@coll_ex.typeOfResource.collection.should == ['yes']
|
154
154
|
end
|
155
155
|
end # <typeOfResource> child element
|
156
|
-
|
156
|
+
|
157
157
|
end # WITH namespaces
|
158
|
-
|
158
|
+
|
159
159
|
context "WITHOUT namespaces" do
|
160
160
|
before(:all) do
|
161
161
|
@rel_it1 = @mods_rec.from_str("<mods><relatedItem displayLabel='Bibliography' type='host'>
|
@@ -201,7 +201,7 @@ describe "Mods <relatedItem> Element" do
|
|
201
201
|
<typeOfResource collection='yes'/>
|
202
202
|
</relatedItem></mods>", false).related_item
|
203
203
|
end
|
204
|
-
|
204
|
+
|
205
205
|
it ".relatedItem should be a NodeSet" do
|
206
206
|
[@rel_it1, @rel_it_mult, @rel_it2, @coll_ex].each { |ri| ri.should be_an_instance_of(Nokogiri::XML::NodeSet) }
|
207
207
|
end
|
@@ -218,7 +218,7 @@ describe "Mods <relatedItem> Element" do
|
|
218
218
|
[@rel_it1, @rel_it_mult, @coll_ex].each { |ri| ri.id_at.size.should == 0 }
|
219
219
|
end
|
220
220
|
it "relatedItem.displayLabel should match displayLabel attribute" do
|
221
|
-
@rel_it1.displayLabel.should == ['Bibliography']
|
221
|
+
@rel_it1.displayLabel.should == ['Bibliography']
|
222
222
|
@rel_it_mult.displayLabel.should == ['From:']
|
223
223
|
[@rel_it2, @coll_ex].each { |ri| ri.displayLabel.size.should == 0 }
|
224
224
|
end
|
@@ -278,7 +278,7 @@ describe "Mods <relatedItem> Element" do
|
|
278
278
|
it "relatedItem.recordInfo.recordIdentifier.source should match <relatedItem><recordInfo><recordIdentifier source> attribute" do
|
279
279
|
@rel_it1.recordInfo.recordIdentifier.source.should == ['Gallica ARK']
|
280
280
|
end
|
281
|
-
end # <recordInfo> child element
|
281
|
+
end # <recordInfo> child element
|
282
282
|
|
283
283
|
context "<titleInfo> child element" do
|
284
284
|
it "relatedItem.titleInfo.title should access <relatedItem><titleInfo><title>" do
|
@@ -286,7 +286,7 @@ describe "Mods <relatedItem> Element" do
|
|
286
286
|
@rel_it_mult.titleInfo.title.map { |n| n.text }.should == ['Complete atlas, or, Distinct view of the known world', 'Complete atlas, or, Distinct view of the known world']
|
287
287
|
@rel_it2.titleInfo.title.map { |n| n.text }.should == ['Nuppineula.']
|
288
288
|
@coll_ex.titleInfo.title.map { |n| n.text }.should == ['The Collier Collection of the Revs Institute for Automotive Research']
|
289
|
-
end
|
289
|
+
end
|
290
290
|
end # <titleInfo> child element
|
291
291
|
|
292
292
|
context "<typeOfResource> child element" do
|
@@ -297,9 +297,9 @@ describe "Mods <relatedItem> Element" do
|
|
297
297
|
@coll_ex.typeOfResource.collection.should == ['yes']
|
298
298
|
end
|
299
299
|
end # <typeOfResource> child element
|
300
|
-
|
300
|
+
|
301
301
|
end # WITHOUT namespaces
|
302
|
-
|
302
|
+
|
303
303
|
end # basic <related_item> terminology pieces
|
304
304
|
|
305
|
-
end
|
305
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'simplecov-rcov'
|
4
|
-
class SimpleCov::Formatter::MergedFormatter
|
5
|
-
def format(result)
|
6
|
-
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
7
|
-
SimpleCov::Formatter::RcovFormatter.new.format(result)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
|
11
|
-
SimpleCov.start do
|
12
|
-
add_filter "/spec/"
|
13
|
-
end
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
14
3
|
|
15
4
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
16
5
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
data/spec/subject_spec.rb
CHANGED
@@ -9,21 +9,21 @@ describe "Mods <subject> Element" do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should do something intelligent with duplicate values" do
|
12
|
-
|
12
|
+
skip "to be implemented"
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should do some date parsing of temporal element based on encoding" do
|
16
|
-
|
16
|
+
skip "to be implemented"
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "authority designation on the <subject> element should trickle down to child elements" do
|
20
|
-
|
20
|
+
skip "to be implemented"
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should subject personal name dates should be cleaned up???" do
|
24
|
-
|
24
|
+
skip "to be implemented"
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
context "subterms for <name> child elements of <subject> element" do
|
28
28
|
before(:all) do
|
29
29
|
@both_types_sub = @mods_rec.from_str("<mods #{@ns_decl}><subject>
|
@@ -103,15 +103,15 @@ describe "Mods <subject> Element" do
|
|
103
103
|
@mult_pers_name_sub.personal_name.date.map { |e| e.text }.should include("1818-1878")
|
104
104
|
end
|
105
105
|
it "should do the appropriate thing with the role for the value of a name" do
|
106
|
-
|
106
|
+
skip "name objects to be implemented"
|
107
107
|
end
|
108
108
|
it "should do the appropriate thing with the date for the value of a name" do
|
109
|
-
|
109
|
+
skip "name objects to be implemented"
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
113
|
context "basic subject terminology pieces" do
|
114
|
-
|
114
|
+
|
115
115
|
context "WITH namespaces" do
|
116
116
|
before(:all) do
|
117
117
|
@four_subjects = @mods_rec.from_str("<mods #{@ns_decl}><subject authority='lcsh'>
|
@@ -137,7 +137,7 @@ describe "Mods <subject> Element" do
|
|
137
137
|
@lcsh_subject = @mods_rec.from_str("<mods #{@ns_decl}><subject authority='lcsh'>
|
138
138
|
<geographic>Africa</geographic>
|
139
139
|
<genre>Maps</genre>
|
140
|
-
<temporal>500-1400</temporal></subject></mods>").subject
|
140
|
+
<temporal>500-1400</temporal></subject></mods>").subject
|
141
141
|
end
|
142
142
|
|
143
143
|
it "should be a NodeSet" do
|
@@ -149,7 +149,7 @@ describe "Mods <subject> Element" do
|
|
149
149
|
@lcsh_subject.size.should == 1
|
150
150
|
end
|
151
151
|
it "should recognize authority attribute on <subject> element" do
|
152
|
-
['lcsh', 'ingest', 'lctgm'].each { |a|
|
152
|
+
['lcsh', 'ingest', 'lctgm'].each { |a|
|
153
153
|
@mods_rec.from_str("<mods #{@ns_decl}><subject authority='#{a}'><topic>Ruler, English.</topic></subject></mods>").subject.authority.should == [a]
|
154
154
|
}
|
155
155
|
end
|
@@ -210,12 +210,12 @@ describe "Mods <subject> Element" do
|
|
210
210
|
@temporal = @mods_rec.from_str("<mods #{@ns_decl}><subject>
|
211
211
|
<temporal encoding='iso8601'>20010203T040506+0700</temporal>
|
212
212
|
<!-- <temporal encoding='iso8601'>197505</temporal> -->
|
213
|
-
</subject></mods>").subject.temporal
|
213
|
+
</subject></mods>").subject.temporal
|
214
214
|
end
|
215
215
|
|
216
216
|
it "should recognize the date attributes" do
|
217
217
|
@temporal.encoding.should == ['iso8601']
|
218
|
-
Mods::DATE_ATTRIBS.each { |a|
|
218
|
+
Mods::DATE_ATTRIBS.each { |a|
|
219
219
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><temporal #{a}='val'>now</temporal></subject></mods>").subject.temporal.send(a.to_sym).should == ['val']
|
220
220
|
}
|
221
221
|
end
|
@@ -259,22 +259,22 @@ describe "Mods <subject> Element" do
|
|
259
259
|
@geo_code_subject.geographicCode.map { |n| n.text }.should == ['f------']
|
260
260
|
end
|
261
261
|
it "should recognize authority attributes" do
|
262
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
262
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
263
263
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><geographicCode #{a}='attr_val'>f------</geographicCode></subject></mods>")
|
264
264
|
@mods_rec.subject.geographicCode.send(a.to_sym).should == ['attr_val']
|
265
265
|
}
|
266
266
|
end
|
267
267
|
it "should recognize the sanctioned authorities" do
|
268
|
-
Mods::Subject::GEO_CODE_AUTHORITIES.each { |a|
|
268
|
+
Mods::Subject::GEO_CODE_AUTHORITIES.each { |a|
|
269
269
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><geographicCode authority='#{a}'>f------</geographicCode></subject></mods>")
|
270
270
|
@mods_rec.subject.geographicCode.authority.should == [a]
|
271
271
|
}
|
272
272
|
end
|
273
273
|
it "should not recognize unsanctioned authorities?" do
|
274
274
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><geographicCode authority='fake'>f------</geographicCode></subject></mods>")
|
275
|
-
|
275
|
+
skip "to be implemented"
|
276
276
|
expect { @mods_rec.subject.geographicCode.authority }.to raise_error(/no idea/)
|
277
|
-
end
|
277
|
+
end
|
278
278
|
context "translated_value convenience method" do
|
279
279
|
it "should be the translation of the code if it is a marcgac code" do
|
280
280
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><geographicCode authority='marcgac'>e-er</geographicCode></subject></mods>")
|
@@ -320,7 +320,7 @@ describe "Mods <subject> Element" do
|
|
320
320
|
}
|
321
321
|
end
|
322
322
|
it "should understand all immediate child elements allowed on a <titleInfo> element" do
|
323
|
-
Mods::TitleInfo::CHILD_ELEMENTS.each { |e|
|
323
|
+
Mods::TitleInfo::CHILD_ELEMENTS.each { |e|
|
324
324
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><titleInfo><#{e}>el_val</#{e}></titleInfo></subject></mods>").subject.titleInfo.send(e.to_sym).text.should == 'el_val'
|
325
325
|
}
|
326
326
|
@title_info.nonSort.map {|n| n.text}.should == ["The"]
|
@@ -346,7 +346,7 @@ describe "Mods <subject> Element" do
|
|
346
346
|
}
|
347
347
|
end
|
348
348
|
it "should understand all immediate child elements allowed on a <name> element" do
|
349
|
-
Mods::Name::CHILD_ELEMENTS.each { |e|
|
349
|
+
Mods::Name::CHILD_ELEMENTS.each { |e|
|
350
350
|
name = @mods_rec.from_str("<mods #{@ns_decl}><subject><name><#{e}>el_val</#{e}></name></subject></mods>").subject.name_el
|
351
351
|
if (e == 'description')
|
352
352
|
name.description_el.text.should == 'el_val'
|
@@ -366,13 +366,13 @@ describe "Mods <subject> Element" do
|
|
366
366
|
|
367
367
|
context "<hiearchicalGeographic> child element" do
|
368
368
|
it "should recognize authority attributes" do
|
369
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
369
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
370
370
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><hierarchicalGeographic #{a}='attr_val'><country>Albania</country></hierarchicalGeographic></subject></mods>")
|
371
371
|
@mods_rec.subject.hierarchicalGeographic.send(a.to_sym).should == ['attr_val']
|
372
372
|
}
|
373
373
|
end
|
374
374
|
it "should recognize allowed child elements" do
|
375
|
-
Mods::Subject::HIER_GEO_CHILD_ELEMENTS.each { |e|
|
375
|
+
Mods::Subject::HIER_GEO_CHILD_ELEMENTS.each { |e|
|
376
376
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><hierarchicalGeographic><#{e}>el_val</#{e}></hierarchicalGeographic></subject></mods>")
|
377
377
|
@mods_rec.subject.hierarchicalGeographic.send(e.to_sym).text.should == 'el_val'
|
378
378
|
}
|
@@ -418,7 +418,7 @@ describe "Mods <subject> Element" do
|
|
418
418
|
@multi_carto.size.should == 3
|
419
419
|
end
|
420
420
|
it "should recognize allowed child elements" do
|
421
|
-
Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |e|
|
421
|
+
Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |e|
|
422
422
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><cartographics><#{e}>el_val</#{e}></cartographics></subject></mods>")
|
423
423
|
@mods_rec.subject.cartographics.send(e.to_sym).text.should == 'el_val'
|
424
424
|
}
|
@@ -450,14 +450,14 @@ describe "Mods <subject> Element" do
|
|
450
450
|
@occupation.map { |n| n.text }.should == ['Migrant laborers']
|
451
451
|
end
|
452
452
|
it "should recognize authority attributes" do
|
453
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
453
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
454
454
|
@mods_rec.from_str("<mods #{@ns_decl}><subject><occupation #{a}='attr_val'>Flunkie</occupation></subject></mods>")
|
455
455
|
@mods_rec.subject.occupation.send(a.to_sym).should == ['attr_val']
|
456
456
|
}
|
457
457
|
end
|
458
458
|
end # <occupation>
|
459
459
|
end # WITH namespaces
|
460
|
-
|
460
|
+
|
461
461
|
context "WITHOUT namespaces" do
|
462
462
|
before(:all) do
|
463
463
|
@four_subjects = @mods_rec.from_str("<mods><subject authority='lcsh'>
|
@@ -483,7 +483,7 @@ describe "Mods <subject> Element" do
|
|
483
483
|
@lcsh_subject = @mods_rec.from_str("<mods><subject authority='lcsh'>
|
484
484
|
<geographic>Africa</geographic>
|
485
485
|
<genre>Maps</genre>
|
486
|
-
<temporal>500-1400</temporal></subject></mods>", false).subject
|
486
|
+
<temporal>500-1400</temporal></subject></mods>", false).subject
|
487
487
|
end
|
488
488
|
|
489
489
|
it "should be a NodeSet" do
|
@@ -495,7 +495,7 @@ describe "Mods <subject> Element" do
|
|
495
495
|
@lcsh_subject.size.should == 1
|
496
496
|
end
|
497
497
|
it "should recognize authority attribute on <subject> element" do
|
498
|
-
['lcsh', 'ingest', 'lctgm'].each { |a|
|
498
|
+
['lcsh', 'ingest', 'lctgm'].each { |a|
|
499
499
|
@mods_rec.from_str("<mods><subject authority='#{a}'><topic>Ruler, English.</topic></subject></mods>", false).subject.authority.should == [a]
|
500
500
|
}
|
501
501
|
end
|
@@ -556,12 +556,12 @@ describe "Mods <subject> Element" do
|
|
556
556
|
@temporal = @mods_rec.from_str("<mods><subject>
|
557
557
|
<temporal encoding='iso8601'>20010203T040506+0700</temporal>
|
558
558
|
<!-- <temporal encoding='iso8601'>197505</temporal> -->
|
559
|
-
</subject></mods>", false).subject.temporal
|
559
|
+
</subject></mods>", false).subject.temporal
|
560
560
|
end
|
561
561
|
|
562
562
|
it "should recognize the date attributes" do
|
563
563
|
@temporal.encoding.should == ['iso8601']
|
564
|
-
Mods::DATE_ATTRIBS.each { |a|
|
564
|
+
Mods::DATE_ATTRIBS.each { |a|
|
565
565
|
@mods_rec.from_str("<mods><subject><temporal #{a}='val'>now</temporal></subject></mods>", false).subject.temporal.send(a.to_sym).should == ['val']
|
566
566
|
}
|
567
567
|
end
|
@@ -605,20 +605,20 @@ describe "Mods <subject> Element" do
|
|
605
605
|
@geo_code_subject.geographicCode.map { |n| n.text }.should == ['f------']
|
606
606
|
end
|
607
607
|
it "should recognize authority attributes" do
|
608
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
608
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
609
609
|
@mods_rec.from_str("<mods><subject><geographicCode #{a}='attr_val'>f------</geographicCode></subject></mods>", false)
|
610
610
|
@mods_rec.subject.geographicCode.send(a.to_sym).should == ['attr_val']
|
611
611
|
}
|
612
612
|
end
|
613
613
|
it "should recognize the sanctioned authorities" do
|
614
|
-
Mods::Subject::GEO_CODE_AUTHORITIES.each { |a|
|
614
|
+
Mods::Subject::GEO_CODE_AUTHORITIES.each { |a|
|
615
615
|
@mods_rec.from_str("<mods><subject><geographicCode authority='#{a}'>f------</geographicCode></subject></mods>", false)
|
616
616
|
@mods_rec.subject.geographicCode.authority.should == [a]
|
617
617
|
}
|
618
618
|
end
|
619
619
|
it "should not recognize unsanctioned authorities?" do
|
620
620
|
@mods_rec.from_str("<mods><subject><geographicCode authority='fake'>f------</geographicCode></subject></mods>", false)
|
621
|
-
|
621
|
+
skip "to be implemented"
|
622
622
|
expect { @mods_rec.subject.geographicCode.authority }.to raise_error(/no idea/)
|
623
623
|
end
|
624
624
|
context "translated_value convenience method" do
|
@@ -666,7 +666,7 @@ describe "Mods <subject> Element" do
|
|
666
666
|
}
|
667
667
|
end
|
668
668
|
it "should understand all immediate child elements allowed on a <titleInfo> element" do
|
669
|
-
Mods::TitleInfo::CHILD_ELEMENTS.each { |e|
|
669
|
+
Mods::TitleInfo::CHILD_ELEMENTS.each { |e|
|
670
670
|
@mods_rec.from_str("<mods><subject><titleInfo><#{e}>el_val</#{e}></titleInfo></subject></mods>", false).subject.titleInfo.send(e.to_sym).text.should == 'el_val'
|
671
671
|
}
|
672
672
|
@title_info.nonSort.map {|n| n.text}.should == ["The"]
|
@@ -692,7 +692,7 @@ describe "Mods <subject> Element" do
|
|
692
692
|
}
|
693
693
|
end
|
694
694
|
it "should understand all immediate child elements allowed on a <name> element" do
|
695
|
-
Mods::Name::CHILD_ELEMENTS.each { |e|
|
695
|
+
Mods::Name::CHILD_ELEMENTS.each { |e|
|
696
696
|
name = @mods_rec.from_str("<mods><subject><name><#{e}>el_val</#{e}></name></subject></mods>", false).subject.name_el
|
697
697
|
if (e == 'description')
|
698
698
|
name.description_el.text.should == 'el_val'
|
@@ -712,13 +712,13 @@ describe "Mods <subject> Element" do
|
|
712
712
|
|
713
713
|
context "<hiearchicalGeographic> child element" do
|
714
714
|
it "should recognize authority attributes" do
|
715
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
715
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
716
716
|
@mods_rec.from_str("<mods><subject><hierarchicalGeographic #{a}='attr_val'><country>Albania</country></hierarchicalGeographic></subject></mods>", false)
|
717
717
|
@mods_rec.subject.hierarchicalGeographic.send(a.to_sym).should == ['attr_val']
|
718
718
|
}
|
719
719
|
end
|
720
720
|
it "should recognize allowed child elements" do
|
721
|
-
Mods::Subject::HIER_GEO_CHILD_ELEMENTS.each { |e|
|
721
|
+
Mods::Subject::HIER_GEO_CHILD_ELEMENTS.each { |e|
|
722
722
|
@mods_rec.from_str("<mods><subject><hierarchicalGeographic><#{e}>el_val</#{e}></hierarchicalGeographic></subject></mods>", false)
|
723
723
|
@mods_rec.subject.hierarchicalGeographic.send(e.to_sym).text.should == 'el_val'
|
724
724
|
}
|
@@ -764,7 +764,7 @@ describe "Mods <subject> Element" do
|
|
764
764
|
@multi_carto.size.should == 3
|
765
765
|
end
|
766
766
|
it "should recognize allowed child elements" do
|
767
|
-
Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |e|
|
767
|
+
Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |e|
|
768
768
|
@mods_rec.from_str("<mods><subject><cartographics><#{e}>el_val</#{e}></cartographics></subject></mods>", false)
|
769
769
|
@mods_rec.subject.cartographics.send(e.to_sym).text.should == 'el_val'
|
770
770
|
}
|
@@ -796,14 +796,14 @@ describe "Mods <subject> Element" do
|
|
796
796
|
@occupation.map { |n| n.text }.should == ['Migrant laborers']
|
797
797
|
end
|
798
798
|
it "should recognize authority attributes" do
|
799
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
799
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
800
800
|
@mods_rec.from_str("<mods><subject><occupation #{a}='attr_val'>Flunkie</occupation></subject></mods>", false)
|
801
801
|
@mods_rec.subject.occupation.send(a.to_sym).should == ['attr_val']
|
802
802
|
}
|
803
803
|
end
|
804
804
|
end # <occupation>
|
805
805
|
end # WITHOUT namespaces
|
806
|
-
|
806
|
+
|
807
807
|
end # basic subject terminology
|
808
|
-
|
809
|
-
end
|
808
|
+
|
809
|
+
end
|
@@ -5,13 +5,13 @@ describe "Mods Top Level Elements that do not have Child Elements" do
|
|
5
5
|
before(:all) do
|
6
6
|
@mods_rec = Mods::Record.new
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should deal with camelcase vs. ruby underscore convention" do
|
10
|
-
|
10
|
+
skip "need to implement ruby style version of (element/attribute) method names"
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should get the text contents of any single complex top level element instance with no child elements" do
|
14
|
-
|
14
|
+
skip "to be implemented"
|
15
15
|
Mods::TOP_LEVEL_ELEMENTS_COMPLEX.each { |elname|
|
16
16
|
@mods_rec.from_str("<mods><#{elname}>hi</#{elname}></mods>", false)
|
17
17
|
@mods_rec.send(elname.to_sym).map { |e| e.text }.should == ["hi"]
|
@@ -30,7 +30,7 @@ describe "Mods Top Level Elements that do not have Child Elements" do
|
|
30
30
|
it "should return an array of strings when there are multiple occurrences of simple top level elements" do
|
31
31
|
@mods_rec.from_str('<mods><note>hi</note><note>hello</note></mods>', false).note.map { |e| e.text }.should == ["hi", "hello"]
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
context "<abstract> child element" do
|
35
35
|
it ".abstract.displayLabel should be an accessor for displayLabel attribute on abstract element: <abstract displayLabel='foo'>" do
|
36
36
|
@mods_rec.from_str('<mods><abstract displayLabel="Summary">blah blah blah</abstract></mods>', false)
|
@@ -68,7 +68,7 @@ describe "Mods Top Level Elements that do not have Child Elements" do
|
|
68
68
|
@class1.edition.should == ['11']
|
69
69
|
end
|
70
70
|
it "should recognize all authority attributes" do
|
71
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
71
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
72
72
|
@mods_rec.from_str("<mods><classification #{a}='attr_val'>zzz</classification></mods>", false)
|
73
73
|
@mods_rec.classification.send(a.to_sym).should == ['attr_val']
|
74
74
|
}
|
@@ -101,7 +101,7 @@ describe "Mods Top Level Elements that do not have Child Elements" do
|
|
101
101
|
@mods_rec.genre.usage.should == ['fer sure']
|
102
102
|
end
|
103
103
|
it "should recognize all authority attributes" do
|
104
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
104
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
105
105
|
@mods_rec.from_str("<mods><genre #{a}='attr_val'>zzz</genre></mods>", false)
|
106
106
|
@mods_rec.genre.send(a.to_sym).should == ['attr_val']
|
107
107
|
}
|
@@ -160,7 +160,7 @@ describe "Mods Top Level Elements that do not have Child Elements" do
|
|
160
160
|
@mods_rec.targetAudience.displayLabel.should == ['ta da']
|
161
161
|
end
|
162
162
|
it "should recognize all authority attributes" do
|
163
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
163
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
164
164
|
@mods_rec.from_str("<mods><targetAudience #{a}='attr_val'>zzz</targetAudience></mods>", false)
|
165
165
|
@mods_rec.targetAudience.send(a.to_sym).should == ['attr_val']
|
166
166
|
}
|
@@ -188,9 +188,9 @@ describe "Mods Top Level Elements that do not have Child Elements" do
|
|
188
188
|
@mods_rec.typeOfResource.usage.should == ['fer sure']
|
189
189
|
end
|
190
190
|
end
|
191
|
-
|
191
|
+
|
192
192
|
end # context without namespaces
|
193
|
-
|
193
|
+
|
194
194
|
context "parsing with namespaces" do
|
195
195
|
|
196
196
|
before(:all) do
|
@@ -245,7 +245,7 @@ describe "Mods Top Level Elements that do not have Child Elements" do
|
|
245
245
|
@class1.edition.should == ['11']
|
246
246
|
end
|
247
247
|
it "should recognize all authority attributes" do
|
248
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
248
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
249
249
|
@mods_rec.from_str(@mods_el_w_ns + "<classification #{a}='attr_val'>zzz</classification></mods>")
|
250
250
|
@mods_rec.classification.send(a.to_sym).should == ['attr_val']
|
251
251
|
}
|
@@ -278,7 +278,7 @@ describe "Mods Top Level Elements that do not have Child Elements" do
|
|
278
278
|
@mods_rec.genre.usage.should == ['fer sure']
|
279
279
|
end
|
280
280
|
it "should recognize all authority attributes" do
|
281
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
281
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
282
282
|
@mods_rec.from_str(@mods_el_w_ns + "<genre #{a}='attr_val'>zzz</genre></mods>")
|
283
283
|
@mods_rec.genre.send(a.to_sym).should == ['attr_val']
|
284
284
|
}
|
@@ -337,7 +337,7 @@ describe "Mods Top Level Elements that do not have Child Elements" do
|
|
337
337
|
@mods_rec.targetAudience.displayLabel.should == ['ta da']
|
338
338
|
end
|
339
339
|
it "should recognize all authority attributes" do
|
340
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
340
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
341
341
|
@mods_rec.from_str(@mods_el_w_ns + "<targetAudience #{a}='attr_val'>zzz</targetAudience></mods>")
|
342
342
|
@mods_rec.targetAudience.send(a.to_sym).should == ['attr_val']
|
343
343
|
}
|
@@ -362,8 +362,8 @@ describe "Mods Top Level Elements that do not have Child Elements" do
|
|
362
362
|
@mods_rec.typeOfResource.usage.should == ['fer sure']
|
363
363
|
end
|
364
364
|
end
|
365
|
-
|
365
|
+
|
366
366
|
end # parsing with namespaces
|
367
|
-
|
368
|
-
|
369
|
-
end
|
367
|
+
|
368
|
+
|
369
|
+
end
|