mods 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +6 -2
- data/lib/mods.rb +12 -2
- data/lib/mods/constants.rb +60 -0
- data/lib/mods/marc_relator_codes.rb +228 -0
- data/lib/mods/name.rb +18 -0
- data/lib/mods/nom_terminology.rb +221 -0
- data/lib/mods/reader.rb +41 -0
- data/lib/mods/record.rb +145 -0
- data/lib/mods/title_info.rb +24 -0
- data/lib/mods/version.rb +2 -1
- data/mods.gemspec +12 -6
- data/spec/language_spec.rb +69 -0
- data/spec/location_spec.rb +148 -0
- data/spec/name_spec.rb +257 -0
- data/spec/origin_info_spec.rb +311 -0
- data/spec/physical_description_spec.rb +79 -0
- data/spec/reader_spec.rb +50 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/title_spec.rb +111 -0
- data/spec/top_level_elmnts_simple_spec.rb +32 -0
- metadata +69 -10
data/spec/name_spec.rb
ADDED
@@ -0,0 +1,257 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Mods <name> Element" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@mods_rec = Mods::Record.new
|
7
|
+
@corp_name = 'ABC corp'
|
8
|
+
@mods_w_corp_name = "<mods><name type='corporate'><namePart>#{@corp_name}</namePart></name></mods>"
|
9
|
+
@mods_w_corp_name_role = "<mods><name type='corporate'><namePart>#{@corp_name}</namePart>
|
10
|
+
<role><roleTerm type='text'>lithographer</roleTerm></role></name></mods>"
|
11
|
+
@pers_name = 'Crusty'
|
12
|
+
@mods_w_pers_name = "<mods><name type='personal'><namePart>#{@pers_name}</namePart></name></mods>"
|
13
|
+
@mods_w_both = "<mods>
|
14
|
+
<name type='corporate'><namePart>#{@corp_name}</namePart></name>
|
15
|
+
<name type='personal'><namePart>#{@pers_name}</namePart></name></mods>"
|
16
|
+
@pers_role = 'creator'
|
17
|
+
@mods_w_pers_name_role = "<mods><name type='personal'><namePart>#{@pers_name}</namePart>
|
18
|
+
<role><roleTerm authority='marcrelator' type='text'>#{@pers_role}</roleTerm><role></name></mods>"
|
19
|
+
@mods_w_pers_name_role_code = '<mods><name type="personal"><namePart type="given">John</namePart>
|
20
|
+
<namePart type="family">Huston</namePart>
|
21
|
+
<role>
|
22
|
+
<roleTerm type="code" authority="marcrelator">drt</roleTerm>
|
23
|
+
</role>
|
24
|
+
</name></mods>'
|
25
|
+
end
|
26
|
+
|
27
|
+
context "personal name" do
|
28
|
+
|
29
|
+
it "should recognize child elements" do
|
30
|
+
Mods::Name::SUBELEMENTS.reject{|e| e == "role"}.each { |e|
|
31
|
+
@mods_rec.from_str("<mods><name type='personal'><#{e}>oofda</#{e}></name></mods>")
|
32
|
+
if e == 'description'
|
33
|
+
@mods_rec.personal_name.description_el.text.should == 'oofda'
|
34
|
+
else
|
35
|
+
@mods_rec.personal_name.send(e).text.should == 'oofda'
|
36
|
+
end
|
37
|
+
}
|
38
|
+
end
|
39
|
+
it "should include name elements with type attr = personal" do
|
40
|
+
@mods_rec.from_str(@mods_w_pers_name)
|
41
|
+
@mods_rec.personal_name.namePart.text.should == @pers_name
|
42
|
+
@mods_rec.from_str(@mods_w_both).personal_name.namePart.text.should == @pers_name
|
43
|
+
end
|
44
|
+
it "should not include name elements with type attr != personal" do
|
45
|
+
@mods_rec.from_str(@mods_w_corp_name)
|
46
|
+
@mods_rec.personal_name.namePart.text.should == ""
|
47
|
+
@mods_rec.from_str(@mods_w_both).personal_name.namePart.text.should_not match(@corp_name)
|
48
|
+
end
|
49
|
+
|
50
|
+
context "roles" do
|
51
|
+
it "should be possible to access a personal_name role easily" do
|
52
|
+
@mods_rec.from_str(@mods_w_pers_name_role)
|
53
|
+
@mods_rec.personal_name.role.text.should include(@pers_role)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should get role type" do
|
57
|
+
@mods_rec.from_str(@mods_w_pers_name_role)
|
58
|
+
@mods_rec.personal_name.role.type_at.should == ["text"]
|
59
|
+
@mods_rec.from_str(@mods_w_pers_name_role_code)
|
60
|
+
@mods_rec.personal_name.role.type_at.should == ["code"]
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should get role authority" do
|
64
|
+
@mods_rec.from_str(@mods_w_pers_name_role)
|
65
|
+
@mods_rec.personal_name.role.authority.should == ["marcrelator"]
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
context "Mods::Record.personal_names convenience method" do
|
71
|
+
before(:all) do
|
72
|
+
@given_family = '<mods><name type="personal"><namePart type="given">Jorge Luis</namePart>
|
73
|
+
<namePart type="family">Borges</namePart></name></mods>'
|
74
|
+
@given_family_date = '<mods><name type="personal"><namePart type="given">Zaphod</namePart>
|
75
|
+
<namePart type="family">Beeblebrox</namePart>
|
76
|
+
<namePart type="date">1912-2362</namePart></name></mods>'
|
77
|
+
@all_name_parts = '<mods><name type="personal"><namePart type="given">Given</namePart>
|
78
|
+
<namePart type="family">Family</namePart>
|
79
|
+
<namePart type="termsOfAddress">Mr.</namePart>
|
80
|
+
<namePart type="date">date</namePart></name></mods>'
|
81
|
+
@family_only = '<mods><name type="personal"><namePart type="family">Family</namePart></name></mods>'
|
82
|
+
@given_only = '<mods><name type="personal"><namePart type="given">Given</namePart></name></mods>'
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should return an Array of Strings" do
|
86
|
+
@mods_rec.from_str(@mods_w_pers_name)
|
87
|
+
@mods_rec.personal_names.should == [@pers_name]
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should not include the role text" do
|
91
|
+
@mods_rec.from_str(@mods_w_pers_name_role)
|
92
|
+
@mods_rec.personal_names.first.should_not match(@pers_role)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should prefer displayForm over namePart pieces" do
|
96
|
+
display_form_and_name_parts = '<mods><name type="personal"><namePart type="given">Jorge Luis</namePart>
|
97
|
+
<namePart type="family">Borges</namePart>
|
98
|
+
<displayForm>display form</displayForm></name></mods>'
|
99
|
+
@mods_rec.from_str(display_form_and_name_parts)
|
100
|
+
@mods_rec.personal_names.should include("display form")
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should put the family namePart first" do
|
104
|
+
@mods_rec.from_str(@given_family)
|
105
|
+
@mods_rec.personal_names.first.should match(/^Borges/)
|
106
|
+
@mods_rec.from_str(@given_family_date)
|
107
|
+
@mods_rec.personal_names.first.should match(/^Beeblebrox/)
|
108
|
+
end
|
109
|
+
it "should not include date" do
|
110
|
+
@mods_rec.from_str(@given_family_date)
|
111
|
+
@mods_rec.personal_names.first.should_not match(/19/)
|
112
|
+
@mods_rec.from_str(@all_name_parts)
|
113
|
+
@mods_rec.personal_names.first.should_not match('date')
|
114
|
+
end
|
115
|
+
it "should include a comma when there is both a family and a given name" do
|
116
|
+
@mods_rec.from_str(@all_name_parts)
|
117
|
+
@mods_rec.personal_names.should include("Family, Given")
|
118
|
+
end
|
119
|
+
it "should include multiple words in a namePart" do
|
120
|
+
@mods_rec.from_str(@given_family)
|
121
|
+
@mods_rec.personal_names.should include("Borges, Jorge Luis")
|
122
|
+
end
|
123
|
+
it "should not include a comma when there is only a family or given name" do
|
124
|
+
[@family_only, @given_only].each { |mods_str|
|
125
|
+
@mods_rec.from_str(mods_str)
|
126
|
+
@mods_rec.personal_names.first.should_not match(/,/)
|
127
|
+
}
|
128
|
+
end
|
129
|
+
it "should not include terms of address" do
|
130
|
+
@mods_rec.from_str(@all_name_parts)
|
131
|
+
@mods_rec.personal_names.first.should_not match(/Mr./)
|
132
|
+
end
|
133
|
+
end # personal_names convenience method
|
134
|
+
end # personal name
|
135
|
+
|
136
|
+
context "sort_author" do
|
137
|
+
it "should do something" do
|
138
|
+
pending "sort_author to be implemented"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context "corporate name" do
|
143
|
+
before(:all) do
|
144
|
+
@corp_role = 'lithographer'
|
145
|
+
@mods_w_corp_name_role = "<mods><name type='corporate'><namePart>#{@corp_name}</namePart>
|
146
|
+
<role><roleTerm type='text'>#{@corp_role}</roleTerm></role></name></mods>"
|
147
|
+
s = '<mods><name type="corporate"><namePart>Sherman & Smith</namePart>
|
148
|
+
<role><roleTerm authority="marcrelator" type="text">creator</roleTerm></role></name></mods>'
|
149
|
+
@mult_corps = '<mods> <name type="corporate">
|
150
|
+
<namePart>Henry Bill, New York</namePart>
|
151
|
+
<role><roleTerm type="text">publisher</roleTerm></role>
|
152
|
+
</name>
|
153
|
+
<name type="corporate">
|
154
|
+
<namePart>T. Sinclair's, Philadelphia</namePart>
|
155
|
+
<role><roleTerm type="text">lithographer</roleTerm></role>
|
156
|
+
</name>
|
157
|
+
<name type="corporate">
|
158
|
+
<namePart>Potter Collection</namePart>
|
159
|
+
<role><roleTerm type="text">former owner</roleTerm></role>
|
160
|
+
</name></mods>'
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should recognize child elements" do
|
164
|
+
Mods::Name::SUBELEMENTS.reject{|e| e == "role" }.each { |e|
|
165
|
+
@mods_rec.from_str("<mods><name type='corporate'><#{e}>oofda</#{e}></name></mods>")
|
166
|
+
if e == 'description'
|
167
|
+
@mods_rec.corporate_name.description_el.text.should == 'oofda'
|
168
|
+
else
|
169
|
+
@mods_rec.corporate_name.send(e).text.should == 'oofda'
|
170
|
+
end
|
171
|
+
}
|
172
|
+
end
|
173
|
+
it "should include name elements with type attr = corporate" do
|
174
|
+
@mods_rec.from_str(@mods_w_corp_name)
|
175
|
+
@mods_rec.corporate_name.namePart.text.should == @corp_name
|
176
|
+
@mods_rec.from_str(@mods_w_both).corporate_name.namePart.text.should == @corp_name
|
177
|
+
end
|
178
|
+
it "should not include name elements with type attr != corporate" do
|
179
|
+
@mods_rec.from_str(@mods_w_pers_name)
|
180
|
+
@mods_rec.corporate_name.namePart.text.should == ""
|
181
|
+
@mods_rec.from_str(@mods_w_both).corporate_name.namePart.text.should_not match(@pers_name)
|
182
|
+
end
|
183
|
+
|
184
|
+
context "Mods::Record.corporate_names convenience method" do
|
185
|
+
it "should return an Array of Strings" do
|
186
|
+
@mods_rec.from_str(@mods_w_corp_name)
|
187
|
+
@mods_rec.corporate_names.should == [@corp_name]
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should not include the role text" do
|
191
|
+
@mods_rec.from_str(@mods_w_corp_name_role)
|
192
|
+
@mods_rec.corporate_names.first.should_not match(@corp_role)
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should prefer displayForm over namePart pieces" do
|
196
|
+
display_form_and_name_parts = '<mods><name type="corporate"><namePart>Food, Inc.</namePart>
|
197
|
+
<displayForm>display form</displayForm></name></mods>'
|
198
|
+
@mods_rec.from_str(display_form_and_name_parts)
|
199
|
+
@mods_rec.corporate_names.should include("display form")
|
200
|
+
end
|
201
|
+
end # corporate_names convenience method
|
202
|
+
end # corporate name
|
203
|
+
|
204
|
+
context "(plain) <name> element terminology pieces" do
|
205
|
+
|
206
|
+
it "should recognize child elements" do
|
207
|
+
Mods::Name::SUBELEMENTS.reject{|e| e == "role"}.each { |e|
|
208
|
+
@mods_rec.from_str("<mods><name><#{e}>oofda</#{e}></name></mods>")
|
209
|
+
if e == 'description'
|
210
|
+
@mods_rec.plain_name.description_el.text.should == 'oofda'
|
211
|
+
else
|
212
|
+
@mods_rec.plain_name.send(e).text.should == 'oofda'
|
213
|
+
end
|
214
|
+
}
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should recognize attributes on name node" do
|
218
|
+
Mods::Name::ATTRIBUTES.each { |attrb|
|
219
|
+
@mods_rec.from_str("<mods><name #{attrb}='hello'><displayForm>q</displayForm></name></mods>")
|
220
|
+
if attrb != 'type'
|
221
|
+
@mods_rec.plain_name.send(attrb).should == ['hello']
|
222
|
+
else
|
223
|
+
@mods_rec.plain_name.type_at.should == ['hello']
|
224
|
+
end
|
225
|
+
}
|
226
|
+
end
|
227
|
+
|
228
|
+
context "namePart subelement" do
|
229
|
+
it "should recognize type attribute on namePart element" do
|
230
|
+
Mods::Name::NAME_PART_TYPES.each { |t|
|
231
|
+
@mods_rec.from_str("<mods><name><namePart type='#{t}'>hi</namePart></name></mods>")
|
232
|
+
@mods_rec.plain_name.namePart.type_at.text.should == t
|
233
|
+
}
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
context "role subelement" do
|
238
|
+
it "should get role type" do
|
239
|
+
@mods_rec.from_str(@mods_w_pers_name_role)
|
240
|
+
@mods_rec.plain_name.role.type_at.should == ["text"]
|
241
|
+
@mods_rec.from_str(@mods_w_pers_name_role_code)
|
242
|
+
@mods_rec.plain_name.role.type_at.should == ["code"]
|
243
|
+
end
|
244
|
+
|
245
|
+
it "should get role authority" do
|
246
|
+
@mods_rec.from_str(@mods_w_pers_name_role)
|
247
|
+
@mods_rec.plain_name.role.authority.should == ["marcrelator"]
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
end # plain name
|
252
|
+
|
253
|
+
it "should be able to translate the marc relator code into text" do
|
254
|
+
MARC_RELATOR['drt'].should == "Director"
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
@@ -0,0 +1,311 @@
|
|
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
|
+
@kolb = '<mods>
|
8
|
+
<originInfo>
|
9
|
+
<dateCreated>1537-1553.</dateCreated>
|
10
|
+
<dateCreated point="start">1537</dateCreated>
|
11
|
+
<dateCreated point="end">1553</dateCreated>
|
12
|
+
</originInfo></mods>'
|
13
|
+
@reid_dennis = '<mods><originInfo><dateIssued>1852</dateIssued></originInfo></mods>'
|
14
|
+
@walters = '<mods><originInfo>
|
15
|
+
<place>
|
16
|
+
<placeTerm type="text">Iran</placeTerm>
|
17
|
+
</place>
|
18
|
+
<dateIssued>22 Rabīʿ II 889 AH / 1484 CE</dateIssued>
|
19
|
+
<issuance>monographic</issuance>
|
20
|
+
</originInfo>
|
21
|
+
</mods>'
|
22
|
+
@simple = '<mods><originInfo><dateIssued>circa 1900</dateIssued></originInfo></mods>'
|
23
|
+
@ew = '<mods><originInfo>
|
24
|
+
<place>
|
25
|
+
<placeTerm type="text">Reichenau Abbey, Lake Constance, Germany</placeTerm>
|
26
|
+
</place>
|
27
|
+
<dateIssued>Middle of the 11th century CE</dateIssued>
|
28
|
+
<issuance>monographic</issuance>
|
29
|
+
</originInfo>
|
30
|
+
</mods>'
|
31
|
+
@e = '<mods><originInfo>
|
32
|
+
<place>
|
33
|
+
<placeTerm type="code" authority="marccountry">au</placeTerm>
|
34
|
+
</place>
|
35
|
+
<place>
|
36
|
+
<placeTerm type="text">[Austria?</placeTerm>
|
37
|
+
</place>
|
38
|
+
<dateIssued>circa 1180-1199]</dateIssued>
|
39
|
+
<issuance>monographic</issuance>
|
40
|
+
</originInfo></mods>'
|
41
|
+
@f = '<mods> <originInfo>
|
42
|
+
<place>
|
43
|
+
<placeTerm authority="marccountry" type="code">cau</placeTerm>
|
44
|
+
</place>
|
45
|
+
<dateIssued encoding="marc" keyDate="yes" point="start">1850</dateIssued>
|
46
|
+
<dateIssued encoding="marc" point="end">1906</dateIssued>
|
47
|
+
<issuance>monographic</issuance>
|
48
|
+
</originInfo>
|
49
|
+
</mods>'
|
50
|
+
@ex = '<mods><originInfo>
|
51
|
+
<place>
|
52
|
+
<placeTerm>France and Italy</placeTerm>
|
53
|
+
</place>
|
54
|
+
<dateCreated keyDate="yes" qualifier="inferred">173-?</dateCreated>
|
55
|
+
</originInfo>
|
56
|
+
</mods>'
|
57
|
+
@ex1 = '<mods><originInfo>
|
58
|
+
<publisher>Robot Publishing</publisher>
|
59
|
+
<place>
|
60
|
+
<placeTerm>France</placeTerm>
|
61
|
+
</place>
|
62
|
+
<place>
|
63
|
+
<placeTerm>Italy</placeTerm>
|
64
|
+
</place>
|
65
|
+
<dateCreated keyDate="yes" qualifier="inferred">173-?</dateCreated>
|
66
|
+
<dateIssued>1850</dateIssued>
|
67
|
+
</originInfo>
|
68
|
+
</mods>'
|
69
|
+
@ex2 = '<mods><originInfo>
|
70
|
+
<place>
|
71
|
+
<placeTerm type="code" authority="marccountry">enk</placeTerm>
|
72
|
+
</place>
|
73
|
+
<place>
|
74
|
+
<placeTerm type="text">[London]</placeTerm>
|
75
|
+
</place>
|
76
|
+
<publisher>Bunney & Gold</publisher>
|
77
|
+
<dateIssued>1799</dateIssued>
|
78
|
+
<dateIssued encoding="marc" keyDate="yes">1799</dateIssued>
|
79
|
+
<issuance>monographic</issuance>
|
80
|
+
</originInfo>
|
81
|
+
</mods>'
|
82
|
+
@ex3 = '<mods><originInfo>
|
83
|
+
<place>
|
84
|
+
<placeTerm type="code" authority="marccountry">xx</placeTerm>
|
85
|
+
</place>
|
86
|
+
<place>
|
87
|
+
<placeTerm type="text">[s.l. : s.n.]</placeTerm>
|
88
|
+
</place>
|
89
|
+
<dateIssued>1780?]</dateIssued>
|
90
|
+
<dateIssued encoding="marc" keyDate="yes">178u</dateIssued>
|
91
|
+
<issuance>monographic</issuance>
|
92
|
+
</originInfo>
|
93
|
+
</mods>'
|
94
|
+
@ex4 = '<mods><originInfo>
|
95
|
+
<place>
|
96
|
+
<placeTerm type="code" authority="marccountry">fr</placeTerm>
|
97
|
+
</place>
|
98
|
+
<place>
|
99
|
+
<placeTerm type="text">[S.l.]</placeTerm>
|
100
|
+
</place>
|
101
|
+
<publisher>[s.n.]</publisher>
|
102
|
+
<dateIssued>[1740.]</dateIssued>
|
103
|
+
<dateIssued encoding="marc" point="start" qualifier="questionable" keyDate="yes">1740</dateIssued>
|
104
|
+
<dateIssued encoding="marc" point="end" qualifier="questionable">1749</dateIssued>
|
105
|
+
<issuance>monographic</issuance>
|
106
|
+
</originInfo>
|
107
|
+
</mods>'
|
108
|
+
@ex5 = '<mods><originInfo>
|
109
|
+
<place>
|
110
|
+
<placeTerm type="code" authority="marccountry">xx</placeTerm>
|
111
|
+
</place>
|
112
|
+
<place>
|
113
|
+
<placeTerm type="text">[S.l.]</placeTerm>
|
114
|
+
</place>
|
115
|
+
<publisher>Olney</publisher>
|
116
|
+
<dateIssued>1844</dateIssued>
|
117
|
+
<dateIssued encoding="marc" keyDate="yes">1844</dateIssued>
|
118
|
+
<issuance>monographic</issuance>
|
119
|
+
</originInfo>
|
120
|
+
</mods>'
|
121
|
+
@ex6 = '<mods><originInfo>
|
122
|
+
<place>
|
123
|
+
<placeTerm type="code" authority="marccountry">enk</placeTerm>
|
124
|
+
</place>
|
125
|
+
<place>
|
126
|
+
<placeTerm type="text">[London</placeTerm>
|
127
|
+
</place>
|
128
|
+
<publisher>Printed for William Innys and Joseph Richardson ... [et al.]</publisher>
|
129
|
+
<dateIssued>1752]</dateIssued>
|
130
|
+
<dateIssued encoding="marc" keyDate="yes">1752</dateIssued>
|
131
|
+
<issuance>monographic</issuance>
|
132
|
+
</originInfo>
|
133
|
+
</mods>'
|
134
|
+
@ex7 = '<mods><originInfo>
|
135
|
+
<place>
|
136
|
+
<placeTerm authority="marccountry" type="code">fr</placeTerm>
|
137
|
+
</place>
|
138
|
+
<place>
|
139
|
+
<placeTerm type="text">[S.l.]</placeTerm>
|
140
|
+
</place>
|
141
|
+
<publisher>[s.n.]</publisher>
|
142
|
+
<dateIssued>[1740.]</dateIssued>
|
143
|
+
<dateIssued encoding="marc" keyDate="yes" point="start" qualifier="questionable">1740</dateIssued>
|
144
|
+
<dateIssued encoding="marc" point="end" qualifier="questionable">1749</dateIssued>
|
145
|
+
<issuance>monographic</issuance>
|
146
|
+
</originInfo>
|
147
|
+
</mods>'
|
148
|
+
|
149
|
+
xml = '<originInfo>
|
150
|
+
<dateCreated encoding="w3cdtf" keyDate="yes" point="start" qualifier="approximate">250 B.C.</dateCreated>
|
151
|
+
<dateCreated encoding="w3cdtf" keyDate="yes" point="end" qualifier="approximate">150 B.C.</dateCreated>
|
152
|
+
</originInfo>'
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
context "parsing date values" do
|
157
|
+
it "should cope with slop" do
|
158
|
+
pending "to be implemented"
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
context "basic origin_info terminology pieces" do
|
164
|
+
before(:all) do
|
165
|
+
@mods_rec.from_str(@form_and_extent)
|
166
|
+
end
|
167
|
+
|
168
|
+
context "place child element" do
|
169
|
+
before(:all) do
|
170
|
+
@place_term_text = '<mods><originInfo><place><placeTerm type="text">Iran</placeTerm></place></originInfo></mods>'
|
171
|
+
@place_term_plain_mult = '<mods><originInfo>
|
172
|
+
<place><placeTerm>France</placeTerm></place>
|
173
|
+
<place><placeTerm>Italy</placeTerm></place></originInfo></mods>'
|
174
|
+
@place_term_code = '<mods><originInfo><place><placeTerm authority="marccountry" type="code">fr</placeTerm></place></originInfo></mods>'
|
175
|
+
@yuck1 = '<mods><originInfo><place><placeTerm type="text">[S.l.]</placeTerm></place></originInfo></mods>'
|
176
|
+
@yuck2 = '<mods><originInfo><place><placeTerm type="text">[London</placeTerm></place></originInfo></mods>'
|
177
|
+
@yuck3 = '<mods><originInfo><place><placeTerm type="text">[s.l. : s.n.]</placeTerm></place></originInfo></mods>'
|
178
|
+
@yuck4 = '<mods><originInfo><place><placeTerm type="text">[London]</placeTerm></place></originInfo></mods>'
|
179
|
+
end
|
180
|
+
context "placeTerm child element" do
|
181
|
+
it "should get element values" do
|
182
|
+
vals = @mods_rec.from_str(@place_term_plain_mult).origin_info.place.placeTerm.map { |e| e.text}
|
183
|
+
vals.size.should == 2
|
184
|
+
vals.should include("France")
|
185
|
+
vals.should include("Italy")
|
186
|
+
end
|
187
|
+
it "should get authority attribute" do
|
188
|
+
@mods_rec.from_str(@place_term_code).origin_info.place.placeTerm.authority.should == ["marccountry"]
|
189
|
+
end
|
190
|
+
it "should get type(_at) attribute" do
|
191
|
+
@mods_rec.from_str(@place_term_code).origin_info.place.placeTerm.type_at.should == ["code"]
|
192
|
+
end
|
193
|
+
it "should be able to translate marccountry codes" do
|
194
|
+
pending "to be implemented"
|
195
|
+
end
|
196
|
+
it "should ignore s.l. value (from MARC)" do
|
197
|
+
pending "to be implemented"
|
198
|
+
end
|
199
|
+
it "should be forgiving of square brackets (from MARC), matched or unmatched" do
|
200
|
+
pending "to be implemented"
|
201
|
+
end
|
202
|
+
end # placeTerm
|
203
|
+
end # place
|
204
|
+
|
205
|
+
context "publisher child element" do
|
206
|
+
before(:all) do
|
207
|
+
@ex = '<mods><originInfo><publisher>Olney</publisher></origin_info></mods>'
|
208
|
+
@yuck1 = '<mods><originInfo><publisher>[s.n.]</publisher></originInfo></mods>'
|
209
|
+
@yuck2 = '<mods><originInfo><publisher>Printed for William Innys and Joseph Richardson ... [et al.]</publisher></originInfo></mods>'
|
210
|
+
end
|
211
|
+
it "should get element values" do
|
212
|
+
vals = @mods_rec.from_str('<mods><originInfo><publisher>Olney</publisher></origin_info></mods>').origin_info.publisher
|
213
|
+
vals.map { |n| n.text }.should == ["Olney"]
|
214
|
+
end
|
215
|
+
it "should ignore s.n. value (from MARC)" do
|
216
|
+
pending "to be implemented"
|
217
|
+
end
|
218
|
+
it "should leave square brackets alone, except for s.n." do
|
219
|
+
pending "to be implemented"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
context "various date child elements" do
|
224
|
+
it "should recognize each element" do
|
225
|
+
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
226
|
+
@mods_rec.from_str("<mods><originInfo><#{elname}>date</#{elname}></originInfo></mods>")
|
227
|
+
@mods_rec.origin_info.send(elname.to_sym).map { |n| n.text }.should == ["date"]
|
228
|
+
}
|
229
|
+
end
|
230
|
+
it "should recognize encoding attribute on each element" do
|
231
|
+
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
232
|
+
@mods_rec.from_str("<mods><originInfo><#{elname} encoding='foo'>date</#{elname}></originInfo></mods>")
|
233
|
+
@mods_rec.origin_info.send(elname.to_sym).encoding.should == ["foo"]
|
234
|
+
}
|
235
|
+
end
|
236
|
+
it "should recognize keyDate attribute" do
|
237
|
+
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
238
|
+
@mods_rec.from_str("<mods><originInfo><#{elname} keyDate='foo'>date</#{elname}></originInfo></mods>")
|
239
|
+
@mods_rec.origin_info.send(elname.to_sym).keyDate.should == ["foo"]
|
240
|
+
}
|
241
|
+
end
|
242
|
+
it "should recognize point attribute" do
|
243
|
+
# NOTE: values allowed are 'start' and 'end'
|
244
|
+
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
245
|
+
@mods_rec.from_str("<mods><originInfo><#{elname} point='foo'>date</#{elname}></originInfo></mods>")
|
246
|
+
@mods_rec.origin_info.send(elname.to_sym).point.should == ["foo"]
|
247
|
+
}
|
248
|
+
end
|
249
|
+
it "should recognize qualifier attribute" do
|
250
|
+
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
251
|
+
@mods_rec.from_str("<mods><originInfo><#{elname} qualifier='foo'>date</#{elname}></originInfo></mods>")
|
252
|
+
@mods_rec.origin_info.send(elname.to_sym).qualifier.should == ["foo"]
|
253
|
+
}
|
254
|
+
end
|
255
|
+
it "should recognize type attribute only on dateOther" do
|
256
|
+
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |elname|
|
257
|
+
@mods_rec.from_str("<mods><originInfo><#{elname} type='foo'>date</#{elname}></originInfo></mods>")
|
258
|
+
if elname == 'dateOther'
|
259
|
+
@mods_rec.origin_info.send(elname.to_sym).type_at.should == ["foo"]
|
260
|
+
else
|
261
|
+
expect { @mods_rec.origin_info.send(elname.to_sym).type_at}.to raise_exception(NoMethodError, /type_at/)
|
262
|
+
end
|
263
|
+
}
|
264
|
+
end
|
265
|
+
it "should know something about various date encodings: w3cdtf, iso8601, marc, edtf, temper" do
|
266
|
+
pending "to be implemented"
|
267
|
+
end
|
268
|
+
it "should know the only valid values for point attribute are 'start' and 'end'" do
|
269
|
+
pending "to be implemented"
|
270
|
+
end
|
271
|
+
it "should know the only valid value for keyDate attribute is 'yes" do
|
272
|
+
pending "to be implemented"
|
273
|
+
end
|
274
|
+
it "should know the only valid values for qualifier attribute: approximate, inferred, questionable" do
|
275
|
+
pending "to be implemented"
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
it "edition child element" do
|
280
|
+
xml = '<mods><originInfo><edition>7th ed.</edition></originInfo></mods>'
|
281
|
+
@mods_rec.from_str(xml).origin_info.edition.map { |n| n.text }.should == ['7th ed.']
|
282
|
+
end
|
283
|
+
|
284
|
+
context "issuance child element" do
|
285
|
+
before(:all) do
|
286
|
+
@ex = '<mods><originInfo><issuance>monographic</issuance></originInfo></mods>'
|
287
|
+
end
|
288
|
+
it "should get element value" do
|
289
|
+
@mods_rec.from_str(@ex).origin_info.issuance.map { |n| n.text }.should == ['monographic']
|
290
|
+
end
|
291
|
+
it "should know the only valid values are: continuing, monographic, single unit, multipart monograph, serial, integrating resource" do
|
292
|
+
pending "to be implemented"
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
context "frequency child element" do
|
297
|
+
before(:all) do
|
298
|
+
xml = '<mods><originInfo><frequency authority="marcfrequency">Annual</frequency></originInfo></mods>'
|
299
|
+
@origin_info = @mods_rec.from_str(xml).origin_info
|
300
|
+
end
|
301
|
+
it "should get element value" do
|
302
|
+
@origin_info.frequency.map { |n| n.text }.should == ["Annual"]
|
303
|
+
end
|
304
|
+
it "should recognize the authority attribute" do
|
305
|
+
@origin_info.frequency.authority.should == ["marcfrequency"]
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end # basic terminology
|
309
|
+
|
310
|
+
|
311
|
+
end
|