stanford-mods 3.0.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stanford-mods/concerns/origin_info.rb +53 -58
- data/lib/stanford-mods/coordinate.rb +5 -2
- data/lib/stanford-mods/imprint.rb +145 -49
- data/lib/stanford-mods/version.rb +1 -1
- data/lib/stanford-mods.rb +1 -2
- data/spec/fixtures/searchworks_imprint_data.rb +11 -11
- data/spec/imprint_spec.rb +35 -10
- data/spec/lib/stanford-mods/coordinate_spec.rb +3 -5
- data/spec/origin_info_spec.rb +560 -208
- data/spec/sw_publication_spec.rb +0 -24
- data/stanford-mods.gemspec +1 -1
- metadata +5 -10
- data/lib/stanford-mods/date_parsing.rb +0 -70
- data/spec/fixtures/searchworks_pub_date_data.rb +0 -979
- data/spec/fixtures/spotlight_pub_date_data.rb +0 -316
data/spec/imprint_spec.rb
CHANGED
@@ -108,7 +108,7 @@ describe Stanford::Mods::Imprint do
|
|
108
108
|
it 'presents centuries' do
|
109
109
|
smods_rec.from_str <<-XML
|
110
110
|
#{mods_origin_info_start_str}
|
111
|
-
<dateIssued encoding="edtf">
|
111
|
+
<dateIssued encoding="edtf">18xx</dateIssued>
|
112
112
|
#{mods_origin_info_end_str}
|
113
113
|
XML
|
114
114
|
|
@@ -120,7 +120,7 @@ describe Stanford::Mods::Imprint do
|
|
120
120
|
it 'presents decades' do
|
121
121
|
smods_rec.from_str <<-XML
|
122
122
|
#{mods_origin_info_start_str}
|
123
|
-
<dateIssued encoding="edtf">
|
123
|
+
<dateIssued encoding="edtf">147x</dateIssued>
|
124
124
|
#{mods_origin_info_end_str}
|
125
125
|
XML
|
126
126
|
|
@@ -129,7 +129,7 @@ describe Stanford::Mods::Imprint do
|
|
129
129
|
expect(updated_element).to eq '1470s'
|
130
130
|
end
|
131
131
|
|
132
|
-
it 'adds
|
132
|
+
it 'adds CE to early years' do
|
133
133
|
smods_rec.from_str <<-XML
|
134
134
|
#{mods_origin_info_start_str}
|
135
135
|
<dateIssued encoding="edtf">988</dateIssued>
|
@@ -138,10 +138,10 @@ describe Stanford::Mods::Imprint do
|
|
138
138
|
|
139
139
|
imp = stanford_mods_imprint(smods_rec)
|
140
140
|
updated_element = imp.send(:date_str)
|
141
|
-
expect(updated_element).to eq '988
|
141
|
+
expect(updated_element).to eq '988 CE'
|
142
142
|
end
|
143
143
|
|
144
|
-
it 'adds
|
144
|
+
it 'adds BCE to BCE years' do
|
145
145
|
smods_rec.from_str <<-XML
|
146
146
|
#{mods_origin_info_start_str}
|
147
147
|
<dateIssued encoding="edtf">-5</dateIssued>
|
@@ -150,10 +150,10 @@ describe Stanford::Mods::Imprint do
|
|
150
150
|
|
151
151
|
imp = stanford_mods_imprint(smods_rec)
|
152
152
|
updated_element = imp.send(:date_str)
|
153
|
-
expect(updated_element).to eq '6
|
153
|
+
expect(updated_element).to eq '6 BCE'
|
154
154
|
end
|
155
155
|
|
156
|
-
it 'has special handling for the year 0 (1
|
156
|
+
it 'has special handling for the year 0 (1 BCE)' do
|
157
157
|
smods_rec.from_str <<-XML
|
158
158
|
#{mods_origin_info_start_str}
|
159
159
|
<dateIssued>0</dateIssued>
|
@@ -162,7 +162,7 @@ describe Stanford::Mods::Imprint do
|
|
162
162
|
|
163
163
|
imp = stanford_mods_imprint(smods_rec)
|
164
164
|
updated_element = imp.send(:date_str)
|
165
|
-
expect(updated_element).to eq '1
|
165
|
+
expect(updated_element).to eq '1 BCE'
|
166
166
|
end
|
167
167
|
|
168
168
|
it 'presents years + months' do
|
@@ -189,6 +189,31 @@ describe Stanford::Mods::Imprint do
|
|
189
189
|
expect(updated_element).to eq 'April 2, 1948'
|
190
190
|
end
|
191
191
|
|
192
|
+
it 'handles very precise EDTF ranges' do
|
193
|
+
smods_rec.from_str <<-XML
|
194
|
+
#{mods_origin_info_start_str}
|
195
|
+
<dateIssued encoding="edtf">2014-01/2020-12-31</dateIssued>
|
196
|
+
#{mods_origin_info_end_str}
|
197
|
+
XML
|
198
|
+
|
199
|
+
imp = stanford_mods_imprint(smods_rec)
|
200
|
+
updated_element = imp.send(:date_str)
|
201
|
+
expect(updated_element).to eq 'January 2014 - December 31, 2020'
|
202
|
+
end
|
203
|
+
|
204
|
+
xit 'handles BC EDTF centuries' do
|
205
|
+
# ruby-edtf apparently can't handle this format
|
206
|
+
smods_rec.from_str <<-XML
|
207
|
+
#{mods_origin_info_start_str}
|
208
|
+
<dateIssued encoding="edtf">-09XX</dateIssued>
|
209
|
+
#{mods_origin_info_end_str}
|
210
|
+
XML
|
211
|
+
|
212
|
+
imp = stanford_mods_imprint(smods_rec)
|
213
|
+
updated_element = imp.send(:date_str)
|
214
|
+
expect(updated_element).to eq '10th century BCE'
|
215
|
+
end
|
216
|
+
|
192
217
|
it 'handles the approximate qualifier' do
|
193
218
|
smods_rec.from_str <<-XML
|
194
219
|
#{mods_origin_info_start_str}
|
@@ -210,13 +235,13 @@ describe Stanford::Mods::Imprint do
|
|
210
235
|
|
211
236
|
imp = stanford_mods_imprint(smods_rec)
|
212
237
|
updated_element = imp.send(:date_str)
|
213
|
-
expect(updated_element).to eq '[322
|
238
|
+
expect(updated_element).to eq '[322 CE?]'
|
214
239
|
end
|
215
240
|
|
216
241
|
it 'handles the inferred qualifier' do
|
217
242
|
smods_rec.from_str <<-XML
|
218
243
|
#{mods_origin_info_start_str}
|
219
|
-
<dateIssued encoding="edtf" qualifier="inferred">
|
244
|
+
<dateIssued encoding="edtf" qualifier="inferred">190x</dateIssued>
|
220
245
|
#{mods_origin_info_end_str}
|
221
246
|
XML
|
222
247
|
|
@@ -9,10 +9,6 @@ describe Stanford::Mods::Coordinate do
|
|
9
9
|
expect(described_class.new('W80°--E100°/N487°--S42°')).not_to be_valid
|
10
10
|
end
|
11
11
|
|
12
|
-
it 'rejects coordinates without degree symbols' do
|
13
|
-
expect(described_class.new('W 650--W 100/N 700--N 550')).not_to be_valid
|
14
|
-
end
|
15
|
-
|
16
12
|
it 'rejects malformed coordinates' do
|
17
13
|
expect(described_class.new('(E29°--E35/°S12°--S16°).')).not_to be_valid
|
18
14
|
end
|
@@ -43,7 +39,9 @@ describe Stanford::Mods::Coordinate do
|
|
43
39
|
%((W 170⁰--E 55⁰/N 40⁰--S 36⁰).) =>
|
44
40
|
'-170.0 -36.0 55.0 40.0', # superscript 0 is almost a degree character..
|
45
41
|
%((W 0°-W 0°/S 90°---S 90°)) =>
|
46
|
-
'-0.0 -90.0 -0.0 -90.0' # one dash, two dashes, three dashes.. what's the difference?
|
42
|
+
'-0.0 -90.0 -0.0 -90.0', # one dash, two dashes, three dashes.. what's the difference?
|
43
|
+
%((W 030.6--E 068.1/N 041.7--S 042.4)) =>
|
44
|
+
'-30.6 -42.4 68.1 41.7'
|
47
45
|
}.each do |value, expected|
|
48
46
|
describe 'parsing' do
|
49
47
|
let(:subject) { described_class.new(value) }
|