timelord 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/timelord.rb +1 -1
- data/spec/timelord_spec.rb +35 -35
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5189616e2ec6e2f443d70bf1aa8140650178939a
|
4
|
+
data.tar.gz: 6e9bc68cbd8295504d112d7fbeb1b4037537c7a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33b865effef5a4b9a072d51d32b296944c5043d9edffe0f705f1e4ef0e2d68499c7a9d51a250f2fc8055f15fb43aec76b4aedbd357c6d43abc69b1a450e951eb
|
7
|
+
data.tar.gz: 1d80dec16533705248e527c9292803e6f277d89384b492557f7b02abd907b764715300a02d7432cc37769219cf311b9b31c5dd5d1aebfb0bf9c95430876c041b
|
data/lib/timelord.rb
CHANGED
data/spec/timelord_spec.rb
CHANGED
@@ -8,81 +8,81 @@ describe Timelord, 'parse' do
|
|
8
8
|
|
9
9
|
it "can set today to a different value" do
|
10
10
|
actual_date = Time.local(2010,12,5,10,5,0)
|
11
|
-
Timelord.parse("today", today: actual_date).
|
11
|
+
expect(Timelord.parse("today", today: actual_date)).to eq actual_date
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns nil when no time is present" do
|
15
|
-
Timelord.parse("No time here").
|
15
|
+
expect(Timelord.parse("No time here")).to eq nil
|
16
16
|
end
|
17
17
|
|
18
18
|
it "parses 'today'" do
|
19
|
-
Timelord.parse("I need to do something today.").
|
19
|
+
expect(Timelord.parse("I need to do something today.")).to eq Date.today
|
20
20
|
end
|
21
21
|
|
22
22
|
it "parses 'tod'" do
|
23
|
-
Timelord.parse("I need to do something tod.").
|
23
|
+
expect(Timelord.parse("I need to do something tod.")).to eq Date.today
|
24
24
|
end
|
25
25
|
|
26
26
|
it "parses 'tomorrow'" do
|
27
27
|
tomorrow = Date.today + 1
|
28
|
-
Timelord.parse("I need to do something tomorrow.").
|
28
|
+
expect(Timelord.parse("I need to do something tomorrow.")).to eq tomorrow
|
29
29
|
end
|
30
30
|
|
31
31
|
it "parses 'tom'" do
|
32
32
|
tomorrow = Date.today + 1
|
33
|
-
Timelord.parse("I need to do something tom.").
|
33
|
+
expect(Timelord.parse("I need to do something tom.")).to eq tomorrow
|
34
34
|
end
|
35
35
|
|
36
36
|
it "does not parse 'monster' as monday" do
|
37
|
-
Timelord.parse("Monster mash").
|
37
|
+
expect(Timelord.parse("Monster mash")).to eq nil
|
38
38
|
end
|
39
39
|
|
40
40
|
it "parses '12 Dec'" do
|
41
41
|
twelth_of_december = Date.civil(2010,12,12)
|
42
|
-
Timelord.parse("On 12 Dec I need to do something.").
|
42
|
+
expect(Timelord.parse("On 12 Dec I need to do something.")).to eq twelth_of_december
|
43
43
|
end
|
44
44
|
|
45
45
|
it "parses 'Dec 12'" do
|
46
46
|
twelth_of_december = Date.civil(2010,12,12)
|
47
|
-
Timelord.parse("On Dec 12 I need to do something.").
|
47
|
+
expect(Timelord.parse("On Dec 12 I need to do something.")).to eq twelth_of_december
|
48
48
|
end
|
49
49
|
|
50
50
|
it "parses American style dates" do
|
51
51
|
first_of_december = Date.today
|
52
|
-
Timelord.parse("On 12/1/2010 I need to do something.", format: :american).
|
52
|
+
expect(Timelord.parse("On 12/1/2010 I need to do something.", format: :american)).to eq first_of_december
|
53
53
|
end
|
54
54
|
|
55
55
|
it "parses Internation style dates by default" do
|
56
56
|
first_of_december = Date.today
|
57
|
-
Timelord.parse("On 1/12/2010 I need to do something.", format: :international).
|
57
|
+
expect(Timelord.parse("On 1/12/2010 I need to do something.", format: :international)).to eq first_of_december
|
58
58
|
end
|
59
59
|
|
60
60
|
it "parses yyyy/mm/dd" do
|
61
61
|
first_of_december = Date.today
|
62
|
-
Timelord.parse("On 2010/12/01 I need to do something.").
|
62
|
+
expect(Timelord.parse("On 2010/12/01 I need to do something.")).to eq first_of_december
|
63
63
|
end
|
64
64
|
|
65
65
|
it "parses yyyy/mm/d" do
|
66
66
|
first_of_december = Date.today
|
67
|
-
Timelord.parse("On 2010/12/1 I need to do something.").
|
67
|
+
expect(Timelord.parse("On 2010/12/1 I need to do something.")).to eq first_of_december
|
68
68
|
end
|
69
69
|
|
70
70
|
it "parses yyyy/m/d" do
|
71
71
|
first_of_january = Date.civil(2010, 1, 1)
|
72
|
-
Timelord.parse("On 2010/1/1 I need to do something.").
|
72
|
+
expect(Timelord.parse("On 2010/1/1 I need to do something.")).to eq first_of_january
|
73
73
|
end
|
74
74
|
|
75
75
|
it "parses yyyy-mm-dd" do
|
76
76
|
first_of_december = Date.today
|
77
|
-
Timelord.parse("On 2010-12-01 I need to do something.").
|
77
|
+
expect(Timelord.parse("On 2010-12-01 I need to do something.")).to eq first_of_december
|
78
78
|
end
|
79
79
|
|
80
80
|
it "parses mm/dd" do
|
81
81
|
first_of_december = Date.today
|
82
|
-
Timelord.parse("On 12/1 I need to do something.", format: :american).
|
83
|
-
Timelord.parse("On 12/01 I need to do something.", format: :american).
|
84
|
-
Timelord.parse("On 1/12 I need to do something.", format: :international).
|
85
|
-
Timelord.parse("On 01/12 I need to do something.", format: :international).
|
82
|
+
expect(Timelord.parse("On 12/1 I need to do something.", format: :american)).to eq first_of_december
|
83
|
+
expect(Timelord.parse("On 12/01 I need to do something.", format: :american)).to eq first_of_december
|
84
|
+
expect(Timelord.parse("On 1/12 I need to do something.", format: :international)).to eq first_of_december
|
85
|
+
expect(Timelord.parse("On 01/12 I need to do something.", format: :international)).to eq first_of_december
|
86
86
|
end
|
87
87
|
|
88
88
|
it "parses formats like 1st,2nd,3rd,4th,25th" do
|
@@ -91,11 +91,11 @@ describe Timelord, 'parse' do
|
|
91
91
|
third_of_december = Date.today + 2
|
92
92
|
forth_of_december = Date.today + 3
|
93
93
|
twenty_fifth_of_december = Date.civil(2010,12,25)
|
94
|
-
Timelord.parse("On the 1st").
|
95
|
-
Timelord.parse("On the 2nd").
|
96
|
-
Timelord.parse("On the 3rd").
|
97
|
-
Timelord.parse("On the 4th").
|
98
|
-
Timelord.parse("On the 25th").
|
94
|
+
expect(Timelord.parse("On the 1st")).to eq first_of_december
|
95
|
+
expect(Timelord.parse("On the 2nd")).to eq second_of_december
|
96
|
+
expect(Timelord.parse("On the 3rd")).to eq third_of_december
|
97
|
+
expect(Timelord.parse("On the 4th")).to eq forth_of_december
|
98
|
+
expect(Timelord.parse("On the 25th")).to eq twenty_fifth_of_december
|
99
99
|
end
|
100
100
|
|
101
101
|
it "parses the day of the week" do
|
@@ -103,34 +103,34 @@ describe Timelord, 'parse' do
|
|
103
103
|
monday = Date.today + 5
|
104
104
|
tuesday = Date.today + 6
|
105
105
|
thursday = Date.today + 1
|
106
|
-
Timelord.parse("On friday do something").
|
107
|
-
Timelord.parse("On Monday do something").
|
108
|
-
Timelord.parse("On fri do something").
|
109
|
-
Timelord.parse("On mon do something").
|
110
|
-
Timelord.parse("On tues do something").
|
111
|
-
Timelord.parse("On thurs do something").
|
106
|
+
expect(Timelord.parse("On friday do something")).to eq friday
|
107
|
+
expect(Timelord.parse("On Monday do something")).to eq monday
|
108
|
+
expect(Timelord.parse("On fri do something")).to eq friday
|
109
|
+
expect(Timelord.parse("On mon do something")).to eq monday
|
110
|
+
expect(Timelord.parse("On tues do something")).to eq tuesday
|
111
|
+
expect(Timelord.parse("On thurs do something")).to eq thursday
|
112
112
|
end
|
113
113
|
|
114
114
|
it "parses the next weekday" do
|
115
115
|
friday = Date.today + 9
|
116
116
|
monday = Date.today + 12
|
117
|
-
Timelord.parse("On next friday do something").
|
118
|
-
Timelord.parse("On next Monday do something").
|
117
|
+
expect(Timelord.parse("On next friday do something")).to eq friday
|
118
|
+
expect(Timelord.parse("On next Monday do something")).to eq monday
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'returns a date in the future' do
|
122
122
|
first_of_january = Date.civil(2011,1,1)
|
123
|
-
Timelord.parse("On 1 Jan I need to do something.").
|
123
|
+
expect(Timelord.parse("On 1 Jan I need to do something.")).to eq first_of_january
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'parses month_name day format' do
|
127
127
|
first_of_march = Date.civil(2011,3,1)
|
128
|
-
Timelord.parse("March 1 I need to do stuff.").
|
128
|
+
expect(Timelord.parse("March 1 I need to do stuff.")).to eq first_of_march
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'parses mm/dd/yy correctly' do
|
132
132
|
oct_12 = Date.civil(2015, 10, 12)
|
133
|
-
Timelord.parse("Stuff 10/12/15", format: :american).
|
133
|
+
expect(Timelord.parse("Stuff 10/12/15", format: :american)).to eq oct_12
|
134
134
|
end
|
135
135
|
|
136
136
|
after do
|