kronos 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/kronos.gemspec +4 -2
- data/lib/kronos.rb +17 -6
- data/spec/spec_helper.rb +1 -0
- data/spec/to_s_spec.rb +33 -0
- data/spec/valid_spec.rb +4 -0
- metadata +5 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
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.6"
|
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-03-
|
12
|
+
s.date = %q{2010-03-17}
|
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 = [
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"spec/parse_spec.rb",
|
31
31
|
"spec/spec.opts",
|
32
32
|
"spec/spec_helper.rb",
|
33
|
+
"spec/to_s_spec.rb",
|
33
34
|
"spec/valid_spec.rb"
|
34
35
|
]
|
35
36
|
s.homepage = %q{http://github.com/djsun/kronos}
|
@@ -42,6 +43,7 @@ Gem::Specification.new do |s|
|
|
42
43
|
"spec/from_hash_spec.rb",
|
43
44
|
"spec/parse_spec.rb",
|
44
45
|
"spec/spec_helper.rb",
|
46
|
+
"spec/to_s_spec.rb",
|
45
47
|
"spec/valid_spec.rb"
|
46
48
|
]
|
47
49
|
|
data/lib/kronos.rb
CHANGED
@@ -29,14 +29,25 @@ class Kronos
|
|
29
29
|
self
|
30
30
|
end
|
31
31
|
|
32
|
+
def to_s
|
33
|
+
s = ""
|
34
|
+
raise "Invalid" unless valid?
|
35
|
+
s << "%04i" % year if year
|
36
|
+
s << "/%02i" % month if month
|
37
|
+
s << "/%02i" % day if day
|
38
|
+
s
|
39
|
+
end
|
40
|
+
|
32
41
|
def valid?
|
33
|
-
if day
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
42
|
+
if day && (!month || !year)
|
43
|
+
false
|
44
|
+
elsif month && !year
|
45
|
+
false
|
46
|
+
elsif !year
|
47
|
+
false
|
48
|
+
else
|
49
|
+
true
|
38
50
|
end
|
39
|
-
true
|
40
51
|
end
|
41
52
|
|
42
53
|
def <(other)
|
data/spec/spec_helper.rb
CHANGED
data/spec/to_s_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "to_s" do
|
4
|
+
|
5
|
+
def new_kronos(year=nil, month=nil, day=nil)
|
6
|
+
k = Kronos.new
|
7
|
+
k.year = year if year
|
8
|
+
k.month = month if month
|
9
|
+
k.day = day if day
|
10
|
+
k
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "2005" do
|
14
|
+
it "should be '2005'" do
|
15
|
+
k = new_kronos(2005)
|
16
|
+
k.to_s.should == '2005'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "Feb. 2005" do
|
21
|
+
it "should be '2005/02'" do
|
22
|
+
k = new_kronos(2005, 2)
|
23
|
+
k.to_s.should == '2005/02'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "Feb. 9, 2005" do
|
28
|
+
it "should be '2005/02/09'" do
|
29
|
+
k = new_kronos(2005, 2, 9)
|
30
|
+
k.to_s.should == '2005/02/09'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/valid_spec.rb
CHANGED
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
|
+
- 6
|
9
|
+
version: 0.1.6
|
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-03-
|
17
|
+
date: 2010-03-17 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- spec/parse_spec.rb
|
55
55
|
- spec/spec.opts
|
56
56
|
- spec/spec_helper.rb
|
57
|
+
- spec/to_s_spec.rb
|
57
58
|
- spec/valid_spec.rb
|
58
59
|
has_rdoc: true
|
59
60
|
homepage: http://github.com/djsun/kronos
|
@@ -90,4 +91,5 @@ test_files:
|
|
90
91
|
- spec/from_hash_spec.rb
|
91
92
|
- spec/parse_spec.rb
|
92
93
|
- spec/spec_helper.rb
|
94
|
+
- spec/to_s_spec.rb
|
93
95
|
- spec/valid_spec.rb
|