kronos 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/kronos.gemspec +2 -2
- data/lib/kronos.rb +3 -2
- data/spec/parse_spec.rb +8 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
data/kronos.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{kronos}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David James"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-24}
|
13
13
|
s.description = %q{Kronos provides flexible date parsing. Currently just a thin layer on top of ParseDate.}
|
14
14
|
s.email = %q{djames@sunlightfoundation.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/kronos.rb
CHANGED
@@ -7,11 +7,12 @@ class Kronos
|
|
7
7
|
IGNORE_PATTERN = Regexp.compile("^prior")
|
8
8
|
|
9
9
|
def parse(string)
|
10
|
-
if string =~
|
10
|
+
if string.nil? || string =~ IGNORE_PATTERN
|
11
|
+
nil # do nothing
|
12
|
+
elsif string =~ /^\d{4}$/
|
11
13
|
self.year = string.to_i
|
12
14
|
elsif string =~ /^[']?(\d{2})$/
|
13
15
|
self.year = to_full_year($1.to_i)
|
14
|
-
elsif string =~ IGNORE_PATTERN
|
15
16
|
else
|
16
17
|
values = ParseDate.parsedate(string)
|
17
18
|
if values[0]
|
data/spec/parse_spec.rb
CHANGED
@@ -120,6 +120,14 @@ describe "Kronos" do
|
|
120
120
|
}
|
121
121
|
end
|
122
122
|
|
123
|
+
it "nil" do
|
124
|
+
c = Kronos.parse(nil)
|
125
|
+
c.year.should == nil
|
126
|
+
c.month.should == nil
|
127
|
+
c.day.should == nil
|
128
|
+
c.to_hash.should == {}
|
129
|
+
end
|
130
|
+
|
123
131
|
it "empty string" do
|
124
132
|
c = Kronos.parse("")
|
125
133
|
c.year.should == nil
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 7
|
9
|
+
version: 0.1.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David James
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-24 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|