stanford-mods 2.6.4 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/lib/stanford-mods/{geo_spatial.rb → concerns/geo_spatial.rb} +3 -5
- data/lib/stanford-mods/concerns/name.rb +57 -0
- data/lib/stanford-mods/concerns/origin_info.rb +113 -0
- data/lib/stanford-mods/{physical_location.rb → concerns/physical_location.rb} +2 -2
- data/lib/stanford-mods/concerns/searchworks.rb +125 -0
- data/lib/stanford-mods/concerns/searchworks_subjects.rb +126 -0
- data/lib/stanford-mods/concerns/title.rb +87 -0
- data/lib/stanford-mods/coordinate.rb +24 -3
- data/lib/stanford-mods/date_parsing.rb +32 -289
- data/lib/stanford-mods/imprint.rb +170 -322
- data/lib/stanford-mods/record.rb +20 -0
- data/lib/stanford-mods/version.rb +1 -1
- data/lib/stanford-mods/{searchworks_languages.rb → vocabularies/searchworks_languages.rb} +0 -0
- data/lib/stanford-mods.rb +12 -11
- data/spec/fixtures/searchworks_imprint_data.rb +38 -39
- data/spec/fixtures/searchworks_pub_date_data.rb +7 -7
- data/spec/fixtures/spotlight_pub_date_data.rb +7 -7
- data/spec/geo_spatial_spec.rb +1 -6
- data/spec/imprint_spec.rb +263 -207
- data/spec/lib/stanford-mods/coordinate_spec.rb +3 -5
- data/spec/name_spec.rb +26 -230
- data/spec/origin_info_spec.rb +34 -300
- data/spec/searchworks_basic_spec.rb +1 -3
- data/spec/searchworks_pub_dates_spec.rb +0 -215
- data/spec/searchworks_spec.rb +0 -21
- data/spec/searchworks_subject_raw_spec.rb +106 -105
- data/spec/searchworks_subject_spec.rb +19 -55
- data/spec/searchworks_title_spec.rb +5 -5
- data/stanford-mods.gemspec +1 -1
- metadata +19 -15
- data/lib/marc_countries.rb +0 -387
- data/lib/stanford-mods/geo_utils.rb +0 -28
- data/lib/stanford-mods/name.rb +0 -80
- data/lib/stanford-mods/origin_info.rb +0 -489
- data/lib/stanford-mods/searchworks.rb +0 -333
- data/lib/stanford-mods/searchworks_subjects.rb +0 -196
- data/spec/date_parsing_spec.rb +0 -905
@@ -10,219 +10,4 @@ describe "Date methods (searchworks.rb)" do
|
|
10
10
|
# or
|
11
11
|
# dateCreated: 4 digit year
|
12
12
|
# and they should go in spec/fixtures searchworks_pub_date_data.rb
|
13
|
-
|
14
|
-
# @deprecated: need to switch to pub_year_int, or pub_date_sortable_string if you must have a string (why?)
|
15
|
-
context '#pub_date_sort (deprecated)' do
|
16
|
-
it 'four digits' do
|
17
|
-
allow(smods_rec).to receive(:pub_date).and_return('1945')
|
18
|
-
expect(smods_rec.pub_date_sort).to eq('1945')
|
19
|
-
end
|
20
|
-
it '3 digits' do
|
21
|
-
allow(smods_rec).to receive(:pub_date).and_return('945')
|
22
|
-
expect(smods_rec.pub_date_sort).to eq('0945')
|
23
|
-
end
|
24
|
-
it '16--' do
|
25
|
-
allow(smods_rec).to receive(:pub_date).and_return('16--')
|
26
|
-
expect(smods_rec.pub_date_sort).to eq('1600')
|
27
|
-
end
|
28
|
-
it '9--' do
|
29
|
-
allow(smods_rec).to receive(:pub_date).and_return('9--')
|
30
|
-
expect(smods_rec.pub_date_sort).to eq('0900')
|
31
|
-
end
|
32
|
-
it '1980 for 198u' do
|
33
|
-
m = "<mods #{ns_decl}>
|
34
|
-
<originInfo>
|
35
|
-
<dateIssued>198u</dateIssued>
|
36
|
-
</originInfo></mods>"
|
37
|
-
smods_rec.from_str(m)
|
38
|
-
expect(smods_rec.pub_date_sort).to eq('1980')
|
39
|
-
end
|
40
|
-
it '1900 for 19uu' do
|
41
|
-
m = "<mods #{ns_decl}>
|
42
|
-
<originInfo>
|
43
|
-
<dateIssued>19uu</dateIssued>
|
44
|
-
</originInfo></mods>"
|
45
|
-
smods_rec.from_str(m)
|
46
|
-
expect(smods_rec.pub_date_sort).to eq('1900')
|
47
|
-
end
|
48
|
-
it '-700 for 300 B.C.' do
|
49
|
-
m = "<mods #{ns_decl}><originInfo>
|
50
|
-
<dateCreated>300 B.C.</dateCreated>
|
51
|
-
</originInfo></mods>"
|
52
|
-
smods_rec.from_str(m)
|
53
|
-
expect(smods_rec.pub_date_sort).to eq('-700')
|
54
|
-
end
|
55
|
-
it '0966 for 966' do
|
56
|
-
m = "<mods #{ns_decl}><originInfo>
|
57
|
-
<dateIssued>966</dateIssued>
|
58
|
-
</originInfo></mods>"
|
59
|
-
smods_rec.from_str(m)
|
60
|
-
expect(smods_rec.pub_date_sort).to eq('0966')
|
61
|
-
end
|
62
|
-
it '0800 for 9th century' do
|
63
|
-
m = "<mods #{ns_decl}><originInfo>
|
64
|
-
<dateIssued>9th century</dateIssued>
|
65
|
-
</originInfo></mods>"
|
66
|
-
smods_rec.from_str(m)
|
67
|
-
expect(smods_rec.pub_date_sort).to eq('0800')
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context '#pub_date_facet' do
|
72
|
-
it '1980 for 198u' do
|
73
|
-
m = "<mods #{ns_decl}>
|
74
|
-
<originInfo>
|
75
|
-
<dateIssued>198u</dateIssued>
|
76
|
-
</originInfo></mods>"
|
77
|
-
smods_rec.from_str(m)
|
78
|
-
expect(smods_rec.pub_date_facet).to eq('1980')
|
79
|
-
end
|
80
|
-
it '20th century for 19uu' do
|
81
|
-
m = "<mods #{ns_decl}>
|
82
|
-
<originInfo>
|
83
|
-
<dateIssued>19uu</dateIssued>
|
84
|
-
</originInfo></mods>"
|
85
|
-
smods_rec.from_str(m)
|
86
|
-
expect(smods_rec.pub_date_facet).to eq('20th century')
|
87
|
-
end
|
88
|
-
it '3000 B.C. for 300 B.C.' do
|
89
|
-
m = "<mods #{ns_decl}><originInfo>
|
90
|
-
<dateCreated>300 B.C.</dateCreated>
|
91
|
-
</originInfo></mods>"
|
92
|
-
smods_rec.from_str(m)
|
93
|
-
expect(smods_rec.pub_date_facet).to eq('300 B.C.')
|
94
|
-
end
|
95
|
-
it '966 for 966' do
|
96
|
-
m = "<mods #{ns_decl}><originInfo>
|
97
|
-
<dateIssued>966</dateIssued>
|
98
|
-
</originInfo></mods>"
|
99
|
-
smods_rec.from_str(m)
|
100
|
-
expect(smods_rec.pub_date_facet).to eq('966')
|
101
|
-
end
|
102
|
-
it '9th century for 9th century' do
|
103
|
-
m = "<mods #{ns_decl}><originInfo>
|
104
|
-
<dateIssued>9th century</dateIssued>
|
105
|
-
</originInfo></mods>"
|
106
|
-
smods_rec.from_str(m)
|
107
|
-
expect(smods_rec.pub_date_facet).to eq('9th century')
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
context 'uses dateIssued with marc encoding for sorting and faceting' do
|
112
|
-
it '1860' do
|
113
|
-
m = "<mods #{ns_decl}><originInfo>
|
114
|
-
<dateIssued>1844</dateIssued>
|
115
|
-
<dateIssued encoding=\"marc\">1860</dateIssued>
|
116
|
-
</originInfo></mods>"
|
117
|
-
smods_rec.from_str(m)
|
118
|
-
expect(smods_rec.pub_date_sort).to eq('1860') # @deprecated: need to switch to pub_year_int, or pub_date_sortable_string if you must have a string (why?)
|
119
|
-
expect(smods_rec.pub_date_facet).to eq('1860')
|
120
|
-
end
|
121
|
-
it '186?' do
|
122
|
-
m = "<mods #{ns_decl}><originInfo>
|
123
|
-
<dateIssued>1844</dateIssued>
|
124
|
-
<dateIssued encoding=\"marc\">186?</dateIssued>
|
125
|
-
</originInfo></mods>"
|
126
|
-
smods_rec.from_str(m)
|
127
|
-
expect(smods_rec.pub_date_sort).to eq('1860') # @deprecated: need to switch to pub_year_int, or pub_date_sortable_string if you must have a string (why?)
|
128
|
-
expect(smods_rec.pub_date_facet).to eq('1860')
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
context '#pub_year (protected)' do
|
133
|
-
it '-700 for 300 B.C.' do
|
134
|
-
m = "<mods #{ns_decl}><originInfo>
|
135
|
-
<dateCreated>300 B.C.</dateCreated>
|
136
|
-
</originInfo></mods>"
|
137
|
-
smods_rec.from_str(m)
|
138
|
-
expect(smods_rec.send(:pub_year)).to eq('-700')
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
context "#pub_date (protected)" do
|
143
|
-
it "uses dateCreated if no dateIssued" do
|
144
|
-
m = "<mods #{ns_decl}><originInfo>
|
145
|
-
<dateCreated>1904</dateCreated>
|
146
|
-
</originInfo></mods>"
|
147
|
-
smods_rec.from_str(m)
|
148
|
-
expect(smods_rec.send(:pub_date)).to eq('1904')
|
149
|
-
end
|
150
|
-
it "gets year from text date" do
|
151
|
-
m = "<mods #{ns_decl}><originInfo>
|
152
|
-
<dateCreated>Aug. 3rd, 1886</dateCreated>
|
153
|
-
</originInfo></mods>"
|
154
|
-
smods_rec.from_str(m)
|
155
|
-
expect(smods_rec.send(:pub_date)).to eq('1886')
|
156
|
-
end
|
157
|
-
it "ignores question marks and square brackets" do
|
158
|
-
m = "<mods #{ns_decl}><originInfo>
|
159
|
-
<dateCreated>Aug. 3rd, [18]86?</dateCreated>
|
160
|
-
</originInfo></mods>"
|
161
|
-
smods_rec.from_str(m)
|
162
|
-
expect(smods_rec.send(:pub_date)).to eq('1886')
|
163
|
-
end
|
164
|
-
it '1890 for 1890s' do
|
165
|
-
m = "<mods #{ns_decl}><originInfo>
|
166
|
-
<dateCreated>early 1890s</dateCreated>
|
167
|
-
</originInfo></mods>"
|
168
|
-
smods_rec.from_str(m)
|
169
|
-
expect(smods_rec.send(:pub_date)).to eq('1890')
|
170
|
-
end
|
171
|
-
it 'takes first occurring 4 digit date in string' do
|
172
|
-
m = "<mods #{ns_decl}><originInfo>
|
173
|
-
<dateCreated>Text dated June 4, 1594; miniatures added by 1596</dateCreated>
|
174
|
-
</originInfo></mods>"
|
175
|
-
smods_rec.from_str(m)
|
176
|
-
expect(smods_rec.send(:pub_date)).to eq('1594')
|
177
|
-
end
|
178
|
-
it '1980 for 198u' do
|
179
|
-
m = "<mods #{ns_decl}><originInfo>
|
180
|
-
<dateIssued >198u</dateIssued>
|
181
|
-
</originInfo></mods>"
|
182
|
-
smods_rec.from_str(m)
|
183
|
-
expect(smods_rec.send(:pub_date)).to eq('1980')
|
184
|
-
end
|
185
|
-
it '19-- for 19uu' do
|
186
|
-
m = "<mods #{ns_decl}>
|
187
|
-
<originInfo>
|
188
|
-
<dateIssued>19uu</dateIssued>
|
189
|
-
</originInfo></mods>"
|
190
|
-
smods_rec.from_str(m)
|
191
|
-
expect(smods_rec.send(:pub_date)).to eq('19--')
|
192
|
-
end
|
193
|
-
it '-700 for 300 B.C.' do
|
194
|
-
m = "<mods #{ns_decl}><originInfo>
|
195
|
-
<dateCreated>300 B.C.</dateCreated>
|
196
|
-
</originInfo></mods>"
|
197
|
-
smods_rec.from_str(m)
|
198
|
-
expect(smods_rec.send(:pub_date)).to eq('-700')
|
199
|
-
end
|
200
|
-
it '966 for 966' do
|
201
|
-
m = "<mods #{ns_decl}><originInfo>
|
202
|
-
<dateIssued>966</dateIssued>
|
203
|
-
</originInfo></mods>"
|
204
|
-
smods_rec.from_str(m)
|
205
|
-
expect(smods_rec.send(:pub_date)).to eq('966')
|
206
|
-
end
|
207
|
-
it '8-- for 9th century' do
|
208
|
-
m = "<mods #{ns_decl}><originInfo>
|
209
|
-
<dateIssued>9th century</dateIssued>
|
210
|
-
</originInfo></mods>"
|
211
|
-
smods_rec.from_str(m)
|
212
|
-
expect(smods_rec.send(:pub_date)).to eq('8--')
|
213
|
-
end
|
214
|
-
end # pub_date
|
215
|
-
|
216
|
-
context "pub_dates (protected)" do
|
217
|
-
it "puts dateIssued values before dateCreated values" do
|
218
|
-
m = "<mods #{ns_decl}><originInfo>
|
219
|
-
<dateCreated>1904</dateCreated>
|
220
|
-
<dateCreated>1904</dateCreated>
|
221
|
-
<dateIssued>1906</dateIssued>
|
222
|
-
</originInfo></mods>"
|
223
|
-
smods_rec = Stanford::Mods::Record.new
|
224
|
-
smods_rec.from_str(m)
|
225
|
-
expect(smods_rec.send(:pub_dates)).to eq(['1906', '1904', '1904'])
|
226
|
-
end
|
227
|
-
end
|
228
13
|
end
|
data/spec/searchworks_spec.rb
CHANGED
@@ -32,7 +32,6 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
32
32
|
it "should return nothing when the authority and type=code are specified but the language code cannot be found" do
|
33
33
|
m = "<mods #{@ns_decl}><language><languageTerm authority='iso639-2b' type='code'>bogus</languageTerm></language></mods>"
|
34
34
|
@smods_rec.from_str m
|
35
|
-
expect(@smods_rec.logger).to receive(:warn).with(/Couldn't find english name for bogus/)
|
36
35
|
langs = @smods_rec.sw_language_facet
|
37
36
|
expect(langs.size).to eq(0)
|
38
37
|
end
|
@@ -98,18 +97,6 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
98
97
|
@smods_rec.from_str(m)
|
99
98
|
end
|
100
99
|
|
101
|
-
it "main author (for author_1xx_search)" do
|
102
|
-
expect(@smods_rec).to receive(:main_author_w_date) # in stanford-mods.rb
|
103
|
-
@smods_rec.sw_main_author
|
104
|
-
end
|
105
|
-
it "additional authors (for author_7xx_search)" do
|
106
|
-
expect(@smods_rec).to receive(:additional_authors_w_dates) # in stanford-mods.rb
|
107
|
-
@smods_rec.sw_addl_authors
|
108
|
-
end
|
109
|
-
it "person authors (for author_person_facet, author_person_display)" do
|
110
|
-
expect(@smods_rec).to receive(:personal_names_w_dates) # in Mods gem
|
111
|
-
@smods_rec.sw_person_authors
|
112
|
-
end
|
113
100
|
it "non-person authors (for author_other_facet)" do
|
114
101
|
expect(@smods_rec.sw_impersonal_authors).to eq(['Watchful Eye, 1850-', 'Exciting Prints', 'plain', 'conference', 'family'])
|
115
102
|
end
|
@@ -123,14 +110,6 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
|
|
123
110
|
it "should be a String" do
|
124
111
|
expect(@smods_rec.sw_sort_author).to eq('qJerk')
|
125
112
|
end
|
126
|
-
it "should include the main author, as retrieved by :main_author_w_date" do
|
127
|
-
expect(@smods_rec).to receive(:main_author_w_date) # in stanford-mods.rb
|
128
|
-
@smods_rec.sw_sort_author
|
129
|
-
end
|
130
|
-
it "should append the sort title, as retrieved by :sort_title" do
|
131
|
-
expect(@smods_rec).to receive(:sort_title) # in Mods gem
|
132
|
-
@smods_rec.sw_sort_author
|
133
|
-
end
|
134
113
|
it "should not begin or end with whitespace" do
|
135
114
|
expect(@smods_rec.sw_sort_author).to eq(@smods_rec.sw_sort_author.strip)
|
136
115
|
end
|