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.
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">18XX</dateIssued>
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">147X</dateIssued>
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 A.D. to early years' do
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 A.D.'
141
+ expect(updated_element).to eq '988 CE'
142
142
  end
143
143
 
144
- it 'adds B.C. to B.C. years' do
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 B.C.'
153
+ expect(updated_element).to eq '6 BCE'
154
154
  end
155
155
 
156
- it 'has special handling for the year 0 (1 B.C.)' do
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 B.C.'
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 A.D.?]'
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">190X</dateIssued>
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) }