mods 2.4.1 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +24 -0
  3. data/.gitignore +1 -0
  4. data/README.md +0 -1
  5. data/lib/mods/date.rb +54 -17
  6. data/lib/mods/marc_country_codes.rb +12 -10
  7. data/lib/mods/nom_terminology.rb +109 -845
  8. data/lib/mods/reader.rb +9 -39
  9. data/lib/mods/record.rb +13 -28
  10. data/lib/mods/version.rb +1 -1
  11. data/mods.gemspec +2 -2
  12. data/spec/fixture_data/hp566jq8781.xml +334 -0
  13. data/spec/integration/parker_spec.rb +217 -0
  14. data/spec/{date_spec.rb → lib/date_spec.rb} +9 -1
  15. data/spec/lib/language_spec.rb +123 -0
  16. data/spec/lib/location_spec.rb +175 -0
  17. data/spec/lib/name_spec.rb +368 -0
  18. data/spec/lib/origin_info_spec.rb +134 -0
  19. data/spec/lib/part_spec.rb +162 -0
  20. data/spec/lib/physical_description_spec.rb +72 -0
  21. data/spec/{reader_spec.rb → lib/reader_spec.rb} +1 -41
  22. data/spec/lib/record_info_spec.rb +114 -0
  23. data/spec/lib/record_spec.rb +287 -0
  24. data/spec/lib/related_item_spec.rb +124 -0
  25. data/spec/lib/subject_spec.rb +427 -0
  26. data/spec/lib/title_spec.rb +108 -0
  27. data/spec/lib/top_level_elmnts_simple_spec.rb +169 -0
  28. data/spec/spec_helper.rb +86 -5
  29. data/spec/support/fixtures.rb +9 -0
  30. metadata +49 -44
  31. data/.travis.yml +0 -16
  32. data/spec/language_spec.rb +0 -118
  33. data/spec/location_spec.rb +0 -295
  34. data/spec/name_spec.rb +0 -759
  35. data/spec/origin_info_spec.rb +0 -447
  36. data/spec/part_spec.rb +0 -471
  37. data/spec/physical_description_spec.rb +0 -144
  38. data/spec/record_info_spec.rb +0 -493
  39. data/spec/record_spec.rb +0 -356
  40. data/spec/related_item_spec.rb +0 -305
  41. data/spec/subject_spec.rb +0 -809
  42. data/spec/title_spec.rb +0 -226
  43. data/spec/top_level_elmnts_simple_spec.rb +0 -369
@@ -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&amp;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&amp;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&amp;url=%3D%3FUTF-8%3FB%FaHR0cDovL2NhdGFsb2cucGxzaW5mby5vcmcvc2VhcmNoL2kwMTk1MDM4NjMw%3F%3D&amp;title=Menlo+Park+Public+Library&amp;linktype=opac&amp;detail=JRF%3AMenlo+Park+Public+Library%3APublic&amp;app=wcapi&amp;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&amp;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&amp;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&amp;url=%3D%3FUTF-8%3FB%FaHR0cDovL2NhdGFsb2cucGxzaW5mby5vcmcvc2VhcmNoL2kwMTk1MDM4NjMw%3F%3D&amp;title=Menlo+Park+Public+Library&amp;linktype=opac&amp;detail=JRF%3AMenlo+Park+Public+Library%3APublic&amp;app=wcapi&amp;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