mods_display 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mods_display/fields/imprint.rb +16 -0
- data/lib/mods_display/version.rb +1 -1
- data/spec/fields/imprint_spec.rb +18 -0
- data/spec/fixtures/imprint_fixtures.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f646ef8067a80ee0b0318f9f8c8d03ca5450c522772d5f514776aee4f03dae64
|
4
|
+
data.tar.gz: a04eb7333f672aba00e2a6cb0883ff580a027d23c97363becb11a634cf6b1661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5a0a38fac8e49e2e9fdc17c4560fd5cb0461f4c459eddf2981cfccc3e3a7df1cd1477acc9fae4537daf1cb269f439d5809799e09cc9487c8f813529612dbf1a
|
7
|
+
data.tar.gz: '09364c514c07be1ad564fb4f4325a7ad9f9abf031c08f140a7150119c6b2be6e14a8dd06a75e5aa19e3a31f096939df7ce4b87e493e5abbf7e4bdaadfd33daf8'
|
@@ -68,6 +68,8 @@ module ModsDisplay
|
|
68
68
|
date_fields.map do |date_field|
|
69
69
|
if date_is_w3cdtf?(date_field)
|
70
70
|
process_w3cdtf_date(date_field)
|
71
|
+
elsif date_is_iso8601?(date_field)
|
72
|
+
process_iso8601_date(date_field)
|
71
73
|
else
|
72
74
|
date_field
|
73
75
|
end
|
@@ -158,6 +160,10 @@ module ModsDisplay
|
|
158
160
|
field_is_encoded?(date_field, 'w3cdtf')
|
159
161
|
end
|
160
162
|
|
163
|
+
def date_is_iso8601?(date_field)
|
164
|
+
field_is_encoded?(date_field, 'iso8601')
|
165
|
+
end
|
166
|
+
|
161
167
|
def process_w3cdtf_date(date_field)
|
162
168
|
date_field = date_field.clone
|
163
169
|
date_field.content = begin
|
@@ -174,6 +180,16 @@ module ModsDisplay
|
|
174
180
|
date_field
|
175
181
|
end
|
176
182
|
|
183
|
+
def process_iso8601_date(date_field)
|
184
|
+
date_field = date_field.clone
|
185
|
+
date_field.content = begin
|
186
|
+
Date.iso8601(date_field.text).strftime(@config.full_date_format)
|
187
|
+
rescue
|
188
|
+
date_field.content
|
189
|
+
end
|
190
|
+
date_field
|
191
|
+
end
|
192
|
+
|
177
193
|
def dedup_dates(date_fields)
|
178
194
|
date_text = date_fields.map { |d| normalize_date(d.text) }
|
179
195
|
if date_text != date_text.uniq
|
data/lib/mods_display/version.rb
CHANGED
data/spec/fields/imprint_spec.rb
CHANGED
@@ -43,6 +43,7 @@ describe ModsDisplay::Imprint do
|
|
43
43
|
@imprint_date_range = Stanford::Mods::Record.new.from_str(imprint_date_range, false).origin_info
|
44
44
|
@encoded_place = Stanford::Mods::Record.new.from_str(encoded_place, false).origin_info
|
45
45
|
@encoded_dates = Stanford::Mods::Record.new.from_str(encoded_dates, false).origin_info
|
46
|
+
@iso8601_encoded_dates = Stanford::Mods::Record.new.from_str(iso8601_encoded_dates, false).origin_info
|
46
47
|
@bad_dates = Stanford::Mods::Record.new.from_str(bad_dates, false).origin_info
|
47
48
|
@invalid_dates = Stanford::Mods::Record.new.from_str(invalid_dates, false).origin_info
|
48
49
|
@punctuation_imprint = Stanford::Mods::Record.new.from_str(punctuation_imprint_fixture, false).origin_info
|
@@ -209,6 +210,23 @@ describe ModsDisplay::Imprint do
|
|
209
210
|
end.values).to eq(['July (2013)'])
|
210
211
|
end
|
211
212
|
end
|
213
|
+
|
214
|
+
describe 'iso8601' do
|
215
|
+
it 'handles full dates properly' do
|
216
|
+
fields = mods_display_imprint(@iso8601_encoded_dates).fields
|
217
|
+
expect(fields.length).to eq(2)
|
218
|
+
expect(fields.find do |field|
|
219
|
+
field.label == 'Date created:'
|
220
|
+
end.values).to eq(['November 14, 2013'])
|
221
|
+
end
|
222
|
+
it "should not try to handle dates we can't parse" do
|
223
|
+
fields = mods_display_imprint(@iso8601_encoded_dates).fields
|
224
|
+
expect(fields.length).to eq(2)
|
225
|
+
expect(fields.find do |field|
|
226
|
+
field.label == 'Date modified:'
|
227
|
+
end.values).to eq(['Jul. 22, 2013'])
|
228
|
+
end
|
229
|
+
end
|
212
230
|
end
|
213
231
|
describe 'bad dates' do
|
214
232
|
it 'should ignore date values' do
|
@@ -280,6 +280,17 @@ module ImprintFixtures
|
|
280
280
|
MODS
|
281
281
|
end
|
282
282
|
|
283
|
+
def iso8601_encoded_dates
|
284
|
+
<<-MODS
|
285
|
+
<mods>
|
286
|
+
<originInfo>
|
287
|
+
<dateCreated encoding="iso8601">20131114161429</dateCreated>
|
288
|
+
<dateModified encoding="iso8601">Jul. 22, 2013</dateModified>
|
289
|
+
</originInfo>
|
290
|
+
</mods>
|
291
|
+
MODS
|
292
|
+
end
|
293
|
+
|
283
294
|
def bad_dates
|
284
295
|
<<-MODS
|
285
296
|
<mods>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mods_display
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jessie Keck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stanford-mods
|