stanford-mods 1.1.5 → 1.2.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 +4 -4
- data/.hound.yml +2 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +12 -0
- data/.travis.yml +12 -13
- data/Gemfile +5 -2
- data/Rakefile +11 -7
- data/config/mappings_hash.rb +1 -1
- data/lib/stanford-mods/name.rb +84 -0
- data/lib/stanford-mods/physical_location.rb +83 -0
- data/lib/stanford-mods/searchworks.rb +1 -2
- data/lib/stanford-mods/version.rb +1 -1
- data/lib/stanford-mods.rb +2 -37
- data/spec/name_spec.rb +385 -206
- data/spec/physical_location_spec.rb +254 -0
- data/spec/searchworks_title_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- metadata +9 -2
@@ -0,0 +1,254 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Physical Location for series, box, folder" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@smods_rec = Stanford::Mods::Record.new
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:smods_rec) { Stanford::Mods::Record.new }
|
10
|
+
let(:mods_loc_phys_loc) do
|
11
|
+
<<-EOF
|
12
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
13
|
+
<location>
|
14
|
+
<physicalLocation>#{example}</physicalLocation>
|
15
|
+
</location>
|
16
|
+
</mods>
|
17
|
+
EOF
|
18
|
+
end
|
19
|
+
let(:mods_rel_item_loc_phys_loc) do
|
20
|
+
<<-EOF
|
21
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
22
|
+
<relatedItem>
|
23
|
+
<location>
|
24
|
+
<physicalLocation>#{example}</physicalLocation>
|
25
|
+
</location>
|
26
|
+
</relatedItem>
|
27
|
+
</mods>
|
28
|
+
EOF
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:mods_loc_multiple_phys_loc) do
|
32
|
+
<<-EOF
|
33
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
34
|
+
<location>
|
35
|
+
<physicalLocation>Irrelevant Data</physicalLocation>
|
36
|
+
<physicalLocation>#{example}</physicalLocation>
|
37
|
+
</location>
|
38
|
+
</mods>
|
39
|
+
EOF
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#add_box' do
|
43
|
+
# example string as key, expected box name as value
|
44
|
+
{
|
45
|
+
# feigenbaum
|
46
|
+
'Call Number: SC0340, Accession 2005-101, Box : 1, Folder: 1' => '1',
|
47
|
+
'Call Number: SC0340, Accession 2005-101, Box: 39, Folder: 9' => '39',
|
48
|
+
'Call Number: SC0340, Accession: 1986-052, Box 3 Folder 38' => '3',
|
49
|
+
'Call Number: SC0340, Accession: 2005-101, Box : 50, Folder: 31' => '50',
|
50
|
+
'Call Number: SC0340, Accession: 1986-052, Box: 5, Folder: 1' => '5',
|
51
|
+
'SC0340, 1986-052, Box 18' => '18',
|
52
|
+
'SC0340, Accession 2005-101, Box 18' => '18',
|
53
|
+
'Call Number: SC0340, Accession 2005-101, Box: 42A, Folder: 24' => '42A',
|
54
|
+
'Call Number: SC0340, Accession: 1986-052, Box: 42A, Folder: 59' => '42A',
|
55
|
+
'Call Number: SC0340, Accession 2005-101' => nil,
|
56
|
+
'Call Number: SC0340, Accession: 1986-052' => nil,
|
57
|
+
'SC0340' => nil,
|
58
|
+
'SC0340, Accession 1986-052' => nil,
|
59
|
+
'Stanford University. Libraries. Department of Special Collections and University Archives' => nil,
|
60
|
+
# shpc (actually in <relatedItem><location><physicalLocation>)
|
61
|
+
'Series Biographical Photographs | Box 42 | Folder Abbot, Nathan' => '42',
|
62
|
+
'Series General Photographs | Box 42 | Folder Administration building--Outer Quad' => '42',
|
63
|
+
# menuez
|
64
|
+
'MSS Photo 451, Series 1, Box 32, Folder 11, Sleeve 32-11-2, Frame B32-F11-S2-6' => '32',
|
65
|
+
'Series 1, Box 10, Folder 8' => '10',
|
66
|
+
# fuller
|
67
|
+
'Collection: M1090 , Series: 1 , Box: 5 , Folder: 42' => '5',
|
68
|
+
# hummel (actually in <relatedItem><location><physicalLocation>)
|
69
|
+
'Box 42 | Folder 3' => '42',
|
70
|
+
'Flat-box 228 | Volume 1' => '228'
|
71
|
+
}.each do |example, expected|
|
72
|
+
describe "for example '#{example}'" do
|
73
|
+
let(:example) { example }
|
74
|
+
context 'in /location/physicalLocation' do
|
75
|
+
it "has the expected box label '#{expected}'" do
|
76
|
+
@smods_rec.from_str(mods_loc_phys_loc)
|
77
|
+
expect(@smods_rec.box).to eq expected
|
78
|
+
end
|
79
|
+
end
|
80
|
+
context 'in /relatedItem/location/physicalLocation' do
|
81
|
+
it "has the expected box label '#{expected}'" do
|
82
|
+
@smods_rec.from_str(mods_rel_item_loc_phys_loc)
|
83
|
+
expect(@smods_rec.box).to eq expected
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'with multiple physicalLocation elements' do
|
88
|
+
it "has the expected box label '#{expected}'" do
|
89
|
+
@smods_rec.from_str(mods_loc_multiple_phys_loc)
|
90
|
+
expect(@smods_rec.box).to eq expected
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end # for example
|
94
|
+
end # each
|
95
|
+
end # add_box
|
96
|
+
|
97
|
+
describe '#add_folder' do
|
98
|
+
# example string as key, expected folder name as value
|
99
|
+
{
|
100
|
+
# feigenbaum
|
101
|
+
'Call Number: SC0340, Accession 2005-101, Box : 1, Folder: 42' => '42',
|
102
|
+
'Call Number: SC0340, Accession 2005-101, Box: 2, Folder: 42' => '42',
|
103
|
+
'Call Number: SC0340, Accession: 1986-052, Box 3 Folder 42' => '42',
|
104
|
+
'Call Number: SC0340, Accession: 2005-101, Box : 4, Folder: 42' => '42',
|
105
|
+
'Call Number: SC0340, Accession: 1986-052, Box: 5, Folder: 42' => '42',
|
106
|
+
'Call Number: SC0340, Accession 2005-101, Box: 4A, Folder: 42' => '42',
|
107
|
+
'Call Number: SC0340, Accession: 1986-052, Box: 5A, Folder: 42' => '42',
|
108
|
+
'Call Number: SC0340, Accession 2005-101' => nil,
|
109
|
+
'Call Number: SC0340, Accession: 1986-052' => nil,
|
110
|
+
'SC0340' => nil,
|
111
|
+
'SC0340, 1986-052, Box 18' => nil,
|
112
|
+
'SC0340, Accession 2005-101' => nil,
|
113
|
+
'SC0340, Accession 2005-101, Box 18' => nil,
|
114
|
+
'Stanford University. Libraries. Department of Special Collections and University Archives' => nil,
|
115
|
+
# menuez
|
116
|
+
'MSS Photo 451, Series 1, Box 32, Folder 42, Sleeve 32-11-2, Frame B32-F11-S2-6' => '42',
|
117
|
+
'Series 1, Box 10, Folder 42' => '42',
|
118
|
+
# fuller
|
119
|
+
'Collection: M1090 , Series: 4 , Box: 5 , Folder: 42' => '42',
|
120
|
+
# hummel (actually in <relatedItem><location><physicalLocation>)
|
121
|
+
'Box 1 | Folder 42' => '42',
|
122
|
+
'Flat-box 228 | Volume 1' => nil,
|
123
|
+
# shpc (actually in <relatedItem><location><physicalLocation>)
|
124
|
+
'Series Biographical Photographs | Box 1 | Folder Abbot, Nathan' => 'Abbot, Nathan',
|
125
|
+
'Series General Photographs | Box 1 | Folder Administration building--Outer Quad' => 'Administration building--Outer Quad',
|
126
|
+
# hypothetical
|
127
|
+
'Folder: 42, Sheet: 15' => '42'
|
128
|
+
}.each do |example, expected|
|
129
|
+
describe "for example '#{example}'" do
|
130
|
+
let(:example) { example }
|
131
|
+
context 'in /location/physicalLocation' do
|
132
|
+
it "has the expected folder label '#{expected}'" do
|
133
|
+
@smods_rec.from_str(mods_loc_phys_loc)
|
134
|
+
expect(@smods_rec.folder).to eq expected
|
135
|
+
end
|
136
|
+
end
|
137
|
+
context 'in /relatedItem/location/physicalLocation' do
|
138
|
+
it "has the expected folder label '#{expected}'" do
|
139
|
+
@smods_rec.from_str(mods_rel_item_loc_phys_loc)
|
140
|
+
expect(@smods_rec.folder).to eq expected
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'with multiple physicalLocation elements' do
|
145
|
+
it "has the expected folder label '#{expected}'" do
|
146
|
+
@smods_rec.from_str(mods_loc_multiple_phys_loc)
|
147
|
+
expect(@smods_rec.folder).to eq expected
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end # for example
|
151
|
+
end # each
|
152
|
+
end # add_folder
|
153
|
+
|
154
|
+
describe '#add_location' do
|
155
|
+
# example string as key, expected box name as value
|
156
|
+
{
|
157
|
+
# feigenbaum
|
158
|
+
'Call Number: SC0340, Accession 2005-101, Box : 1, Folder: 1' => 'Call Number: SC0340, Accession 2005-101, Box : 1, Folder: 1',
|
159
|
+
'Call Number: SC0340, Accession 2005-101' => 'Call Number: SC0340, Accession 2005-101',
|
160
|
+
'SC0340, 1986-052, Box 18' => 'SC0340, 1986-052, Box 18',
|
161
|
+
'SC0340, Accession 2005-101, Box 18' => 'SC0340, Accession 2005-101, Box 18',
|
162
|
+
'SC0340' => nil,
|
163
|
+
'SC0340, Accession 1986-052' => 'SC0340, Accession 1986-052',
|
164
|
+
'Stanford University. Libraries. Department of Special Collections and University Archives' => nil,
|
165
|
+
# shpc (actually in <relatedItem><location><physicalLocation>)
|
166
|
+
'Series Biographical Photographs | Box 42 | Folder Abbot, Nathan' => 'Series Biographical Photographs | Box 42 | Folder Abbot, Nathan',
|
167
|
+
'Series General Photographs | Box 42 | Folder Administration building--Outer Quad' => 'Series General Photographs | Box 42 | Folder Administration building--Outer Quad',
|
168
|
+
# menuez
|
169
|
+
'MSS Photo 451, Series 1, Box 32, Folder 11, Sleeve 32-11-2, Frame B32-F11-S2-6' => 'MSS Photo 451, Series 1, Box 32, Folder 11, Sleeve 32-11-2, Frame B32-F11-S2-6',
|
170
|
+
'Series 1, Box 10, Folder 8' => 'Series 1, Box 10, Folder 8',
|
171
|
+
# fuller
|
172
|
+
'Collection: M1090 , Series: 1 , Box: 5 , Folder: 42' => 'Collection: M1090 , Series: 1 , Box: 5 , Folder: 42',
|
173
|
+
# hummel (actually in <relatedItem><location><physicalLocation>)
|
174
|
+
'Box 42 | Folder 3' => 'Box 42 | Folder 3',
|
175
|
+
'Flat-box 228 | Volume 1' => 'Flat-box 228 | Volume 1'
|
176
|
+
}.each do |example, expected|
|
177
|
+
describe "for example '#{example}'" do
|
178
|
+
let(:example) { example }
|
179
|
+
context 'in /location/physicalLocation' do
|
180
|
+
it "has the expected location '#{expected}'" do
|
181
|
+
@smods_rec.from_str(mods_loc_phys_loc)
|
182
|
+
expect(@smods_rec.location).to eq expected
|
183
|
+
end
|
184
|
+
end
|
185
|
+
context 'in /relatedItem/location/physicalLocation' do
|
186
|
+
it "has the expected location '#{expected}'" do
|
187
|
+
@smods_rec.from_str(mods_rel_item_loc_phys_loc)
|
188
|
+
expect(@smods_rec.location).to eq expected
|
189
|
+
end
|
190
|
+
end
|
191
|
+
context 'with multiple physicalLocation elements' do
|
192
|
+
it "has the expected location '#{expected}'" do
|
193
|
+
@smods_rec.from_str(mods_loc_multiple_phys_loc)
|
194
|
+
expect(@smods_rec.location).to eq expected
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end # for example
|
198
|
+
end # each
|
199
|
+
end # add_location
|
200
|
+
|
201
|
+
describe '#add_series' do
|
202
|
+
# example string as key, expected series name as value
|
203
|
+
{
|
204
|
+
# feigenbaum
|
205
|
+
'Call Number: SC0340, Accession 2005-101' => '2005-101',
|
206
|
+
'Call Number: SC0340, Accession 2005-101, Box : 39, Folder: 9' => '2005-101',
|
207
|
+
'Call Number: SC0340, Accession 2005-101, Box: 2, Folder: 3' => '2005-101',
|
208
|
+
'Call Number: SC0340, Accession: 1986-052' => '1986-052',
|
209
|
+
'Call Number: SC0340, Accession: 1986-052, Box 3 Folder 38' => '1986-052',
|
210
|
+
'Call Number: SC0340, Accession: 2005-101, Box : 50, Folder: 31' => '2005-101',
|
211
|
+
'Call Number: SC0340, Accession: 1986-052, Box: 5, Folder: 1' => '1986-052',
|
212
|
+
'SC0340, Accession 1986-052' => '1986-052',
|
213
|
+
'SC0340, Accession 2005-101, Box 18' => '2005-101',
|
214
|
+
'Call Number: SC0340, Accession 2005-101, Box: 42A, Folder: 24' => '2005-101',
|
215
|
+
'Call Number: SC0340, Accession: 1986-052, Box: 42A, Folder: 59' => '1986-052',
|
216
|
+
'SC0340' => nil,
|
217
|
+
'SC0340, 1986-052, Box 18' => nil,
|
218
|
+
'Stanford University. Libraries. Department of Special Collections and University Archives' => nil,
|
219
|
+
# shpc (actually in <relatedItem><location><physicalLocation>)
|
220
|
+
'Series Biographical Photographs | Box 42 | Folder Abbot, Nathan' => 'Biographical Photographs',
|
221
|
+
'Series General Photographs | Box 42 | Folder Administration building--Outer Quad' => 'General Photographs',
|
222
|
+
# menuez
|
223
|
+
'MSS Photo 451, Series 1, Box 32, Folder 11, Sleeve 32-11-2, Frame B32-F11-S2-6' => '1',
|
224
|
+
'Series 1, Box 10, Folder 8' => '1',
|
225
|
+
# fuller
|
226
|
+
'Collection: M1090 , Series: 4 , Box: 5 , Folder: 10' => '4',
|
227
|
+
# hummel (actually in <relatedItem><location><physicalLocation>)
|
228
|
+
'Box 42 | Folder 3' => nil,
|
229
|
+
'Flat-box 228 | Volume 1' => nil
|
230
|
+
}.each do |example, expected|
|
231
|
+
describe "for example '#{example}'" do
|
232
|
+
let(:example) { example }
|
233
|
+
context 'in /location/physicalLocation' do
|
234
|
+
it "has the expected series name '#{expected}'" do
|
235
|
+
@smods_rec.from_str(mods_loc_phys_loc)
|
236
|
+
expect(@smods_rec.series).to eq expected
|
237
|
+
end
|
238
|
+
end
|
239
|
+
context 'in /relatedItem/location/physicalLocation' do
|
240
|
+
it "has the expected series name '#{expected}'" do
|
241
|
+
@smods_rec.from_str(mods_rel_item_loc_phys_loc)
|
242
|
+
expect(@smods_rec.series).to eq expected
|
243
|
+
end
|
244
|
+
end
|
245
|
+
context 'with multiple physicalLocation elements' do
|
246
|
+
it "has the expected series name '#{expected}'" do
|
247
|
+
@smods_rec.from_str(mods_loc_multiple_phys_loc)
|
248
|
+
expect(@smods_rec.series).to eq expected
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end # for example
|
252
|
+
end # each
|
253
|
+
end # add_series
|
254
|
+
end
|
@@ -564,12 +564,12 @@ describe 'title fields (searchworks.rb)' do
|
|
564
564
|
it 'should not have any punctuation marks' do
|
565
565
|
r = Stanford::Mods::Record.new
|
566
566
|
r.from_str "<mods #{@ns_decl}><titleInfo><title>J,e.r;;;k</title></titleInfo></mods>"
|
567
|
-
expect(r.sw_sort_title).to match
|
567
|
+
expect(r.sw_sort_title).to match(/^Jerk$/)
|
568
568
|
end
|
569
569
|
it 'should properly handle nonSort tags with metacharacters' do
|
570
570
|
r = Stanford::Mods::Record.new
|
571
571
|
r.from_str "<mods #{@ns_decl}><titleInfo><nonSort>[“</nonSort><title>In hat mappa lector... cum enim tota Chilensis regionus...”]</title></titleInfo></mods>"
|
572
|
-
expect(r.sw_sort_title).to match
|
572
|
+
expect(r.sw_sort_title).to match(/^In hat mappa lector cum enim tota Chilensis regionus$/)
|
573
573
|
end
|
574
574
|
end
|
575
575
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stanford-mods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naomi Dushay
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mods
|
@@ -94,7 +94,10 @@ extra_rdoc_files:
|
|
94
94
|
files:
|
95
95
|
- ".coveralls.yml"
|
96
96
|
- ".gitignore"
|
97
|
+
- ".hound.yml"
|
97
98
|
- ".rspec"
|
99
|
+
- ".rubocop.yml"
|
100
|
+
- ".rubocop_todo.yml"
|
98
101
|
- ".travis.yml"
|
99
102
|
- ".yardopts"
|
100
103
|
- Gemfile
|
@@ -103,10 +106,13 @@ files:
|
|
103
106
|
- Rakefile
|
104
107
|
- config/mappings_hash.rb
|
105
108
|
- lib/stanford-mods.rb
|
109
|
+
- lib/stanford-mods/name.rb
|
110
|
+
- lib/stanford-mods/physical_location.rb
|
106
111
|
- lib/stanford-mods/searchworks.rb
|
107
112
|
- lib/stanford-mods/searchworks_languages.rb
|
108
113
|
- lib/stanford-mods/version.rb
|
109
114
|
- spec/name_spec.rb
|
115
|
+
- spec/physical_location_spec.rb
|
110
116
|
- spec/searchworks_basic_spec.rb
|
111
117
|
- spec/searchworks_format_spec.rb
|
112
118
|
- spec/searchworks_pub_dates_spec.rb
|
@@ -141,6 +147,7 @@ specification_version: 4
|
|
141
147
|
summary: Stanford specific wrangling of MODS metadata
|
142
148
|
test_files:
|
143
149
|
- spec/name_spec.rb
|
150
|
+
- spec/physical_location_spec.rb
|
144
151
|
- spec/searchworks_basic_spec.rb
|
145
152
|
- spec/searchworks_format_spec.rb
|
146
153
|
- spec/searchworks_pub_dates_spec.rb
|