chronic_cron 0.7.0 → 0.7.1
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/lib/chronic_cron.rb +24 -9
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74e6c6b5e6aafa964b67958982e125192dff761eb9368ed437918ba129f579d3
|
4
|
+
data.tar.gz: c261b87089908765d850751596efc61d41fff9a963096a46a592db5b58d374a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6aeca1b4badf614977581b0dfbfc246746b483f2c4b69fe212e3e066b529019d56a2ad45e215868e7e346d91f70e5fc599cdcb2f1f2064e6f543a2d265825fa4
|
7
|
+
data.tar.gz: 4e62f03e153be58292d68512abd4a338f2337b9443b9fe5dbda504daf39f6b7b45646cf2410b19c3ca0536a1e9575bc716a130f330419341f45fd29bbe9ed836
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/chronic_cron.rb
CHANGED
@@ -8,6 +8,8 @@ require 'cron_format'
|
|
8
8
|
require 'timetoday'
|
9
9
|
|
10
10
|
|
11
|
+
MONTHS = (Date::MONTHNAMES[1..-1] + Date::ABBR_MONTHNAMES[1..-1]).join('|')
|
12
|
+
|
11
13
|
class ChronicCron
|
12
14
|
include AppRoutes
|
13
15
|
using ColouredText
|
@@ -43,7 +45,7 @@ class ChronicCron
|
|
43
45
|
.sub(/^(?:on|at|from|starting)\s+/,''))
|
44
46
|
puts 'expression: ' + expression.inspect if @debug
|
45
47
|
return unless expression
|
46
|
-
|
48
|
+
puts 'now: ' + now.inspect if @debug
|
47
49
|
@cf = CronFormat.new(expression, now)
|
48
50
|
|
49
51
|
end
|
@@ -284,7 +286,7 @@ class ChronicCron
|
|
284
286
|
# e.g. last sunday of March at 1am
|
285
287
|
|
286
288
|
get /last (#{Date::DAYNAMES.join('|')}) (?:of|in) \
|
287
|
-
(#{
|
289
|
+
(#{MONTHS})\s+at\s+(\d{1,2})(?::(\d{1,2}))?\
|
288
290
|
([ap]m)/i do |day, month, raw_hrs, mins, meridiem|
|
289
291
|
|
290
292
|
now = Chronic.parse(month, now: @now)
|
@@ -303,7 +305,7 @@ class ChronicCron
|
|
303
305
|
# e.g. last sunday of October
|
304
306
|
|
305
307
|
get /last (#{Date::DAYNAMES.join('|')}) (?:of|in) \
|
306
|
-
(#{
|
308
|
+
(#{MONTHS})/i do |day, month|
|
307
309
|
|
308
310
|
now = Chronic.parse(month, now: @now)
|
309
311
|
|
@@ -316,14 +318,27 @@ class ChronicCron
|
|
316
318
|
|
317
319
|
|
318
320
|
# e.g. every 2nd tuesday at 4:40pm
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
log.info 'ChronicCron/expressions/get: r225' if log
|
321
|
+
#
|
322
|
+
get /every\s+2nd\s+#{weekday}\s+at\s+(\d{1,2})(?::(\d{1,2}))?([ap]m)(.*)/i do
|
323
|
+
|wday, raw_hrs, mins, meridiem, remaining|
|
323
324
|
|
325
|
+
log.info 'ChronicCron/expressions/get: r225' if log
|
324
326
|
puts 'ChronicCron#expressions 225' if @debug
|
325
327
|
|
326
|
-
|
328
|
+
hrs = in24hrs(raw_hrs, meridiem)
|
329
|
+
puts 'remaining: ' + remaining.inspect if @debug
|
330
|
+
|
331
|
+
if remaining =~ /#{MONTHS}/i then
|
332
|
+
|
333
|
+
t = Chronic.parse(remaining.gsub(/[\(\)]/,''), :now => @now)
|
334
|
+
"%s %s * * %s/2" % [mins.to_i, hrs, t.wday]
|
335
|
+
|
336
|
+
else
|
337
|
+
|
338
|
+
"%s %s * * %s/2" % [mins.to_i, hrs , wday]
|
339
|
+
|
340
|
+
end
|
341
|
+
|
327
342
|
end
|
328
343
|
|
329
344
|
# e.g. every tuesday at 4:40pm
|
@@ -341,7 +356,7 @@ class ChronicCron
|
|
341
356
|
get /every 2nd week\s+at\s+([^\s]+)/ do |raw_time|
|
342
357
|
|
343
358
|
t = Chronic.parse(raw_time, :now => @now)
|
344
|
-
log.info 'ChronicCron/expressions/get:
|
359
|
+
log.info 'ChronicCron/expressions/get: r240' if log
|
345
360
|
puts 'ChronicCron#expressions 240' if @debug
|
346
361
|
|
347
362
|
"%s %s * * %s/2" % [t.min,t.hour,t.wday]
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|