revs-utils 2.0.5 → 2.0.6

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODAzOTc4MGRiMTU0NDExMTQ2NDA2MWRlMjhmZWViMDRhMWUyMDhjMQ==
4
+ NGE4MzU4NGVjZjc4YzkxYWNlNjlhNGM2MzRmM2JmNDFiYTZiMmZiNw==
5
5
  data.tar.gz: !binary |-
6
- Y2NmOGNiZDQwNjcyOTE2ZDEyNzgzOWQ3ODBjM2UyOGQxOTVhZDgyYQ==
6
+ ODg2NzMxNDAzYWIxYmVmZjA5NDA3MjRkNTVkZDI1MDQzOTgxMTU0Yw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDEwZDY1NTQ1MjRiY2E4YjIxNWMyNzIwN2U0OTc2ZjlmMGFiMTQwODVkNzQ0
10
- YWNmYWY2NDI0ODU1OGQ1OTdjM2I2MmI1ZjY4ODBlYzZjNjY3NTNhNmE3Y2Zi
11
- MzVhYWE1OWJmOTI3Nzg1ODk0MTVmMmVlYzc2MDExYmU4YWJiYTc=
9
+ ODI5MDcwMzIwMGY1ZTcxYmViNjk5NjI4ZGY2ZmIxMzJhNmMzMWViMDUzZTE2
10
+ MzIyMDViZWQ2ZWVlYzdlNGQwZWY1MTU2YzFlMGJiM2JhMTAwMDlhZDVhMjAz
11
+ OTE0N2U3MTFjOWQ4MzhlOGNjYTMwMDMwMTQ4YjI0MTIwY2RhYjA=
12
12
  data.tar.gz: !binary |-
13
- ZjQ3NjBkNDhkMThlZmUxNTEwZTQxMWY4ODU4MjBmMTI1NzRiOGE0ODVlOWFi
14
- ZTdjNzU1NDlhOGNmMDNhOWJhOTRhZDAyYjQ5OWI4MWM0MzlhODlkYzYyZTI2
15
- YzVhM2I5ODM2ZjE3ZTgyZGMwOGRhODA5NDU1NGMxMDBlODhmYmY=
13
+ YWVkNmY2Y2E0NTYyZTRjZGQ2YmVkOTRkNDczYjEzM2QxYTI0YzU2NmQxMDFm
14
+ MzEyZjczMDA2MDc2MGQ3Y2NiZjQxYjg2M2U2YzE2NGEwN2VjMTAyMjFkNTIy
15
+ N2E4MmQ4Yzk5OGM0YzM4YzI1NmU0Y2Q2NjU2Mzk3MGY0MmZmOWM=
data/Gemfile.lock CHANGED
@@ -3,6 +3,7 @@ PATH
3
3
  specs:
4
4
  revs-utils (2.0.5)
5
5
  actionpack (~> 4.1.6)
6
+ chronic
6
7
  countries (= 0.9.2)
7
8
  rdf
8
9
 
@@ -26,6 +27,7 @@ GEM
26
27
  thread_safe (~> 0.1)
27
28
  tzinfo (~> 1.1)
28
29
  builder (3.2.2)
30
+ chronic (0.10.2)
29
31
  countries (0.9.2)
30
32
  currencies (>= 0.4.0)
31
33
  currencies (0.4.2)
@@ -1,5 +1,5 @@
1
1
  module Revs
2
2
  module Utils
3
- VERSION = "2.0.5"
3
+ VERSION = "2.0.6"
4
4
  end
5
5
  end
data/lib/revs-utils.rb CHANGED
@@ -5,6 +5,7 @@ require "countries"
5
5
  require 'active_support/core_ext/string'
6
6
  require 'active_support/core_ext/hash'
7
7
  require 'csv'
8
+ require 'chronic'
8
9
 
9
10
  PROJECT_ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
10
11
 
@@ -238,9 +239,7 @@ module Revs
238
239
  # tell us if the string passed is in is a full date of the format M/D/YYYY or m-d-yyyy or m-d-yy or M/D/YY, and returns the date object if it is valid
239
240
  def get_full_date(date_string)
240
241
  begin
241
- date_obj_string=date_string.gsub('-','/').delete(' ')
242
- date_format = (date_obj_string.split('/').last.size == 4 ? '%m/%d/%Y' : '%m/%d/%y') # if we think we have a 4 digit year, parse with 4 year format, else try the two year format
243
- date_obj = Date.strptime(date_obj_string, date_format)
242
+ date_obj=Chronic.parse(date_string).to_date
244
243
  date_obj=date_obj.prev_year(100) if date_obj > Date.today # if the parsing yields a date in the future, this is a problem, so adjust back a century (due to this issue: http://stackoverflow.com/questions/27058068/ruby-incorrectly-parses-2-digit-year)
245
244
  is_valid_year?(date_obj.year.to_s) ? date_obj : false
246
245
  rescue
data/revs-utils.gemspec CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency "countries", "0.9.2"
21
21
  gem.add_dependency "rdf"
22
22
  gem.add_dependency "actionpack", '~> 4.1.6'
23
+ gem.add_dependency "chronic"
23
24
 
24
25
  gem.add_development_dependency "rspec", "~> 2.6"
25
26
  gem.add_development_dependency "lyberteam-gems-devel", "> 1.0.0"
@@ -82,6 +82,9 @@ describe "Revs-Utils" do
82
82
  @revs.get_full_date('1/1/71').should == Date.strptime("1/1/1971", '%m/%d/%Y') # deal with two digit years ok too
83
83
  @revs.get_full_date('5-1-14').should == Date.strptime("5/1/2014", '%m/%d/%Y') # deal with two digit years ok too
84
84
  @revs.get_full_date('5-1-21').should == Date.strptime("5/1/1921", '%m/%d/%Y') # deal with two digit years ok too
85
+ @revs.get_full_date('1966-02-27').should == Date.strptime("2/27/1966", '%m/%d/%Y') # deal with alternate formats
86
+ @revs.get_full_date('1966-2-5').should == Date.strptime("2/5/1966", '%m/%d/%Y') # deal with alternate formats
87
+ @revs.get_full_date('1966-14-11').should be_falsey
85
88
  @revs.get_full_date('bogus').should be_falsey
86
89
  end
87
90
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revs-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Mangiafico
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 4.1.6
55
+ - !ruby/object:Gem::Dependency
56
+ name: chronic
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement