mods_display 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7405311ccd79996582dd2eacb5a4aed58f01bc10
4
- data.tar.gz: 8239610c70f063e06bdf0b27dd1a11d21824b050
3
+ metadata.gz: 42641f12e467c9b272076b0b6815cd70db0fa05d
4
+ data.tar.gz: 09f1736b6d10375c9b42886bff7229727112d5ee
5
5
  SHA512:
6
- metadata.gz: 0db38505cefc90acce173c4092574fe50bd7781326f5aff9b490a2491c3a6795641a3bb5055a72b0da6a202e48c62b8a798b9ef10d07a9286e1e0c491a6a2da6
7
- data.tar.gz: 66abdd1b57edd01c590c4cc3e821d14db40cc377b24d737be32116f67f9363556157b1f625e5eaf0c4514be975489f2825acc5775bd2b66dc323528b6157325d
6
+ metadata.gz: a345e88948e4b742cc76b13ca85461cf1050b418c99a29449965fa3fcef607487883ff87736db4547252b450ab45acd2813a1e53d731b2a7fbded2be826c8569
7
+ data.tar.gz: 73513c3417b6f6a7903d1769b38aaaae05c50a4806c8b4b3809c00d28aafd97a8af7611d4a3d1c11431b8490180dd58c6c2ba59edd3b0f5b51b084d099e2e87f
@@ -156,11 +156,15 @@ class ModsDisplay::Imprint < ModsDisplay::Field
156
156
  end
157
157
  def process_w3cdtf_date(date_field)
158
158
  date_field = date_field.clone
159
- date_field.content = if date_field.text.strip =~ /^\d{4}-\d{2}-\d{2}$/
160
- Date.parse(date_field.text).strftime(@config.full_date_format)
161
- elsif date_field.text.strip =~ /^\d{4}-\d{2}$/
162
- Date.parse("#{date_field.text}-01").strftime(@config.short_date_format)
163
- else
159
+ date_field.content = begin
160
+ if date_field.text.strip =~ /^\d{4}-\d{2}-\d{2}$/
161
+ Date.parse(date_field.text).strftime(@config.full_date_format)
162
+ elsif date_field.text.strip =~ /^\d{4}-\d{2}$/
163
+ Date.parse("#{date_field.text}-01").strftime(@config.short_date_format)
164
+ else
165
+ date_field.content
166
+ end
167
+ rescue
164
168
  date_field.content
165
169
  end
166
170
  date_field
@@ -1,3 +1,3 @@
1
1
  module ModsDisplay
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -35,6 +35,7 @@ describe ModsDisplay::Imprint do
35
35
  @encoded_place = Stanford::Mods::Record.new.from_str(encoded_place, false).origin_info
36
36
  @encoded_dates = Stanford::Mods::Record.new.from_str(encoded_dates, false).origin_info
37
37
  @bad_dates = Stanford::Mods::Record.new.from_str(bad_dates, false).origin_info
38
+ @invalid_dates = Stanford::Mods::Record.new.from_str(invalid_dates, false).origin_info
38
39
  end
39
40
 
40
41
  describe "labels" do
@@ -193,6 +194,11 @@ describe ModsDisplay::Imprint do
193
194
  field.values.join.should_not include "9999"
194
195
  end
195
196
  end
197
+ it "should handle invalid dates by returning the original value" do
198
+ fields = mods_display_imprint(@invalid_dates).fields
199
+ fields.length.should == 2
200
+ fields.last.values.should == ["1920-09-00"]
201
+ end
196
202
  end
197
203
  end
198
204
  describe "place processing" do
@@ -265,4 +265,16 @@ module ImprintFixtures
265
265
  </mods>
266
266
  MODS
267
267
  end
268
+ def invalid_dates
269
+ <<-MODS
270
+ <mods>
271
+ <originInfo>
272
+ <place>
273
+ <placeTerm>United States</placeTerm>
274
+ </place>
275
+ <dateModified encoding="w3cdtf">1920-09-00</dateModified>
276
+ </originInfo>
277
+ </mods>
278
+ MODS
279
+ end
268
280
  end
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.3.0
4
+ version: 0.3.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: 2013-12-18 00:00:00.000000000 Z
11
+ date: 2013-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stanford-mods