chronic_cron 0.7.0 → 0.7.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71cb9fbaff016e7cf04a40aa56dedba54844753254825889c6e1525aa680be7b
4
- data.tar.gz: e5b614c4fdd6c3935eb7276387206c6b1e5ed90cf84c18c1a16ef8819fd6c318
3
+ metadata.gz: 74e6c6b5e6aafa964b67958982e125192dff761eb9368ed437918ba129f579d3
4
+ data.tar.gz: c261b87089908765d850751596efc61d41fff9a963096a46a592db5b58d374a4
5
5
  SHA512:
6
- metadata.gz: 2ca9ba056ab67289a9a63bfc865ab45f3d7cdf70caeb28db11c912f80e0161f6cf9aa7cf74a812c7cd5ee0372c14ca9b875c50d9321880bf29909fc1079fad5a
7
- data.tar.gz: 067d8f29da520258af4fa0054e446084bb49cedb04260821a94f5ce0800b82ed4f9f7772f392d7d46ef7c87708dc2d3d4b1a891fe5ee9d5dbf8230351d2c34e5
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
- (#{Date::MONTHNAMES[1..-1].join('|')})\s+at\s+(\d{1,2})(?::(\d{1,2}))?\
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
- (#{Date::MONTHNAMES[1..-1].join('|')})/i do |day, month|
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
- get /every\s+2nd\s+#{weekday}\s+at\s+(\d{1,2})(?::(\d{1,2}))?([ap]m)/i do
320
- |wday, raw_hrs, mins, meridiem, |
321
- hrs = in24hrs(raw_hrs, meridiem)
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
- "%s %s * * %s/2" % [mins.to_i, hrs , wday]
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: r250' if log
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
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chronic_cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file