revs-utils 2.0.6 → 2.0.7

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
- NGE4MzU4NGVjZjc4YzkxYWNlNjlhNGM2MzRmM2JmNDFiYTZiMmZiNw==
4
+ YjgyNzZkYTI2YTNmODVlNTZjOTRkZDNhMWUzNjE3ZjY0NzI5NmNlOQ==
5
5
  data.tar.gz: !binary |-
6
- ODg2NzMxNDAzYWIxYmVmZjA5NDA3MjRkNTVkZDI1MDQzOTgxMTU0Yw==
6
+ N2U1NzkxNjNmNzE0MmQ3OWQ5ZTA1YWMzMTE1M2IwMTNhNTQ1Yzk5OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODI5MDcwMzIwMGY1ZTcxYmViNjk5NjI4ZGY2ZmIxMzJhNmMzMWViMDUzZTE2
10
- MzIyMDViZWQ2ZWVlYzdlNGQwZWY1MTU2YzFlMGJiM2JhMTAwMDlhZDVhMjAz
11
- OTE0N2U3MTFjOWQ4MzhlOGNjYTMwMDMwMTQ4YjI0MTIwY2RhYjA=
9
+ ZmMzODNjM2Q3MTM1NDhlMWNjNjkyZmViNzNmMmZhMzZlNGE1OTUxOGI2YjY5
10
+ Zjk3MzMwMzMxMjQ0ZWY3YjliNTlkNjE0YjY5YTI1YTY1NDhmNTg2YWZmMzIx
11
+ M2JhNmM4YTU1YTFhMThiNjgyNTc2YzI5Y2NlZDUxNWU5MjNlYmM=
12
12
  data.tar.gz: !binary |-
13
- YWVkNmY2Y2E0NTYyZTRjZGQ2YmVkOTRkNDczYjEzM2QxYTI0YzU2NmQxMDFm
14
- MzEyZjczMDA2MDc2MGQ3Y2NiZjQxYjg2M2U2YzE2NGEwN2VjMTAyMjFkNTIy
15
- N2E4MmQ4Yzk5OGM0YzM4YzI1NmU0Y2Q2NjU2Mzk3MGY0MmZmOWM=
13
+ ODVlYTBiNzYzMTY3NDc4N2JmMzVlMjM0NzM4N2VhZDNhNjQwYTk4OGUyNzY1
14
+ MWY2ZjYzMTZlODFiZmU4N2E5Y2U3NTE1MzQ2ZDJmNTQxOTVmYmQ2NGNlZmVh
15
+ NWIwNjM5NTk0MGUwMTRiMzVmOWY4N2FmMzQ1N2NmMzY5ZmMyYzg=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- revs-utils (2.0.5)
4
+ revs-utils (2.0.6)
5
5
  actionpack (~> 4.1.6)
6
6
  chronic
7
7
  countries (= 0.9.2)
@@ -1,5 +1,5 @@
1
1
  module Revs
2
2
  module Utils
3
- VERSION = "2.0.6"
3
+ VERSION = "2.0.7"
4
4
  end
5
5
  end
data/lib/revs-utils.rb CHANGED
@@ -239,6 +239,7 @@ module Revs
239
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
240
240
  def get_full_date(date_string)
241
241
  begin
242
+ return false if date_string.scan(/(-|\/)/).count < 2 # we need at least two / or - characters to count as a full date
242
243
  date_obj=Chronic.parse(date_string).to_date
243
244
  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)
244
245
  is_valid_year?(date_obj.year.to_s) ? date_obj : false
@@ -75,17 +75,29 @@ describe "Revs-Utils" do
75
75
  end
76
76
 
77
77
  it "should indicate if a date is valid" do
78
+
79
+ # formats that are ok
78
80
  @revs.get_full_date('5/1/1959').should == Date.strptime("5/1/1959", '%m/%d/%Y')
79
81
  @revs.get_full_date('5-1-1959').should == Date.strptime("5/1/1959", '%m/%d/%Y')
80
82
  @revs.get_full_date('5-1-2014').should == Date.strptime("5/1/2014", '%m/%d/%Y')
81
- @revs.get_full_date('5-1-59').should == Date.strptime("5/1/1959", '%m/%d/%Y') # deal with two digit years ok too
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
- @revs.get_full_date('5-1-14').should == Date.strptime("5/1/2014", '%m/%d/%Y') # deal with two digit years ok too
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
88
- @revs.get_full_date('bogus').should be_falsey
83
+ @revs.get_full_date('5-1-59').should == Date.strptime("5/1/1959", '%m/%d/%Y')
84
+ @revs.get_full_date('1/1/71').should == Date.strptime("1/1/1971", '%m/%d/%Y')
85
+ @revs.get_full_date('5-1-14').should == Date.strptime("5/1/2014", '%m/%d/%Y')
86
+ @revs.get_full_date('5-1-21').should == Date.strptime("5/1/1921", '%m/%d/%Y')
87
+ @revs.get_full_date('1966-02-27').should == Date.strptime("2/27/1966", '%m/%d/%Y')
88
+ @revs.get_full_date('1966-2-5').should == Date.strptime("2/5/1966", '%m/%d/%Y')
89
+
90
+ # bad full dates
91
+ @revs.get_full_date('1966-14-11').should be_falsey# bad month
92
+ @revs.get_full_date('1966\4\11').should be_falsey# slashes are the wrong way
93
+ @revs.get_full_date('bogus').should be_falsey# crap string
94
+ @revs.get_full_date('').should be_falsey# blank
95
+ @revs.get_full_date('1965').should be_falsey# only the year
96
+ @revs.get_full_date('1965-68').should be_falsey# range of years
97
+ @revs.get_full_date('1965,1968').should be_falsey# multiple years
98
+ @revs.get_full_date('1965|1968').should be_falsey# multiple years
99
+ @revs.get_full_date('1965-1968').should be_falsey# multiple years
100
+ @revs.get_full_date('1965-8').should be_falsey# multiple years
89
101
  end
90
102
 
91
103
  it "should indicate if we have a valid year" do
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.6
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Mangiafico