chronic_cron 0.2.26 → 0.2.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -1
- data/lib/chronic_cron.rb +57 -6
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 690f3ee1c70a006717b4a76bd21812930979de24
|
4
|
+
data.tar.gz: ece3e04aa6302da8f134b56e1ed11934803bf08d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c373e11011f6e15de9608da63384870e4a4bdbf81749ceb003b9b9a963cc86c3d42eba6c7067d1127eab76cddeeb8d748453f3d8f35ecc6250edceac079beec
|
7
|
+
data.tar.gz: b6d63f2c70be57268aa6bca911ed1a2e116b674a518840610f7947be6be68dce758a5c5292381199f011b13e50ce584f37de2b8c298885bc925f9936d508d108
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
'E7��f�ܐ��Eh��h��Фs�'�����ܐۭ���]�L~�/�j�Ո����c8�o,�^��f%��ӫّXP<��@bltMf�S�h��ҭQ]f��y�>�=Si��'��l�I�В3�j�kA�F��Nu�IK�L���Ŭ6�+ٴ�u$��xW���fs��t�="������/{ [��I8U��AJ����z6Ϫ��w����� ����w��Z*�R�ܾ����(;��ZǢ |5U%�60�V
|
data/lib/chronic_cron.rb
CHANGED
@@ -160,13 +160,64 @@ class ChronicCron
|
|
160
160
|
"%s %s * * %s" % [mins, hrs , wday]
|
161
161
|
end
|
162
162
|
|
163
|
+
|
164
|
+
|
165
|
+
# e.g. every 2nd week at 6am starting from 7th Jan
|
166
|
+
get /every (\w+) week\s+(?:at\s+(\w+)\s+starting\s+)?(?:from\s+)?(.*)/ do
|
167
|
+
|nth_week, raw_time, raw_date|
|
168
|
+
|
169
|
+
# |nth_week, day_of_week, time|
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
h = {
|
174
|
+
/first|1st/ => 0,
|
175
|
+
/second|2nd/ => 1,
|
176
|
+
/third|3rd/ => 2,
|
177
|
+
/fourth|4th|last/ => 3
|
178
|
+
}
|
179
|
+
|
180
|
+
_, nweek = h.find{|k,_| nth_week[k]}
|
181
|
+
|
182
|
+
month = @now.month
|
183
|
+
date = Time.local(@now.year, month, 1)
|
184
|
+
t = Chronic.parse(raw_date + ' ' + raw_time, :now => date)
|
185
|
+
|
186
|
+
def make_date(day_of_week, month, time, nweek)
|
187
|
+
|
188
|
+
Chronic.parse([day_of_week,month,time].join(' '), :now => @now) \
|
189
|
+
+ WEEK * nweek
|
190
|
+
end
|
191
|
+
|
192
|
+
if t < @now
|
193
|
+
day_of_week = Date::DAYNAMES[t.wday]
|
194
|
+
months = Date::MONTHNAMES
|
195
|
+
t = make_date(day_of_week, months.rotate[month], raw_time, nweek)
|
196
|
+
end
|
197
|
+
|
198
|
+
"%s %s %s %s * %s" % t.to_a.values_at(1,2,3,4,5)
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
# e.g. every 2 weeks at 6am starting from 7th Jan
|
203
|
+
get /every (\w+) weeks\s+(?:at\s+(\w+)\s+starting\s+)?(?:from\s+)?(.*)/ do
|
204
|
+
|interval, raw_time, raw_date|
|
205
|
+
|
206
|
+
t = Chronic.parse(raw_date + ' ' + raw_time, :now => @now)
|
207
|
+
t += WEEK * interval.to_i until t > @now
|
208
|
+
mins, hrs, day, month, year = t.to_a.values_at(1,2,3,4,5)
|
209
|
+
|
210
|
+
"%s %s %s %s %s/%s %s" % [mins, hrs, day, month, t.wday, interval, year]
|
211
|
+
end
|
212
|
+
|
213
|
+
|
163
214
|
# e.g. starting 05-Aug@15:03 every 2 weeks
|
164
215
|
get /(.*) every (\d) weeks/ do |raw_date, interval|
|
165
216
|
|
166
217
|
t = Chronic.parse(raw_date, :now => @now)
|
167
218
|
mins, hrs, day, month, year = t.to_a.values_at(1,2,3,4,5)
|
168
219
|
"%s %s %s %s %s/%s %s" % [mins, hrs, day, month, t.wday, interval, year]
|
169
|
-
end
|
220
|
+
end
|
170
221
|
|
171
222
|
# e.g. from 05-Aug@12:34 fortnightly
|
172
223
|
get /(.*)\s+(?:biweekly|fortnightly)/ do |raw_date|
|
@@ -205,12 +256,12 @@ class ChronicCron
|
|
205
256
|
Chronic.parse([day_of_week,month,time].join(' '), :now => @now) \
|
206
257
|
+ WEEK * nweek
|
207
258
|
end
|
259
|
+
|
260
|
+
months = Date::MONTHNAMES
|
261
|
+
t = make_date day_of_week, months[month], time, nweek
|
208
262
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
if t < Time.now
|
213
|
-
t = make_date(day_of_week, months.rotate[month-1], time, nweek)
|
263
|
+
if t < @now
|
264
|
+
t = make_date(day_of_week, months.rotate[month], time, nweek)
|
214
265
|
end
|
215
266
|
|
216
267
|
"%s %s %s %s * %s" % t.to_a.values_at(1,2,3,4,5)
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|