mods 2.3.0 → 3.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +24 -0
- data/.gitignore +1 -0
- data/Gemfile +1 -5
- data/README.md +1 -3
- data/lib/mods/marc_country_codes.rb +12 -10
- data/lib/mods/nom_terminology.rb +109 -848
- data/lib/mods/origin_info.rb +3 -1
- data/lib/mods/reader.rb +9 -39
- data/lib/mods/record.rb +13 -28
- data/lib/mods/version.rb +1 -1
- data/mods.gemspec +4 -4
- 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} +0 -0
- data/spec/lib/language_spec.rb +123 -0
- data/spec/lib/location_spec.rb +175 -0
- data/spec/lib/name_spec.rb +366 -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 +65 -47
- data/.coveralls.yml +0 -1
- data/.travis.yml +0 -12
- 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 -442
- 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/location_spec.rb
DELETED
@@ -1,295 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Mods <location> Element" do
|
4
|
-
before(:all) do
|
5
|
-
@mods_rec = Mods::Record.new
|
6
|
-
end
|
7
|
-
|
8
|
-
context "basic location terminology pieces" do
|
9
|
-
|
10
|
-
context "WITH namespaces" do
|
11
|
-
before(:all) do
|
12
|
-
@ns_decl = "xmlns='#{Mods::MODS_NS}'"
|
13
|
-
@url_and_phys = "<mods #{@ns_decl}><location>
|
14
|
-
<url displayLabel='Digital collection of 46 images available online' usage='primary display'>http://searchworks.stanford.edu/?f%5Bcollection%5D%5B%5D=The+Reid+W.+Dennis+Collection+of+California+Lithographs&view=gallery</url>
|
15
|
-
</location><location>
|
16
|
-
<physicalLocation>Department of Special Collections, Stanford University Libraries, Stanford, CA 94305.</physicalLocation>
|
17
|
-
</location></mods>"
|
18
|
-
# from http://www.loc.gov/standards/mods/v3/mods-userguide-elements.html !!
|
19
|
-
# sublocation is not allowed directly under location
|
20
|
-
@incorrect = "<mods #{@ns_decl}><location>
|
21
|
-
<physicalLocation>Library of Congress </physicalLocation>
|
22
|
-
<sublocation>Prints and Photographs Division Washington, D.C. 20540 USA</sublocation>
|
23
|
-
<shelfLocator>DAG no. 1410</shelfLocator>
|
24
|
-
</location></mods>"
|
25
|
-
end
|
26
|
-
|
27
|
-
context "physicalLocation child element" do
|
28
|
-
before(:all) do
|
29
|
-
@phys_loc_only = "<mods #{@ns_decl}><location><physicalLocation>here</physicalLocation></location></mods>"
|
30
|
-
@phys_loc_authority = "<mods #{@ns_decl}><location><physicalLocation authority='marcorg'>MnRM</physicalLocation></location></mods>"
|
31
|
-
end
|
32
|
-
it "should have access to text value of element" do
|
33
|
-
@mods_rec.from_str(@phys_loc_only)
|
34
|
-
expect(@mods_rec.location.physicalLocation.text).to eq("here")
|
35
|
-
@mods_rec.from_str(@phys_loc_authority)
|
36
|
-
expect(@mods_rec.location.physicalLocation.map { |n| n.text }).to eq(["MnRM"])
|
37
|
-
end
|
38
|
-
it "should recognize authority attribute" do
|
39
|
-
@mods_rec.from_str(@phys_loc_authority)
|
40
|
-
expect(@mods_rec.location.physicalLocation.authority).to eq(["marcorg"])
|
41
|
-
end
|
42
|
-
it "should recognize displayLabel attribute" do
|
43
|
-
@mods_rec.from_str("<mods #{@ns_decl}><location><physicalLocation displayLabel='Correspondence'>some address</physicalLocation></location></mods>")
|
44
|
-
expect(@mods_rec.location.physicalLocation.displayLabel).to eq(["Correspondence"])
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it "shelfLocator child element" do
|
49
|
-
shelf_loc = "<mods #{@ns_decl}><location>
|
50
|
-
<physicalLocation>Library of Congress </physicalLocation>
|
51
|
-
<shelfLocator>DAG no. 1410</shelfLocator>
|
52
|
-
</location></mods>"
|
53
|
-
@mods_rec.from_str(shelf_loc)
|
54
|
-
expect(@mods_rec.location.shelfLocator.map { |n| n.text }).to eq(["DAG no. 1410"])
|
55
|
-
end
|
56
|
-
|
57
|
-
context "url child element" do
|
58
|
-
before(:all) do
|
59
|
-
@empty_loc_url = "<mods #{@ns_decl}><location><url/></location></mods>"
|
60
|
-
@mult_flavor_loc_urls = "<mods #{@ns_decl}><location>
|
61
|
-
<url access='preview'>http://preview.org</url>
|
62
|
-
<url access='object in context'>http://context.org</url>
|
63
|
-
<url access='raw object'>http://object.org</url>
|
64
|
-
</location></mods>"
|
65
|
-
end
|
66
|
-
it "should have access to text value of element" do
|
67
|
-
urls = @mods_rec.from_str(@mult_flavor_loc_urls).location.url.map { |e| e.text }
|
68
|
-
expect(urls.size).to eq(3)
|
69
|
-
expect(urls).to include("http://preview.org")
|
70
|
-
expect(urls).to include("http://context.org")
|
71
|
-
expect(urls).to include("http://object.org")
|
72
|
-
end
|
73
|
-
context "attributes" do
|
74
|
-
before(:all) do
|
75
|
-
@url_attribs = "<mods #{@ns_decl}><location>
|
76
|
-
<url displayLabel='Digital collection of 46 images available online' usage='primary display'>http://searchworks.stanford.edu/?f%5Bcollection%5D%5B%5D=The+Reid+W.+Dennis+Collection+of+California+Lithographs&view=gallery</url>
|
77
|
-
</location></mods>"
|
78
|
-
end
|
79
|
-
it "should recognize displayLabel attribute" do
|
80
|
-
expect(@mods_rec.from_str(@url_attribs).location.url.displayLabel).to eq(["Digital collection of 46 images available online"])
|
81
|
-
end
|
82
|
-
it "should recognize access attribute" do
|
83
|
-
vals = @mods_rec.from_str(@mult_flavor_loc_urls).location.url.access
|
84
|
-
expect(vals.size).to eq(3)
|
85
|
-
expect(vals).to include("preview")
|
86
|
-
expect(vals).to include("object in context")
|
87
|
-
expect(vals).to include("raw object")
|
88
|
-
end
|
89
|
-
it "should recognize usage attribute" do
|
90
|
-
expect(@mods_rec.from_str(@url_attribs).location.url.usage).to eq(["primary display"])
|
91
|
-
end
|
92
|
-
it "should recognize note attribute" do
|
93
|
-
@mods_rec.from_str("<mods #{@ns_decl}><location><url note='something'>http://somewhere.org</url></location></mods>")
|
94
|
-
expect(@mods_rec.location.url.note).to eq(["something"])
|
95
|
-
end
|
96
|
-
it "should recognize dateLastAccessed attribute" do
|
97
|
-
@mods_rec.from_str("<mods #{@ns_decl}><location><url dateLastAccessed='something'>http://somewhere.org</url></location></mods>")
|
98
|
-
expect(@mods_rec.location.url.dateLastAccessed).to eq(["something"])
|
99
|
-
end
|
100
|
-
end # attributes
|
101
|
-
it "should have array with empty string for single empty url element" do
|
102
|
-
expect(@mods_rec.from_str(@empty_loc_url).location.url.map { |n| n.text }).to eq([""])
|
103
|
-
end
|
104
|
-
end # url child element
|
105
|
-
|
106
|
-
it "holdingSimple child element" do
|
107
|
-
xml = "<mods #{@ns_decl}><location>
|
108
|
-
<physicalLocation authority='marcorg'>MnRM</physicalLocation>
|
109
|
-
<holdingSimple>
|
110
|
-
<copyInformation>
|
111
|
-
<sublocation>Patient reading room</sublocation>
|
112
|
-
<shelfLocator>QH511.A1J68</shelfLocator>
|
113
|
-
<enumerationAndChronology unitType='1'> v.1-v.8 1970-1976</enumerationAndChronology>
|
114
|
-
</copyInformation>
|
115
|
-
</holdingSimple></location></mods>"
|
116
|
-
expect(@mods_rec.from_str(xml).location.holdingSimple).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
117
|
-
expect(@mods_rec.from_str(xml).location.holdingSimple.first).to be_an_instance_of(Nokogiri::XML::Element)
|
118
|
-
end
|
119
|
-
it "holdingComplex child element" do
|
120
|
-
xml = "<mods #{@ns_decl}>
|
121
|
-
<location>
|
122
|
-
<physicalLocation>Menlo Park Public Library</physicalLocation>
|
123
|
-
<holdingExternal>
|
124
|
-
<holding xmlns:iso20775='info:ofi/fmt:xml:xsd:iso20775' xsi:schemaLocation='info:ofi/fmt:xml:xsd:iso20775 http://www.loc.gov/standards/iso20775/N130_ISOholdings_v6_1.xsd'>
|
125
|
-
<institutionIdentifier>
|
126
|
-
<value>JRF</value>
|
127
|
-
<typeOrSource>
|
128
|
-
<pointer>http://worldcat.org/registry/institutions/</pointer>
|
129
|
-
</typeOrSource>
|
130
|
-
</institutionIdentifier>
|
131
|
-
<physicalLocation>Menlo Park Public Library</physicalLocation>
|
132
|
-
<physicalAddress>
|
133
|
-
<text>Menlo Park, CA 94025 United States </text>
|
134
|
-
</physicalAddress>
|
135
|
-
<electronicAddress>
|
136
|
-
<text>http://www.worldcat.org/wcpa/oclc/15550774? page=frame&url=%3D%3FUTF-8%3FB%FaHR0cDovL2NhdGFsb2cucGxzaW5mby5vcmcvc2VhcmNoL2kwMTk1MDM4NjMw%3F%3D&title=Menlo+Park+Public+Library&linktype=opac&detail=JRF%3AMenlo+Park+Public+Library%3APublic&app=wcapi&id=OCL-OCLC+Staff+use</text>
|
137
|
-
</electronicAddress>
|
138
|
-
<holdingSimple>
|
139
|
-
<copiesSummary>
|
140
|
-
<copiesCount>1</copiesCount>
|
141
|
-
</copiesSummary>
|
142
|
-
</holdingSimple>
|
143
|
-
</holding>
|
144
|
-
</holdingExternal>
|
145
|
-
</mods>"
|
146
|
-
expect(@mods_rec.from_str(xml).location.holdingExternal).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
147
|
-
expect(@mods_rec.from_str(xml).location.holdingExternal.first).to be_an_instance_of(Nokogiri::XML::Element)
|
148
|
-
end
|
149
|
-
|
150
|
-
end # WITH namespaces
|
151
|
-
|
152
|
-
context "WITHOUT namespaces" do
|
153
|
-
before(:all) do
|
154
|
-
@url_and_phys = '<mods><location>
|
155
|
-
<url displayLabel="Digital collection of 46 images available online" usage="primary display">http://searchworks.stanford.edu/?f%5Bcollection%5D%5B%5D=The+Reid+W.+Dennis+Collection+of+California+Lithographs&view=gallery</url>
|
156
|
-
</location><location>
|
157
|
-
<physicalLocation>Department of Special Collections, Stanford University Libraries, Stanford, CA 94305.</physicalLocation>
|
158
|
-
</location></mods>'
|
159
|
-
# from http://www.loc.gov/standards/mods/v3/mods-userguide-elements.html !!
|
160
|
-
# sublocation is not allowed directly under location
|
161
|
-
@incorrect = '<mods><location>
|
162
|
-
<physicalLocation>Library of Congress </physicalLocation>
|
163
|
-
<sublocation>Prints and Photographs Division Washington, D.C. 20540 USA</sublocation>
|
164
|
-
<shelfLocator>DAG no. 1410</shelfLocator>
|
165
|
-
</location></mods>'
|
166
|
-
end
|
167
|
-
|
168
|
-
context "physicalLocation child element" do
|
169
|
-
before(:all) do
|
170
|
-
@phys_loc_only = '<mods><location><physicalLocation>here</physicalLocation></location></mods>'
|
171
|
-
@phys_loc_authority = '<mods><location><physicalLocation authority="marcorg">MnRM</physicalLocation></location></mods>'
|
172
|
-
end
|
173
|
-
it "should have access to text value of element" do
|
174
|
-
@mods_rec.from_str(@phys_loc_only, false)
|
175
|
-
expect(@mods_rec.location.physicalLocation.text).to eq("here")
|
176
|
-
@mods_rec.from_str(@phys_loc_authority, false)
|
177
|
-
expect(@mods_rec.location.physicalLocation.map { |n| n.text }).to eq(["MnRM"])
|
178
|
-
end
|
179
|
-
it "should recognize authority attribute" do
|
180
|
-
@mods_rec.from_str(@phys_loc_authority, false)
|
181
|
-
expect(@mods_rec.location.physicalLocation.authority).to eq(["marcorg"])
|
182
|
-
end
|
183
|
-
it "should recognize displayLabel attribute" do
|
184
|
-
@mods_rec.from_str('<mods><location><physicalLocation displayLabel="Correspondence">some address</physicalLocation></location></mods>', false)
|
185
|
-
expect(@mods_rec.location.physicalLocation.displayLabel).to eq(["Correspondence"])
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
it "shelfLocator child element" do
|
190
|
-
shelf_loc = '<mods><location>
|
191
|
-
<physicalLocation>Library of Congress </physicalLocation>
|
192
|
-
<shelfLocator>DAG no. 1410</shelfLocator>
|
193
|
-
</location></mods>'
|
194
|
-
@mods_rec.from_str(shelf_loc, false)
|
195
|
-
expect(@mods_rec.location.shelfLocator.map { |n| n.text }).to eq(["DAG no. 1410"])
|
196
|
-
end
|
197
|
-
|
198
|
-
context "url child element" do
|
199
|
-
before(:all) do
|
200
|
-
@empty_loc_url = '<mods><location><url/></location></mods>'
|
201
|
-
@mult_flavor_loc_urls = '<mods><location>
|
202
|
-
<url access="preview">http://preview.org</url>
|
203
|
-
<url access="object in context">http://context.org</url>
|
204
|
-
<url access="raw object">http://object.org</url>
|
205
|
-
</location></mods>'
|
206
|
-
end
|
207
|
-
it "should have access to text value of element" do
|
208
|
-
urls = @mods_rec.from_str(@mult_flavor_loc_urls, false).location.url.map { |e| e.text }
|
209
|
-
expect(urls.size).to eq(3)
|
210
|
-
expect(urls).to include("http://preview.org")
|
211
|
-
expect(urls).to include("http://context.org")
|
212
|
-
expect(urls).to include("http://object.org")
|
213
|
-
end
|
214
|
-
context "attributes" do
|
215
|
-
before(:all) do
|
216
|
-
@url_attribs = '<mods><location>
|
217
|
-
<url displayLabel="Digital collection of 46 images available online" usage="primary display">http://searchworks.stanford.edu/?f%5Bcollection%5D%5B%5D=The+Reid+W.+Dennis+Collection+of+California+Lithographs&view=gallery</url>
|
218
|
-
</location></mods>'
|
219
|
-
end
|
220
|
-
it "should recognize displayLabel attribute" do
|
221
|
-
expect(@mods_rec.from_str(@url_attribs, false).location.url.displayLabel).to eq(["Digital collection of 46 images available online"])
|
222
|
-
end
|
223
|
-
it "should recognize access attribute" do
|
224
|
-
vals = @mods_rec.from_str(@mult_flavor_loc_urls, false).location.url.access
|
225
|
-
expect(vals.size).to eq(3)
|
226
|
-
expect(vals).to include("preview")
|
227
|
-
expect(vals).to include("object in context")
|
228
|
-
expect(vals).to include("raw object")
|
229
|
-
end
|
230
|
-
it "should recognize usage attribute" do
|
231
|
-
expect(@mods_rec.from_str(@url_attribs, false).location.url.usage).to eq(["primary display"])
|
232
|
-
end
|
233
|
-
it "should recognize note attribute" do
|
234
|
-
@mods_rec.from_str('<mods><location><url note="something">http://somewhere.org</url></location></mods>', false)
|
235
|
-
expect(@mods_rec.location.url.note).to eq(["something"])
|
236
|
-
end
|
237
|
-
it "should recognize dateLastAccessed attribute" do
|
238
|
-
@mods_rec.from_str('<mods><location><url dateLastAccessed="something">http://somewhere.org</url></location></mods>', false)
|
239
|
-
expect(@mods_rec.location.url.dateLastAccessed).to eq(["something"])
|
240
|
-
end
|
241
|
-
end # attributes
|
242
|
-
it "should have array with empty string for single empty url element" do
|
243
|
-
expect(@mods_rec.from_str(@empty_loc_url, false).location.url.map { |n| n.text }).to eq([""])
|
244
|
-
end
|
245
|
-
end # url child element
|
246
|
-
|
247
|
-
it "holdingSimple child element" do
|
248
|
-
xml = '<mods><location>
|
249
|
-
<physicalLocation authority="marcorg">MnRM</physicalLocation>
|
250
|
-
<holdingSimple>
|
251
|
-
<copyInformation>
|
252
|
-
<sublocation>Patient reading room</sublocation>
|
253
|
-
<shelfLocator>QH511.A1J68</shelfLocator>
|
254
|
-
<enumerationAndChronology unitType="1"> v.1-v.8 1970-1976</enumerationAndChronology>
|
255
|
-
</copyInformation>
|
256
|
-
</holdingSimple></location></mods>'
|
257
|
-
expect(@mods_rec.from_str(xml, false).location.holdingSimple).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
258
|
-
expect(@mods_rec.from_str(xml, false).location.holdingSimple.first).to be_an_instance_of(Nokogiri::XML::Element)
|
259
|
-
end
|
260
|
-
it "holdingComplex child element" do
|
261
|
-
xml = '<mods>
|
262
|
-
<location>
|
263
|
-
<physicalLocation>Menlo Park Public Library</physicalLocation>
|
264
|
-
<holdingExternal>
|
265
|
-
<holding xmlns:iso20775="info:ofi/fmt:xml:xsd:iso20775" xsi:schemaLocation="info:ofi/fmt:xml:xsd:iso20775 http://www.loc.gov/standards/iso20775/N130_ISOholdings_v6_1.xsd">
|
266
|
-
<institutionIdentifier>
|
267
|
-
<value>JRF</value>
|
268
|
-
<typeOrSource>
|
269
|
-
<pointer>http://worldcat.org/registry/institutions/</pointer>
|
270
|
-
</typeOrSource>
|
271
|
-
</institutionIdentifier>
|
272
|
-
<physicalLocation>Menlo Park Public Library</physicalLocation>
|
273
|
-
<physicalAddress>
|
274
|
-
<text>Menlo Park, CA 94025 United States </text>
|
275
|
-
</physicalAddress>
|
276
|
-
<electronicAddress>
|
277
|
-
<text>http://www.worldcat.org/wcpa/oclc/15550774? page=frame&url=%3D%3FUTF-8%3FB%FaHR0cDovL2NhdGFsb2cucGxzaW5mby5vcmcvc2VhcmNoL2kwMTk1MDM4NjMw%3F%3D&title=Menlo+Park+Public+Library&linktype=opac&detail=JRF%3AMenlo+Park+Public+Library%3APublic&app=wcapi&id=OCL-OCLC+Staff+use</text>
|
278
|
-
</electronicAddress>
|
279
|
-
<holdingSimple>
|
280
|
-
<copiesSummary>
|
281
|
-
<copiesCount>1</copiesCount>
|
282
|
-
</copiesSummary>
|
283
|
-
</holdingSimple>
|
284
|
-
</holding>
|
285
|
-
</holdingExternal>
|
286
|
-
</mods>'
|
287
|
-
expect(@mods_rec.from_str(xml, false).location.holdingExternal).to be_an_instance_of(Nokogiri::XML::NodeSet)
|
288
|
-
expect(@mods_rec.from_str(xml, false).location.holdingExternal.first).to be_an_instance_of(Nokogiri::XML::Element)
|
289
|
-
end
|
290
|
-
|
291
|
-
end # WITHOUT namespaces
|
292
|
-
|
293
|
-
end
|
294
|
-
|
295
|
-
end
|