nickel 0.0.3 → 0.0.4
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.
- data/License.txt +2 -2
- data/README.rdoc +24 -12
- data/Rakefile +22 -0
- data/lib/nickel/construct.rb +121 -0
- data/lib/nickel/construct_finder.rb +1145 -0
- data/lib/nickel/construct_interpreter.rb +345 -0
- data/lib/nickel/instance_from_hash.rb +13 -0
- data/lib/nickel/nlp.rb +73 -0
- data/lib/nickel/occurrence.rb +90 -0
- data/lib/nickel/query.rb +1143 -0
- data/lib/nickel/query_constants.rb +26 -0
- data/lib/nickel/ruby_ext/calling_method.rb +10 -0
- data/lib/nickel/ruby_ext/to_s2.rb +12 -0
- data/lib/nickel/zdate.rb +503 -0
- data/lib/nickel/ztime.rb +319 -0
- data/lib/nickel.rb +30 -34
- data/nickel.gemspec +30 -10
- data/{test → spec}/nickel_spec.rb +4 -4
- data/test/compare.rb +109 -0
- data/test/nlp_test.rb +813 -0
- data/test/nlp_tests_helper.rb +55 -0
- data/test/zdate_test.rb +43 -0
- data/test/ztime_test.rb +428 -0
- metadata +34 -22
data/test/nlp_test.rb
ADDED
@@ -0,0 +1,813 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
path = File.expand_path(File.dirname(__FILE__))
|
4
|
+
require File.join(path, '..', 'lib', 'nickel.rb')
|
5
|
+
require File.join(path, 'nlp_tests_helper.rb')
|
6
|
+
include Nickel
|
7
|
+
|
8
|
+
# note that ZTime now has the '==' operator, so it won't go through Compare::Objects recursion, meaning we will miss @firm setting, but that is not very important as long as the outcome is correct
|
9
|
+
|
10
|
+
class TestDates < Test::Unit::TestCase
|
11
|
+
include NLPTestsHelper
|
12
|
+
|
13
|
+
def test__today
|
14
|
+
today = Time.local(2008, 8, 25)
|
15
|
+
assert_message NLP.new("do something today", today), "do something"
|
16
|
+
assert_nlp NLP.new("do something today", today),
|
17
|
+
[Occurrence.new(:type => :single, :start_date => ZDate.new("20080825"))]
|
18
|
+
end
|
19
|
+
|
20
|
+
def test__today_at_noon
|
21
|
+
today = Time.local(2008, 8, 25)
|
22
|
+
assert_message NLP.new("there is a movie today at noon", today), "there is a movie"
|
23
|
+
assert_nlp NLP.new("there is a movie today at noon", today),
|
24
|
+
[Occurrence.new(:type => :single, :start_date => ZDate.new("20080825"), :start_time => ZTime.new("120000"))]
|
25
|
+
end
|
26
|
+
|
27
|
+
def test__today_and_tomorrow
|
28
|
+
today = Time.local(2008, 8, 25)
|
29
|
+
assert_message NLP.new("go to work today and tomorrow", today), "go to work"
|
30
|
+
assert_nlp NLP.new("go to work today and tomorrow", today),
|
31
|
+
[
|
32
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080825")),
|
33
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080826"))
|
34
|
+
]
|
35
|
+
end
|
36
|
+
|
37
|
+
def test__oct_5_and_oct_23
|
38
|
+
today = Time.local(2008, 8, 25)
|
39
|
+
assert_message NLP.new("Appointments with dentist are on oct 5 and oct 23rd", today), "Appointments with dentist"
|
40
|
+
assert_nlp NLP.new("Appointments with dentist are on oct 5 and oct 23rd", today),
|
41
|
+
[
|
42
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20081005")),
|
43
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20081023"))
|
44
|
+
]
|
45
|
+
end
|
46
|
+
|
47
|
+
def test__today_at_noon_and_tomorrow_at_545am
|
48
|
+
today = Time.local(2008, 8, 25)
|
49
|
+
assert_message NLP.new("today at noon and tomorrow at 5:45 am there is an office meeting", today), "there is an office meeting"
|
50
|
+
assert_message NLP.new("office meeting today at noon and tomorrow at 5:45 am", today), "office meeting"
|
51
|
+
assert_nlp NLP.new("office meeting today at noon and tomorrow at 5:45 am", today),
|
52
|
+
[
|
53
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080825"), :start_time => ZTime.new("120000")),
|
54
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080826"), :start_time => ZTime.new("054500",:am))
|
55
|
+
]
|
56
|
+
end
|
57
|
+
|
58
|
+
def test__noon_today_and_545am_tomorrow
|
59
|
+
today = Time.local(2008, 8, 25)
|
60
|
+
assert_message NLP.new("some shit to do at noon today and 545am tomorrow", today), "some shit to do"
|
61
|
+
assert_nlp NLP.new("some shit to do at noon today and 545am tomorrow", today),
|
62
|
+
[
|
63
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080825"), :start_time => ZTime.new("120000")),
|
64
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080826"), :start_time => ZTime.new("054500",:am))
|
65
|
+
]
|
66
|
+
end
|
67
|
+
|
68
|
+
def test__tomorrow_and_thursday
|
69
|
+
now = Time.local(2008, 2, 29, 12, 34, 56)
|
70
|
+
assert_message NLP.new("go to the park tomorrow and thursday with the dog", now), "go to the park with the dog"
|
71
|
+
assert_nlp NLP.new("go to the park tomorrow and thursday with the dog", now),
|
72
|
+
[
|
73
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080301")),
|
74
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080306"))
|
75
|
+
]
|
76
|
+
end
|
77
|
+
|
78
|
+
def test__tomorrow_at_1am_and_from_2am_to_5pm_and_thursday_at_1pm
|
79
|
+
now = Time.local(2008, 2, 29)
|
80
|
+
assert_message NLP.new("how fucking awesome tomorrow at 1am and from 2am to 5pm and thursday at 1pm is this", now), "how fucking awesome is this"
|
81
|
+
assert_nlp NLP.new("how fucking awesome tomorrow at 1am and from 2am to 5pm and thursday at 1pm is this", now),
|
82
|
+
[
|
83
|
+
Occurrence.new(:type => :single,
|
84
|
+
:start_date => ZDate.new("20080301"),
|
85
|
+
:start_time => ZTime.new("010000",:am)),
|
86
|
+
|
87
|
+
Occurrence.new(:type => :single,
|
88
|
+
:start_date => ZDate.new("20080301"),
|
89
|
+
:start_time => ZTime.new("020000",:am),
|
90
|
+
:end_time => ZTime.new("050000", :pm)),
|
91
|
+
|
92
|
+
Occurrence.new(:type => :single,
|
93
|
+
:start_date => ZDate.new("20080306"),
|
94
|
+
:start_time => ZTime.new("010000", :pm))
|
95
|
+
]
|
96
|
+
end
|
97
|
+
|
98
|
+
def test__monday_tuesday_and_wednesday
|
99
|
+
now = Time.local(2008, 9, 10)
|
100
|
+
assert_message NLP.new("soccer practice monday tuesday and wednesday with susan", now), "soccer practice with susan"
|
101
|
+
assert_nlp NLP.new("soccer practice monday tuesday and wednesday with susan", now),
|
102
|
+
[
|
103
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080915")),
|
104
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080916")),
|
105
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080917"))
|
106
|
+
]
|
107
|
+
end
|
108
|
+
|
109
|
+
def test__monday_and_wednesday_at_4pm
|
110
|
+
now = Time.local(2008, 9, 10)
|
111
|
+
assert_message NLP.new("monday and wednesday at 4pm I have guitar lessons", now), "I have guitar lessons"
|
112
|
+
assert_nlp NLP.new("monday and wednesday at 4pm I have guitar lessons", now),
|
113
|
+
[
|
114
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080915"), :start_time => ZTime.new("4", :pm)),
|
115
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080917"), :start_time => ZTime.new("4", :pm))
|
116
|
+
]
|
117
|
+
end
|
118
|
+
|
119
|
+
def test__4pm_on_monday_and_wednesday
|
120
|
+
now = Time.local(2008, 9, 10)
|
121
|
+
assert_message NLP.new("meet with so and so 4pm on monday and wednesday", now), "meet with so and so"
|
122
|
+
assert_nlp NLP.new("meet with so and so 4pm on monday and wednesday", now),
|
123
|
+
[
|
124
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080915"), :start_time => ZTime.new("4", :pm)),
|
125
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080917"), :start_time => ZTime.new("4", :pm))
|
126
|
+
]
|
127
|
+
end
|
128
|
+
|
129
|
+
def test__this_sunday
|
130
|
+
now = Time.local(2008, 8, 25)
|
131
|
+
assert_message NLP.new("flight this sunday on American", now), "flight on American"
|
132
|
+
assert_nlp NLP.new("flight this sunday on American", now),
|
133
|
+
[Occurrence.new(:type => :single, :start_date => ZDate.new("20080831"))]
|
134
|
+
end
|
135
|
+
|
136
|
+
def test__this_sunday_9_dash_5am
|
137
|
+
now = Time.local(2007, 11, 25)
|
138
|
+
assert_message NLP.new("Flight to Miami this sunday 9-5am on Jet Blue", now), "Flight to Miami on Jet Blue"
|
139
|
+
assert_nlp NLP.new("Flight to Miami this sunday 9-5am on Jet Blue", now),
|
140
|
+
[
|
141
|
+
Occurrence.new(:type => :single,
|
142
|
+
:start_date => ZDate.new("20071125"),
|
143
|
+
:start_time => ZTime.new("210000"),
|
144
|
+
:end_time => ZTime.new("05", :am))
|
145
|
+
]
|
146
|
+
end
|
147
|
+
|
148
|
+
def test__this_sunday_9_dash_5
|
149
|
+
now = Time.local(2007, 11, 25)
|
150
|
+
assert_message NLP.new("Go to the park this sunday 9-5", now), "Go to the park"
|
151
|
+
assert_nlp NLP.new("Go to the park this sunday 9-5", now),
|
152
|
+
[
|
153
|
+
Occurrence.new(:type => :single,
|
154
|
+
:start_date => ZDate.new("20071125"),
|
155
|
+
:start_time => ZTime.new("090000"),
|
156
|
+
:end_time => ZTime.new("170000"))
|
157
|
+
]
|
158
|
+
end
|
159
|
+
|
160
|
+
def test__today_at_10_11_12_and_1_to_5
|
161
|
+
now = Time.local(2008, 9, 10)
|
162
|
+
assert_message NLP.new("movie showings are today at 10, 11, 12, and 1 to 5", now), "movie showings"
|
163
|
+
assert_nlp NLP.new("movie showings are today at 10, 11, 12, and 1 to 5", now),
|
164
|
+
[
|
165
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("100000")),
|
166
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("110000")),
|
167
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("120000")),
|
168
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("130000"), :end_time => ZTime.new("170000"))
|
169
|
+
]
|
170
|
+
end
|
171
|
+
|
172
|
+
def test__today_at_10_11_12_1
|
173
|
+
now = Time.local(2008, 9, 10)
|
174
|
+
assert_message NLP.new("Games today at 10, 11, 12, 1", now), "Games"
|
175
|
+
assert_nlp NLP.new("Games today at 10, 11, 12, 1", now),
|
176
|
+
[
|
177
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("100000")),
|
178
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("110000")),
|
179
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("120000")),
|
180
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("130000"))
|
181
|
+
]
|
182
|
+
end
|
183
|
+
|
184
|
+
def test__today_from_8_to_4_and_9_to_5
|
185
|
+
assert_nlp NLP.new("today from 8 to 4 and 9 to 5", Time.local(2008, 9, 10)),
|
186
|
+
[
|
187
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("080000"), :end_time => ZTime.new("160000")),
|
188
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("090000"), :end_time => ZTime.new("17"))
|
189
|
+
]
|
190
|
+
end
|
191
|
+
|
192
|
+
def test__today_from_9_to_5pm_and_8am_to_4
|
193
|
+
assert_nlp NLP.new("today from 9 to 5pm and 8am to 4", Time.local(2008, 9, 10)),
|
194
|
+
[
|
195
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("080000"), :end_time => ZTime.new("160000")),
|
196
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("090000"), :end_time => ZTime.new("17"))
|
197
|
+
]
|
198
|
+
end
|
199
|
+
|
200
|
+
def test__today_at_11am_2_and_3_and_tomorrow_from_2_to_6pm
|
201
|
+
assert_nlp NLP.new("today at 11am, 2 and 3, and tomorrow from 2 to 6pm", Time.local(2008, 9, 10)),
|
202
|
+
[
|
203
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("11", :am)),
|
204
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("2", :pm)),
|
205
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080910"), :start_time => ZTime.new("3", :pm)),
|
206
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20080911"), :start_time => ZTime.new("2", :pm), :end_time => ZTime.new("6", :pm))
|
207
|
+
]
|
208
|
+
end
|
209
|
+
|
210
|
+
def test__next_monday
|
211
|
+
assert_nlp NLP.new("next monday", Time.local(2008, 10, 27)), [Occurrence.new(:type => :single, :start_date => ZDate.new("20081103"))]
|
212
|
+
end
|
213
|
+
|
214
|
+
def test__a_week_from_today
|
215
|
+
now = Time.local(2009, 01, 01)
|
216
|
+
assert_message NLP.new("Flight is a week from today", now), "Flight"
|
217
|
+
assert_nlp NLP.new("Flight is a week from today", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20090108"))]
|
218
|
+
end
|
219
|
+
|
220
|
+
def test__two_weeks_from_tomorrow
|
221
|
+
now = Time.local(2008, 12, 24)
|
222
|
+
assert_message NLP.new("Bill is due two weeks from tomorrow", now), "Bill is due"
|
223
|
+
assert_nlp NLP.new("Bill is due two weeks from tomorrow", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20090108"))]
|
224
|
+
end
|
225
|
+
|
226
|
+
def test__two_months_from_now
|
227
|
+
now = Time.local(2008, 12, 24)
|
228
|
+
assert_message NLP.new("Tryouts are two months from now", now), "Tryouts"
|
229
|
+
assert_nlp NLP.new("Tryouts are two months from now", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20090224"))]
|
230
|
+
end
|
231
|
+
|
232
|
+
def test__october_2nd
|
233
|
+
now = Time.local(2008, 1, 30)
|
234
|
+
assert_message NLP.new("baseball game is on october second", now), "baseball game"
|
235
|
+
assert_message NLP.new("baseball game is on 10/2", now), "baseball game"
|
236
|
+
assert_message NLP.new("baseball game is on 10/2/08", now), "baseball game"
|
237
|
+
assert_message NLP.new("baseball game is on 10/2/2008", now), "baseball game"
|
238
|
+
assert_message NLP.new("baseball game is on october 2nd 08", now), "baseball game"
|
239
|
+
assert_message NLP.new("baseball game is on october 2nd 2008", now), "baseball game"
|
240
|
+
assert_nlp NLP.new("baseball game is on october second", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20081002"))]
|
241
|
+
assert_nlp NLP.new("baseball game is on 10/2", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20081002"))]
|
242
|
+
assert_nlp NLP.new("baseball game is on 10/2/08", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20081002"))]
|
243
|
+
assert_nlp NLP.new("baseball game is on 10/2/2008", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20081002"))]
|
244
|
+
assert_nlp NLP.new("baseball game is on october 2nd 08", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20081002"))]
|
245
|
+
assert_nlp NLP.new("baseball game is on october 2nd 2008", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20081002"))]
|
246
|
+
end
|
247
|
+
|
248
|
+
def test__last_monday_this_month
|
249
|
+
now = Time.local(2008, 8, 25)
|
250
|
+
assert_nlp NLP.new("last monday this month", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20080825"))]
|
251
|
+
assert_nlp NLP.new("the last monday of this month", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20080825"))]
|
252
|
+
end
|
253
|
+
|
254
|
+
def test__third_monday_next_month
|
255
|
+
now = Time.local(2008, 8, 25)
|
256
|
+
assert_nlp NLP.new("third monday next month", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20080915"))]
|
257
|
+
assert_nlp NLP.new("the third monday next month", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20080915"))]
|
258
|
+
end
|
259
|
+
|
260
|
+
def test__the_28th
|
261
|
+
now = Time.local(2010, 03, 20)
|
262
|
+
assert_message NLP.new("baseball game is on the twentyeighth", now), "baseball game"
|
263
|
+
assert_message NLP.new("baseball game is on the 28th of this month", now), "baseball game"
|
264
|
+
assert_nlp NLP.new("the twentyeigth", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20100328"))]
|
265
|
+
assert_nlp NLP.new("28th", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20100328"))]
|
266
|
+
assert_nlp NLP.new("28", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20100328"))]
|
267
|
+
assert_nlp NLP.new("the 28th of this month", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20100328"))]
|
268
|
+
assert_nlp NLP.new("28th of this month", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20100328"))]
|
269
|
+
assert_nlp NLP.new("the 28th this month", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20100328"))]
|
270
|
+
end
|
271
|
+
|
272
|
+
def test__the_28th_next_month
|
273
|
+
now = Time.local(2008, 12, 31, 23, 05, 59)
|
274
|
+
assert_nlp NLP.new("next month 28th", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20090128"))]
|
275
|
+
assert_nlp NLP.new("28th next month", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20090128"))]
|
276
|
+
assert_nlp NLP.new("the 28th next month", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20090128"))]
|
277
|
+
assert_nlp NLP.new("28th of next month", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20090128"))]
|
278
|
+
assert_nlp NLP.new("the 28th of next month", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20090128"))]
|
279
|
+
end
|
280
|
+
|
281
|
+
def test__in_5_days_weeks_months
|
282
|
+
now = Time.local(2008, 9, 11)
|
283
|
+
assert_nlp NLP.new("5 days from now", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20080916"))]
|
284
|
+
assert_nlp NLP.new("in 5 days", Time.local(2008, 9, 30)), [Occurrence.new(:type => :single, :start_date => ZDate.new("20081005"))]
|
285
|
+
assert_nlp NLP.new("5 weeks from now", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20081016"))]
|
286
|
+
assert_nlp NLP.new("in 5 weeks", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20081016"))]
|
287
|
+
assert_nlp NLP.new("5 months from now", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20090211"))]
|
288
|
+
assert_nlp NLP.new("in 5 months", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20090211"))]
|
289
|
+
end
|
290
|
+
|
291
|
+
def test__in_5_minutes_hours
|
292
|
+
now = Time.local(2008, 9, 11)
|
293
|
+
|
294
|
+
assert_nlp NLP.new("5 minutes from now", now), [Occurrence.new(:type => :single,
|
295
|
+
:start_date => ZDate.new("20080911"),
|
296
|
+
:start_time => ZTime.new("000500"))]
|
297
|
+
|
298
|
+
assert_nlp NLP.new("5 hours from now", now), [Occurrence.new(:type => :single,
|
299
|
+
:start_date => ZDate.new("20080911"),
|
300
|
+
:start_time => ZTime.new("050000"))]
|
301
|
+
|
302
|
+
assert_nlp NLP.new("24 hours from now", now), [Occurrence.new(:type => :single,
|
303
|
+
:start_date => ZDate.new("20080912"),
|
304
|
+
:start_time => ZTime.new("000000"))]
|
305
|
+
|
306
|
+
assert_nlp NLP.new("in 5 minutes", now), [Occurrence.new(:type => :single,
|
307
|
+
:start_date => ZDate.new("20080911"),
|
308
|
+
:start_time => ZTime.new("000500"))]
|
309
|
+
|
310
|
+
assert_nlp NLP.new("in 5 hours", now), [Occurrence.new(:type => :single,
|
311
|
+
:start_date => ZDate.new("20080911"),
|
312
|
+
:start_time => ZTime.new("050000"))]
|
313
|
+
end
|
314
|
+
|
315
|
+
def test__tomorrow_through_sunday
|
316
|
+
assert_nlp NLP.new("tomorrow through sunday", Time.local(2008, 9, 18)), [Occurrence.new(:type => :daily,
|
317
|
+
:start_date => ZDate.new("20080919"),
|
318
|
+
:end_date => ZDate.new("20080921"),
|
319
|
+
:interval => 1)]
|
320
|
+
end
|
321
|
+
|
322
|
+
def test__tomorrow_through_sunday_from_9_to_5
|
323
|
+
assert_nlp NLP.new("tomorrow through sunday from 9 to 5", Time.local(2008, 9, 18)),
|
324
|
+
[
|
325
|
+
Occurrence.new(:type => :daily,
|
326
|
+
:start_date => ZDate.new("20080919"),
|
327
|
+
:end_date => ZDate.new("20080921"),
|
328
|
+
:start_time => ZTime.new("09"),
|
329
|
+
:end_time => ZTime.new("17"),
|
330
|
+
:interval => 1)
|
331
|
+
]
|
332
|
+
end
|
333
|
+
|
334
|
+
def test__9_to_5_tomorrow_through_sunday
|
335
|
+
assert_nlp NLP.new("9 to 5 tomorrow through sunday", Time.local(2008, 9, 18)),
|
336
|
+
[
|
337
|
+
Occurrence.new(:type => :daily,
|
338
|
+
:start_date => ZDate.new("20080919"),
|
339
|
+
:end_date => ZDate.new("20080921"),
|
340
|
+
:start_time => ZTime.new("09"),
|
341
|
+
:end_time => ZTime.new("17"),
|
342
|
+
:interval => 1)
|
343
|
+
]
|
344
|
+
end
|
345
|
+
|
346
|
+
def test__october_2nd_through_5th
|
347
|
+
now = Time.local(2008, 9, 18)
|
348
|
+
|
349
|
+
assert_nlp NLP.new("october 2nd through 5th", now), [ Occurrence.new(:type => :daily,
|
350
|
+
:start_date => ZDate.new("20081002"),
|
351
|
+
:end_date => ZDate.new("20081005"),
|
352
|
+
:interval => 1) ]
|
353
|
+
|
354
|
+
assert_nlp NLP.new("october 2nd through october 5th", now), [ Occurrence.new(:type => :daily,
|
355
|
+
:start_date => ZDate.new("20081002"),
|
356
|
+
:end_date => ZDate.new("20081005"),
|
357
|
+
:interval => 1) ]
|
358
|
+
|
359
|
+
assert_nlp NLP.new("10/2 to 10/5", now), [ Occurrence.new(:type => :daily,
|
360
|
+
:start_date => ZDate.new("20081002"),
|
361
|
+
:end_date => ZDate.new("20081005"),
|
362
|
+
:interval => 1) ]
|
363
|
+
|
364
|
+
assert_nlp NLP.new("oct 2 until 5", now), [ Occurrence.new(:type => :daily,
|
365
|
+
:start_date => ZDate.new("20081002"),
|
366
|
+
:end_date => ZDate.new("20081005"),
|
367
|
+
:interval => 1) ]
|
368
|
+
|
369
|
+
assert_nlp NLP.new("oct 2 until oct 5", now), [ Occurrence.new(:type => :daily,
|
370
|
+
:start_date => ZDate.new("20081002"),
|
371
|
+
:end_date => ZDate.new("20081005"),
|
372
|
+
:interval => 1) ]
|
373
|
+
|
374
|
+
assert_nlp NLP.new("oct 2-oct 5", now), [ Occurrence.new(:type => :daily,
|
375
|
+
:start_date => ZDate.new("20081002"),
|
376
|
+
:end_date => ZDate.new("20081005"),
|
377
|
+
:interval => 1) ]
|
378
|
+
|
379
|
+
assert_nlp NLP.new("october 2-5", now), [ Occurrence.new(:type => :daily,
|
380
|
+
:start_date => ZDate.new("20081002"),
|
381
|
+
:end_date => ZDate.new("20081005"),
|
382
|
+
:interval => 1) ]
|
383
|
+
|
384
|
+
assert_nlp NLP.new("october 2nd-5th", now), [ Occurrence.new(:type => :daily,
|
385
|
+
:start_date => ZDate.new("20081002"),
|
386
|
+
:end_date => ZDate.new("20081005"),
|
387
|
+
:interval => 1) ]
|
388
|
+
|
389
|
+
assert_nlp NLP.new("october 2nd-5th from 9 to 5am", now), [ Occurrence.new(:type => :daily,
|
390
|
+
:start_date => ZDate.new("20081002"),
|
391
|
+
:end_date => ZDate.new("20081005"),
|
392
|
+
:interval => 1,
|
393
|
+
:start_time => ZTime.new("21"),
|
394
|
+
:end_time => ZTime.new("05")) ]
|
395
|
+
|
396
|
+
assert_nlp NLP.new("october 2nd-5th every day from 9 to 5am", now), [ Occurrence.new(:type => :daily,
|
397
|
+
:start_date => ZDate.new("20081002"),
|
398
|
+
:end_date => ZDate.new("20081005"),
|
399
|
+
:interval => 1,
|
400
|
+
:start_time => ZTime.new("21"),
|
401
|
+
:end_time => ZTime.new("05")) ]
|
402
|
+
end
|
403
|
+
|
404
|
+
def test__every_monday
|
405
|
+
assert_nlp NLP.new("every monday", Time.local(2008, 9, 18)), [Occurrence.new(:type => :weekly,
|
406
|
+
:day_of_week => 0,
|
407
|
+
:interval => 1,
|
408
|
+
:start_date => ZDate.new("20080922"))]
|
409
|
+
end
|
410
|
+
|
411
|
+
def test__every_monday_and_wednesday
|
412
|
+
assert_nlp NLP.new("every monday and wednesday", Time.local(2008, 9, 18)),
|
413
|
+
[
|
414
|
+
Occurrence.new(:type => :weekly, :day_of_week => 0, :interval => 1, :start_date => ZDate.new("20080922")),
|
415
|
+
Occurrence.new(:type => :weekly, :day_of_week => 2, :interval => 1, :start_date => ZDate.new("20080924"))
|
416
|
+
]
|
417
|
+
end
|
418
|
+
|
419
|
+
def test__every_other_monday_and_wednesday
|
420
|
+
assert_nlp NLP.new("every other monday and wednesday", Time.local(2008, 9, 18)),
|
421
|
+
[
|
422
|
+
Occurrence.new(:type => :weekly, :day_of_week => 0, :interval => 2, :start_date => ZDate.new("20080922")),
|
423
|
+
Occurrence.new(:type => :weekly, :day_of_week => 2, :interval => 2, :start_date => ZDate.new("20080924"))
|
424
|
+
]
|
425
|
+
end
|
426
|
+
|
427
|
+
# Fail here!
|
428
|
+
# def test__every_monday_at_2pm_and_wednesday_at_4pm
|
429
|
+
# assert_nlp NLP.new("every monday at 2pm and wednesday at 4pm", Time.local(2008, 9, 18)),
|
430
|
+
# [
|
431
|
+
# Occurrence.new(:type => :weekly, :day_of_week => 0, :interval => 1, :start_date => ZDate.new("20080922"), :start_time => ZTime.new("2", :pm)),
|
432
|
+
# Occurrence.new(:type => :weekly, :day_of_week => 2, :interval => 1, :start_date => ZDate.new("20080924"), :start_time => ZTime.new("4", :pm))
|
433
|
+
# ]
|
434
|
+
# end
|
435
|
+
|
436
|
+
def test__every_monday_at_2pm_and_every_wednesday_at_4pm
|
437
|
+
assert_nlp NLP.new("every monday at 2pm and every wednesday at 4pm", Time.local(2008, 9, 18)),
|
438
|
+
[
|
439
|
+
Occurrence.new(:type => :weekly, :day_of_week => 0, :interval => 1, :start_time => ZTime.new("2", :pm), :start_date => ZDate.new("20080922")),
|
440
|
+
Occurrence.new(:type => :weekly, :day_of_week => 2, :interval => 1, :start_time => ZTime.new("4", :pm), :start_date => ZDate.new("20080924"))
|
441
|
+
]
|
442
|
+
end
|
443
|
+
|
444
|
+
def test__every_monday_every_wednesday
|
445
|
+
assert_nlp NLP.new("every monday every wednesday", Time.local(2008, 9, 18)),
|
446
|
+
[
|
447
|
+
Occurrence.new(:type => :weekly, :day_of_week => 0, :interval => 1, :start_date => ZDate.new("20080922")),
|
448
|
+
Occurrence.new(:type => :weekly, :day_of_week => 2, :interval => 1, :start_date => ZDate.new("20080924"))
|
449
|
+
]
|
450
|
+
end
|
451
|
+
|
452
|
+
def test__the_22nd_of_every_month
|
453
|
+
assert_nlp NLP.new("the 22nd of every month", Time.local(2008, 9, 18)),
|
454
|
+
[
|
455
|
+
Occurrence.new(:type => :datemonthly, :date_of_month => 22, :interval => 1, :start_date => ZDate.new("20080922"))
|
456
|
+
]
|
457
|
+
end
|
458
|
+
|
459
|
+
def test__the_first_friday_of_every_month
|
460
|
+
assert_nlp NLP.new("the first friday of every month", Time.local(2008, 9, 18)),
|
461
|
+
[
|
462
|
+
Occurrence.new(:type => :daymonthly, :week_of_month => 1, :day_of_week => 4, :interval => 1, :start_date => ZDate.new("20081003"))
|
463
|
+
]
|
464
|
+
end
|
465
|
+
|
466
|
+
def test__the_second_tuesday_of_every_month_at_5pm
|
467
|
+
assert_nlp NLP.new("the second tuesday of every month at 5pm", Time.local(2008, 9, 24)),
|
468
|
+
[
|
469
|
+
Occurrence.new(:type => :daymonthly,
|
470
|
+
:week_of_month => 2,
|
471
|
+
:day_of_week => 1,
|
472
|
+
:interval => 1,
|
473
|
+
:start_date => ZDate.new("20081014"),
|
474
|
+
:start_time => ZTime.new("5", :pm))
|
475
|
+
]
|
476
|
+
end
|
477
|
+
|
478
|
+
def test__the_first_tuesday_of_every_month_at_4pm_and_5pm_and_the_second_tuesday_of_every_month_at_5pm
|
479
|
+
now = Time.local(2008, 9, 24)
|
480
|
+
assert_nlp NLP.new("the first tuesday of every month at 4pm and 5pm, the second tuesday of every month at 5pm", now),
|
481
|
+
[
|
482
|
+
Occurrence.new(:type => :daymonthly,
|
483
|
+
:week_of_month => 1,
|
484
|
+
:day_of_week => 1,
|
485
|
+
:interval => 1,
|
486
|
+
:start_date => ZDate.new("20081007"),
|
487
|
+
:start_time => ZTime.new("4", :pm)),
|
488
|
+
|
489
|
+
Occurrence.new(:type => :daymonthly,
|
490
|
+
:week_of_month => 1,
|
491
|
+
:day_of_week => 1,
|
492
|
+
:interval => 1,
|
493
|
+
:start_date => ZDate.new("20081007"),
|
494
|
+
:start_time => ZTime.new("5", :pm)),
|
495
|
+
|
496
|
+
Occurrence.new(:type => :daymonthly,
|
497
|
+
:week_of_month => 2,
|
498
|
+
:day_of_week => 1,
|
499
|
+
:interval => 1,
|
500
|
+
:start_date => ZDate.new("20081014"),
|
501
|
+
:start_time => ZTime.new("5", :pm))
|
502
|
+
]
|
503
|
+
end
|
504
|
+
|
505
|
+
def test_every_sunday_in_december
|
506
|
+
assert_nlp NLP.new("every sunday in december", Time.local(2008, 9, 24)),
|
507
|
+
[
|
508
|
+
Occurrence.new(:type => :weekly,
|
509
|
+
:day_of_week => 6,
|
510
|
+
:interval => 1,
|
511
|
+
:start_date => ZDate.new("20081207"),
|
512
|
+
:end_date => ZDate.new("20081228"))
|
513
|
+
]
|
514
|
+
end
|
515
|
+
|
516
|
+
def test_every_monday_until_december
|
517
|
+
assert_nlp NLP.new("every monday until december", Time.local(2008, 9, 24)),
|
518
|
+
[
|
519
|
+
Occurrence.new(:type => :weekly,
|
520
|
+
:day_of_week => 0,
|
521
|
+
:interval => 1,
|
522
|
+
:start_date => ZDate.new("20080929"),
|
523
|
+
:end_date => ZDate.new("20081124"))
|
524
|
+
]
|
525
|
+
end
|
526
|
+
|
527
|
+
def test_every_monday_next_month
|
528
|
+
assert_nlp NLP.new("every monday next month", Time.local(2008, 9, 24)),
|
529
|
+
[
|
530
|
+
Occurrence.new(:type => :weekly,
|
531
|
+
:day_of_week => 0,
|
532
|
+
:interval => 1,
|
533
|
+
:start_date => ZDate.new("20081006"),
|
534
|
+
:end_date => ZDate.new("20081027"))
|
535
|
+
]
|
536
|
+
end
|
537
|
+
|
538
|
+
def test_everyday_next_month
|
539
|
+
assert_nlp NLP.new("everyday next month", Time.local(2008, 12, 24)),
|
540
|
+
[
|
541
|
+
Occurrence.new(:type => :daily, :interval => 1, :start_date => ZDate.new("20090101"), :end_date => ZDate.new("20090131"))
|
542
|
+
]
|
543
|
+
end
|
544
|
+
|
545
|
+
def test_in_the_next_two_days
|
546
|
+
assert_nlp NLP.new("in the next two days", Time.local(2007, 12, 29)),
|
547
|
+
[
|
548
|
+
Occurrence.new(:type => :daily, :interval => 1, :start_date => ZDate.new("20071229"), :end_date => ZDate.new("20071231"))
|
549
|
+
]
|
550
|
+
end
|
551
|
+
|
552
|
+
def test_for_three_days
|
553
|
+
assert_nlp NLP.new("for three days", Time.local(2007, 12, 29)),
|
554
|
+
[
|
555
|
+
Occurrence.new(:type => :daily, :interval => 1, :start_date => ZDate.new("20071229"), :end_date => ZDate.new("20080101"))
|
556
|
+
]
|
557
|
+
|
558
|
+
assert_nlp NLP.new("for the next three days", Time.local(2007, 12, 29)),
|
559
|
+
[
|
560
|
+
Occurrence.new(:type => :daily, :interval => 1, :start_date => ZDate.new("20071229"), :end_date => ZDate.new("20080101"))
|
561
|
+
]
|
562
|
+
end
|
563
|
+
|
564
|
+
def test_for_the_next_1_day
|
565
|
+
now = Time.local(2007, 12, 29)
|
566
|
+
assert_message NLP.new("blah for the next 1 day", now), "blah"
|
567
|
+
assert_nlp NLP.new("blah for the next 1 day", now),
|
568
|
+
[
|
569
|
+
Occurrence.new(:type => :daily, :interval => 1, :start_date => ZDate.new("20071229"), :end_date => ZDate.new("20071230"))
|
570
|
+
]
|
571
|
+
end
|
572
|
+
|
573
|
+
def test_this_week
|
574
|
+
now = Time.local(2008, 9, 25)
|
575
|
+
assert_nlp NLP.new("this week", now),
|
576
|
+
[
|
577
|
+
Occurrence.new(:type => :daily, :interval => 1, :start_date => ZDate.new("20080925"), :end_date => ZDate.new("20081002"))
|
578
|
+
]
|
579
|
+
|
580
|
+
assert_nlp NLP.new("every day this week", now),
|
581
|
+
[
|
582
|
+
Occurrence.new(:type => :daily, :interval => 1, :start_date => ZDate.new("20080925"), :end_date => ZDate.new("20081002"))
|
583
|
+
]
|
584
|
+
end
|
585
|
+
|
586
|
+
def test_next_week
|
587
|
+
now = Time.local(2008, 9, 25)
|
588
|
+
assert_nlp NLP.new("next week", now),
|
589
|
+
[
|
590
|
+
Occurrence.new(:type => :daily, :interval => 1, :start_date => ZDate.new("20081002"), :end_date => ZDate.new("20081009"))
|
591
|
+
]
|
592
|
+
|
593
|
+
assert_nlp NLP.new("every day next week", now),
|
594
|
+
[
|
595
|
+
Occurrence.new(:type => :daily, :interval => 1, :start_date => ZDate.new("20081002"), :end_date => ZDate.new("20081009"))
|
596
|
+
]
|
597
|
+
end
|
598
|
+
|
599
|
+
def test_go_to_the_park_tomorrow_and_also_on_thursday_with_the_dog
|
600
|
+
now = Time.local(2008, 10, 28)
|
601
|
+
|
602
|
+
assert_message NLP.new("go to the park tomorrow and also on thursday with the dog", now), "go to the park with the dog"
|
603
|
+
assert_message NLP.new("go to the park tomorrow and thursday with the dog", now), "go to the park with the dog"
|
604
|
+
assert_message NLP.new("go to the park tomorrow and also thursday with the dog", now), "go to the park with the dog"
|
605
|
+
assert_message NLP.new("go to the park tomorrow and on thursday with the dog", now), "go to the park with the dog"
|
606
|
+
assert_message NLP.new("go to the park tomorrow, thursday with the dog", now), "go to the park with the dog"
|
607
|
+
|
608
|
+
assert_nlp NLP.new("go to the park tomorrow and also on thursday with the dog", now),
|
609
|
+
[
|
610
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20081029")),
|
611
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20081030"))
|
612
|
+
]
|
613
|
+
end
|
614
|
+
|
615
|
+
def test_pick_up_groceries_tomorrow_and_also_the_kids
|
616
|
+
now = Time.local(2008, 10, 28)
|
617
|
+
assert_message NLP.new("pick up groceries tomorrow and also the kids", now), "pick up groceries and also the kids"
|
618
|
+
assert_message NLP.new("pick up groceries tomorrow and the kids", now), "pick up groceries and the kids"
|
619
|
+
assert_nlp NLP.new("pick up groceries tomorrow and also the kids", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20081029"))]
|
620
|
+
end
|
621
|
+
|
622
|
+
def test_all_month
|
623
|
+
NLP::use_date_correction = false
|
624
|
+
|
625
|
+
assert_nlp NLP.new("all month", Time.local(2008, 10, 05)),
|
626
|
+
[
|
627
|
+
Occurrence.new(:type => :daily,
|
628
|
+
:start_date => ZDate.new("20081001"),
|
629
|
+
:end_date => ZDate.new("20081031"),
|
630
|
+
:interval => 1)
|
631
|
+
]
|
632
|
+
|
633
|
+
NLP::use_date_correction = true
|
634
|
+
end
|
635
|
+
|
636
|
+
def test_all_month_date_corrected
|
637
|
+
NLP::use_date_correction = true
|
638
|
+
assert_nlp NLP.new("all month", Time.local(2008, 10, 05)),
|
639
|
+
[
|
640
|
+
Occurrence.new(:type => :daily,
|
641
|
+
:start_date => ZDate.new("20081005"),
|
642
|
+
:end_date => ZDate.new("20081031"),
|
643
|
+
:interval => 1)
|
644
|
+
]
|
645
|
+
end
|
646
|
+
|
647
|
+
def test_week_of_jan_2nd
|
648
|
+
assert_nlp NLP.new("the week of jan 2nd", Time.local(2008, 12, 21)),
|
649
|
+
[
|
650
|
+
Occurrence.new(:type => :daily,
|
651
|
+
:start_date => ZDate.new("20090102"),
|
652
|
+
:end_date => ZDate.new("20090109"),
|
653
|
+
:interval => 1)
|
654
|
+
]
|
655
|
+
end
|
656
|
+
|
657
|
+
def test_week_ending_jan_2nd
|
658
|
+
assert_nlp NLP.new("the week ending jan 2nd", Time.local(2008, 12, 21)),
|
659
|
+
[
|
660
|
+
Occurrence.new(:type => :daily,
|
661
|
+
:start_date => ZDate.new("20081226"),
|
662
|
+
:end_date => ZDate.new("20090102"),
|
663
|
+
:interval => 1)
|
664
|
+
]
|
665
|
+
end
|
666
|
+
|
667
|
+
def test_week_of_the_22nd
|
668
|
+
assert_nlp NLP.new("the week of the 22nd", Time.local(2008, 12, 21)),
|
669
|
+
[
|
670
|
+
Occurrence.new(:type => :daily,
|
671
|
+
:start_date => ZDate.new("20081222"),
|
672
|
+
:end_date => ZDate.new("20081229"),
|
673
|
+
:interval => 1)
|
674
|
+
]
|
675
|
+
end
|
676
|
+
|
677
|
+
# ------------------------------------------------ Tests using date correction start here ------------------------------------------------------
|
678
|
+
# -------------------------------------------- THESE WILL FAIL IF 'NLPv2.use_date_correction' IS OFF -------------------------------------------------
|
679
|
+
def test_dates_across_a_year_boundary
|
680
|
+
now = Time.local(2008, 11, 30)
|
681
|
+
NLP::use_date_correction = true
|
682
|
+
assert_message NLP.new("do something on january first", now), "do something"
|
683
|
+
assert_nlp NLP.new("do something on january first", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20090101"))]
|
684
|
+
end
|
685
|
+
|
686
|
+
def test_the_first_of_the_month
|
687
|
+
now = Time.local(2008, 11, 30)
|
688
|
+
NLP::use_date_correction = true
|
689
|
+
assert_nlp NLP.new("on the first of the month, go to the museum", now), [Occurrence.new(:type => :single, :start_date => ZDate.new("20081201"))]
|
690
|
+
end
|
691
|
+
# ------------------------------------------------ Tests using date correction end here --------------------------------------------------------
|
692
|
+
|
693
|
+
# tests to write
|
694
|
+
# this monday wed fri sat
|
695
|
+
# next monday wed fri sat
|
696
|
+
# monday wed fri sat
|
697
|
+
|
698
|
+
# --------------------------------------------------- NLPv1 tests start here -------------------------------------------------------------
|
699
|
+
def test__october_2nd_2009
|
700
|
+
assert_nlp NLP.new("october 2nd, 2009", Time.local(2008, 1, 01)), [Occurrence.new(:type => :single, :start_date => ZDate.new("20091002"))]
|
701
|
+
end
|
702
|
+
|
703
|
+
def test__the_first_of_each_month
|
704
|
+
assert_nlp NLP.new("the first of each month", Time.local(2008, 1, 01)),
|
705
|
+
[
|
706
|
+
Occurrence.new(:type => :datemonthly,
|
707
|
+
:start_date => ZDate.new("20080101"),
|
708
|
+
:interval => 1,
|
709
|
+
:date_of_month => 1)
|
710
|
+
]
|
711
|
+
|
712
|
+
assert_nlp NLP.new("the first of each month", Time.local(2009, 02, 15)),
|
713
|
+
[
|
714
|
+
Occurrence.new(:type => :datemonthly,
|
715
|
+
:start_date => ZDate.new("20090301"),
|
716
|
+
:interval => 1,
|
717
|
+
:date_of_month => 1)
|
718
|
+
]
|
719
|
+
end
|
720
|
+
|
721
|
+
def test__every_sunday
|
722
|
+
assert_nlp NLP.new("every sunday", Time.local(2008, 12, 30)),
|
723
|
+
[
|
724
|
+
Occurrence.new(:type => :weekly,
|
725
|
+
:start_date => ZDate.new("20090104"),
|
726
|
+
:interval => 1,
|
727
|
+
:day_of_week => 6)
|
728
|
+
]
|
729
|
+
end
|
730
|
+
|
731
|
+
def test__every_month_on_the_22nd_at_2pm
|
732
|
+
assert_nlp NLP.new("every month on the 22nd at 2pm", Time.local(2008, 12, 30)),
|
733
|
+
[
|
734
|
+
Occurrence.new(:type => :datemonthly,
|
735
|
+
:start_date => ZDate.new("20090122"),
|
736
|
+
:interval => 1,
|
737
|
+
:date_of_month => 22,
|
738
|
+
:start_time => ZTime.new("2", :pm))
|
739
|
+
]
|
740
|
+
end
|
741
|
+
|
742
|
+
def test_every_other_saturday_at_noon
|
743
|
+
assert_nlp NLP.new("every other saturday at noon", Time.local(2008, 12, 30)),
|
744
|
+
[
|
745
|
+
Occurrence.new(:type => :weekly,
|
746
|
+
:start_date => ZDate.new("20090103"),
|
747
|
+
:interval => 2,
|
748
|
+
:day_of_week => 5,
|
749
|
+
:start_time => ZTime.new("12", :pm))
|
750
|
+
]
|
751
|
+
end
|
752
|
+
|
753
|
+
def test_every_day_at_midnight
|
754
|
+
assert_nlp NLP.new("every day at midnight", Time.local(2008, 12, 30)),
|
755
|
+
[
|
756
|
+
Occurrence.new(:type => :daily,
|
757
|
+
:start_date => ZDate.new("20081230"),
|
758
|
+
:interval => 1,
|
759
|
+
:start_time => ZTime.new("12", :am))
|
760
|
+
]
|
761
|
+
end
|
762
|
+
|
763
|
+
def test_daily_from_noon_to_midnight
|
764
|
+
assert_nlp NLP.new("daily from noon to midnight", Time.local(2008, 12, 30)),
|
765
|
+
[
|
766
|
+
Occurrence.new(:type => :daily,
|
767
|
+
:start_date => ZDate.new("20081230"),
|
768
|
+
:interval => 1,
|
769
|
+
:start_time => ZTime.new("12", :pm),
|
770
|
+
:end_time => ZTime.new("12", :am))
|
771
|
+
]
|
772
|
+
end
|
773
|
+
|
774
|
+
def test_the_last_tuesday_of_every_month
|
775
|
+
assert_nlp NLP.new("the last tuesday of every month, starts at 9am", Time.local(2008, 12, 30)),
|
776
|
+
[
|
777
|
+
Occurrence.new(:type => :daymonthly,
|
778
|
+
:start_date => ZDate.new("20081230"),
|
779
|
+
:start_time => ZTime.new("9", :am),
|
780
|
+
:interval => 1,
|
781
|
+
:week_of_month => -1,
|
782
|
+
:day_of_week => 1)
|
783
|
+
]
|
784
|
+
end
|
785
|
+
|
786
|
+
def test_one_week_from_today
|
787
|
+
assert_nlp NLP.new("one week from today", Time.local(2008, 12, 30)),
|
788
|
+
[
|
789
|
+
Occurrence.new(:type => :single, :start_date => ZDate.new("20090106"))
|
790
|
+
]
|
791
|
+
end
|
792
|
+
|
793
|
+
def test_every_other_day_at_245am
|
794
|
+
assert_nlp NLP.new("every other day at 2:45am", Time.local(2008, 12, 30)),
|
795
|
+
[
|
796
|
+
Occurrence.new(:type => :daily,
|
797
|
+
:start_date => ZDate.new("20081230"),
|
798
|
+
:start_time => ZTime.new("0245", :am),
|
799
|
+
:interval => 2)
|
800
|
+
]
|
801
|
+
end
|
802
|
+
|
803
|
+
def test_every_other_day_at_245am_starting_tomorrow
|
804
|
+
assert_nlp NLP.new("every other day at 2:45am starting tomorrow", Time.local(2008, 12, 30)),
|
805
|
+
[
|
806
|
+
Occurrence.new(:type => :daily,
|
807
|
+
:start_date => ZDate.new("20081231"),
|
808
|
+
:start_time => ZTime.new("0245", :am),
|
809
|
+
:interval => 2)
|
810
|
+
]
|
811
|
+
end
|
812
|
+
end
|
813
|
+
|