fugit 1.11.2 → 1.12.3
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 +4 -4
- data/CHANGELOG.md +24 -0
- data/CREDITS.md +4 -0
- data/LICENSE.txt +1 -1
- data/README.md +173 -22
- data/fugit.gemspec +1 -1
- data/lib/fugit/at.rb +9 -4
- data/lib/fugit/cron.rb +23 -21
- data/lib/fugit/nat.rb +8 -4
- data/lib/fugit/parse.rb +8 -6
- data/lib/fugit.rb +1 -1
- metadata +4 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f588451db0cf7643afd0ecd89313863b4ca89913872547f0dd8342343fec1b57
|
|
4
|
+
data.tar.gz: a0832d2aecbe4b158a3deef01ac7c230cd8de3ff2c3dc5a1da4e871a516d27c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5fca6043aef60a7c895b991f364714f1d26f3ef0922d477fc624a4f4cdc51dc948542fca4638567e2416fa4ff4c75e267f03991d7624f2515745d8e8be203314
|
|
7
|
+
data.tar.gz: 8ddb37f7d0f961dc341757fff83ef1cf844df7a7ffc7aaedc1eed0dca6fea4be217029e2a266cb8ce774303e174f4e27713854b4058cf6f12b3c2aa6eb78d1ca
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
# CHANGELOG.md
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
## fugit 1.12.3 released 2026-07-01
|
|
6
|
+
|
|
7
|
+
* Wrap-around for weekday ranges with step value, gh-119 Nicolas Bachschmidt
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## fugit 1.12.2 released 2026-05-28
|
|
11
|
+
|
|
12
|
+
* Fix "divide by zero" gh-117
|
|
13
|
+
* Let at parse 'now', gh-111
|
|
14
|
+
* Let Fugit::At pass options to Chronic, gh-116
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## fugit 1.12.1 released 2025-10-14
|
|
18
|
+
|
|
19
|
+
* Fix Fugit::Cron#to_cron_s to include & if @day_and
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## fugit 1.12.0 released 2025-09-30
|
|
23
|
+
|
|
24
|
+
* Upgrade et-orbi to ~> 1.4.0 for EtOrbi.rweek_ref=, gh-114
|
|
25
|
+
this changes the rweek reference point to 2018-12-31 (Monday)
|
|
26
|
+
* Fix `12 0 * * wed%4+1,wed%4` issue where 1 wed was ignored, gh-114
|
|
27
|
+
|
|
28
|
+
|
|
5
29
|
## fugit 1.11.2 released 2025-08-22
|
|
6
30
|
|
|
7
31
|
* Fix "every day at midnight America/Los_Angeles", gh-113, Mark R. James
|
data/CREDITS.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
# fugit credits
|
|
3
3
|
|
|
4
|
+
* Nicolas Bachschmidt https://github.com/baarde gh-120 weekday wrap fix
|
|
5
|
+
* JebeenLee https://github.com/JebeenLee gh-117 divide by zero
|
|
6
|
+
* Eric Claerhout https://github.com/swebra gh-114 rweek readme clarity
|
|
7
|
+
* Hugh Kelsey https://github.com/hughkelsey gh-114 rweek/rday / wed%4+1,wed%4
|
|
4
8
|
* Mark R. James, https://github.com/mrj, AM vs America/Los_Angeles, gh-113
|
|
5
9
|
* Tejas Bubane, https://github.com/tejasbubane, r3.4 in test matrix, gh-109
|
|
6
10
|
* Luis Castillo, https://github.com/lekastillo, nice_hash gh-108
|
data/LICENSE.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
Copyright (c) 2017-
|
|
2
|
+
Copyright (c) 2017-2026, John Mettraux, jmettraux+flor@gmail.com
|
|
3
3
|
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
# fugit
|
|
3
3
|
|
|
4
|
+
> Sed fugit interea, fugit irreparabile tempus
|
|
5
|
+
|
|
6
|
+
Virgil, _Georgics_ Book III
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
4
10
|
[](https://github.com/floraison/fugit/actions)
|
|
5
11
|
[](http://badge.fury.io/rb/fugit)
|
|
6
12
|
|
|
@@ -296,43 +302,188 @@ The hash extension can only be used in the day-of-week field.
|
|
|
296
302
|
|
|
297
303
|
### the modulo extension
|
|
298
304
|
|
|
299
|
-
|
|
305
|
+
Since 1.1.10, fugit also understands cron strings like `9 0 * * sun%2` which can be read as "every other Sunday at 9am" or `12 0 * * mon%4` for "every fourth monday at noon".
|
|
300
306
|
|
|
301
307
|
The modulo extension can only be used in the day-of-week field.
|
|
302
308
|
|
|
303
309
|
For odd Sundays, one can write `9 0 * * sun%2+1`.
|
|
304
310
|
|
|
305
|
-
It can be combined, as in `9 0 * * sun%2,tue%3+2
|
|
311
|
+
It can be combined, as in `9 0 * * sun%2,tue%3+2`, which will match every other Sunday and 1 in 3 Tuesdays (with an offset of 2).
|
|
312
|
+
|
|
313
|
+
What does `sun%2` actually mean?
|
|
314
|
+
```ruby
|
|
315
|
+
t.wday == 0 && t.rweek % 2 == 0
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
What does `tue%3+2` mean?
|
|
319
|
+
```ruby
|
|
320
|
+
t.wday == 2 && t.rweek % 3 == 2
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
#### et-orbi < 1.4.0 : reference set on Tuesday 2019-01-01
|
|
324
|
+
|
|
325
|
+
The original implementation of `#rweek` (and `#rday`) found in [et-orbi](https://github.com/floraison/et-orbi) was initially pointing to "Tuesday 2019-01-01" and it was set as rday 1 and rweek 1.
|
|
326
|
+
|
|
327
|
+
Consider this iteration through the days around 2019-01-01.
|
|
328
|
+
```ruby
|
|
329
|
+
require 'fugit'
|
|
330
|
+
|
|
331
|
+
t = EtOrbi.parse('2018-12-28 12:00')
|
|
332
|
+
|
|
333
|
+
15.times do |i|
|
|
334
|
+
|
|
335
|
+
puts " * %14s / rday: %5d / rweek: %5d" % [
|
|
336
|
+
t.strftime('%F %a'), t.rday, t.rweek ]
|
|
337
|
+
|
|
338
|
+
w = t.rweek
|
|
339
|
+
t = t.add(24 * 3600)
|
|
340
|
+
puts if t.rweek != w
|
|
306
341
|
|
|
307
|
-
|
|
342
|
+
if i == 7
|
|
343
|
+
puts "\n (...)\n\n"
|
|
344
|
+
t = EtOrbi.parse('2025-10-04 12:00')
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
For et-orbi 1.2.11, it yields:
|
|
350
|
+
```
|
|
351
|
+
* 2018-12-28 Fri / rday: -3 / rweek: 0
|
|
352
|
+
* 2018-12-29 Sat / rday: -2 / rweek: 0
|
|
353
|
+
* 2018-12-30 Sun / rday: -1 / rweek: 0
|
|
354
|
+
* 2018-12-31 Mon / rday: 0 / rweek: 0
|
|
355
|
+
|
|
356
|
+
* 2019-01-01 Tue / rday: 1 / rweek: 1
|
|
357
|
+
* 2019-01-02 Wed / rday: 2 / rweek: 1
|
|
358
|
+
* 2019-01-03 Thu / rday: 3 / rweek: 1
|
|
359
|
+
* 2019-01-04 Fri / rday: 4 / rweek: 1
|
|
360
|
+
* 2019-01-05 Sat / rday: 5 / rweek: 1
|
|
361
|
+
|
|
362
|
+
(...)
|
|
363
|
+
|
|
364
|
+
* 2025-10-04 Sat / rday: 2469 / rweek: 353
|
|
365
|
+
* 2025-10-05 Sun / rday: 2470 / rweek: 353
|
|
366
|
+
* 2025-10-06 Mon / rday: 2471 / rweek: 353
|
|
367
|
+
|
|
368
|
+
* 2025-10-07 Tue / rday: 2472 / rweek: 354
|
|
369
|
+
* 2025-10-08 Wed / rday: 2473 / rweek: 354
|
|
370
|
+
* 2025-10-09 Thu / rday: 2474 / rweek: 354
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
This [was problematic](https://github.com/floraison/fugit/issues/114), since the week started on, well, Tuesday.
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
#### et-orbi >= 1.4.0 : reference set on Monday 2018-12-31
|
|
377
|
+
|
|
378
|
+
Since 1.4.0, et-orbi starts by default on Monday (2018-12-31), as rday 0 with rweek 0.
|
|
379
|
+
|
|
380
|
+
Thus, the above code yields:
|
|
381
|
+
```
|
|
382
|
+
* 2018-12-28 Fri / rday: -3 / rweek: -1
|
|
383
|
+
* 2018-12-29 Sat / rday: -2 / rweek: -1
|
|
384
|
+
* 2018-12-30 Sun / rday: -1 / rweek: -1
|
|
385
|
+
|
|
386
|
+
* 2018-12-31 Mon / rday: 0 / rweek: 0
|
|
387
|
+
* 2019-01-01 Tue / rday: 1 / rweek: 0
|
|
388
|
+
* 2019-01-02 Wed / rday: 2 / rweek: 0
|
|
389
|
+
* 2019-01-03 Thu / rday: 3 / rweek: 0
|
|
390
|
+
* 2019-01-04 Fri / rday: 4 / rweek: 0
|
|
391
|
+
* 2019-01-05 Sat / rday: 5 / rweek: 0
|
|
392
|
+
|
|
393
|
+
(...)
|
|
394
|
+
|
|
395
|
+
* 2025-10-04 Sat / rday: 2469 / rweek: 352
|
|
396
|
+
* 2025-10-05 Sun / rday: 2470 / rweek: 352
|
|
397
|
+
|
|
398
|
+
* 2025-10-06 Mon / rday: 2471 / rweek: 353
|
|
399
|
+
* 2025-10-07 Tue / rday: 2472 / rweek: 353
|
|
400
|
+
* 2025-10-08 Wed / rday: 2473 / rweek: 353
|
|
401
|
+
* 2025-10-09 Thu / rday: 2474 / rweek: 353
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
#### modulo and et-orbi >= 1.4.0 sanity check
|
|
406
|
+
|
|
407
|
+
Given the cron `"0 12 * * mon%2,wed%3+1"`, here is a piece of code that considers a range of 44 days and tells in its last column if YES or no if each of the days matches the cron.
|
|
308
408
|
|
|
309
409
|
```ruby
|
|
310
|
-
require '
|
|
410
|
+
require 'fugit'
|
|
411
|
+
|
|
412
|
+
c = Fugit.parse_cron('0 12 * * mon%2,wed%3+1')
|
|
311
413
|
|
|
312
|
-
|
|
313
|
-
p EtOrbi.parse('2019-01-01').wday # => 2
|
|
314
|
-
p EtOrbi.parse('2019-01-01').rweek # => 1
|
|
315
|
-
p EtOrbi.parse('2019-01-01').rweek % 2 # => 1
|
|
414
|
+
t = EtOrbi.parse('2025-09-20 12:00')
|
|
316
415
|
|
|
317
|
-
|
|
318
|
-
p EtOrbi.parse('2019-04-11').wday # => 4
|
|
319
|
-
p EtOrbi.parse('2019-04-11').rweek # => 15
|
|
320
|
-
p EtOrbi.parse('2019-04-11').rweek % 2 # => 1
|
|
416
|
+
44.times do
|
|
321
417
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
c.match?('2019-01-08') # => true, since rweek % 2 == 0
|
|
418
|
+
wd = t.strftime('%a')
|
|
419
|
+
wd = %w[ Mon Wed ].include?(wd) ? '*' + wd.upcase : ' ' + wd.downcase
|
|
325
420
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
421
|
+
puts "%14s | rweek: %3d | %%2: %d == 0 | %%3: %d == 1 | ? %3s" % [
|
|
422
|
+
t.strftime('%F') + ' ' + wd,
|
|
423
|
+
t.rweek,
|
|
424
|
+
t.rweek % 2, t.rweek % 3,
|
|
425
|
+
c.match?(t)
|
|
426
|
+
].map { |e| e == true ? 'YES' : e == false ? 'no' : e }
|
|
329
427
|
|
|
330
|
-
|
|
428
|
+
w = t.rweek
|
|
429
|
+
t = t.add(24 * 3600)
|
|
430
|
+
puts if t.rweek != w
|
|
431
|
+
end
|
|
331
432
|
```
|
|
332
433
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
434
|
+
Here's the output:
|
|
435
|
+
```
|
|
436
|
+
2025-09-20 sat | rweek: 350 | %2: 0 == 0 | %3: 2 == 1 | ? no
|
|
437
|
+
2025-09-21 sun | rweek: 350 | %2: 0 == 0 | %3: 2 == 1 | ? no
|
|
438
|
+
|
|
439
|
+
2025-09-22 *MON | rweek: 351 | %2: 1 == 0 | %3: 0 == 1 | ? no
|
|
440
|
+
2025-09-23 tue | rweek: 351 | %2: 1 == 0 | %3: 0 == 1 | ? no
|
|
441
|
+
2025-09-24 *WED | rweek: 351 | %2: 1 == 0 | %3: 0 == 1 | ? no
|
|
442
|
+
2025-09-25 thu | rweek: 351 | %2: 1 == 0 | %3: 0 == 1 | ? no
|
|
443
|
+
2025-09-26 fri | rweek: 351 | %2: 1 == 0 | %3: 0 == 1 | ? no
|
|
444
|
+
2025-09-27 sat | rweek: 351 | %2: 1 == 0 | %3: 0 == 1 | ? no
|
|
445
|
+
2025-09-28 sun | rweek: 351 | %2: 1 == 0 | %3: 0 == 1 | ? no
|
|
446
|
+
|
|
447
|
+
2025-09-29 *MON | rweek: 352 | %2: 0 == 0 | %3: 1 == 1 | ? YES
|
|
448
|
+
2025-09-30 tue | rweek: 352 | %2: 0 == 0 | %3: 1 == 1 | ? no
|
|
449
|
+
2025-10-01 *WED | rweek: 352 | %2: 0 == 0 | %3: 1 == 1 | ? YES
|
|
450
|
+
2025-10-02 thu | rweek: 352 | %2: 0 == 0 | %3: 1 == 1 | ? no
|
|
451
|
+
2025-10-03 fri | rweek: 352 | %2: 0 == 0 | %3: 1 == 1 | ? no
|
|
452
|
+
2025-10-04 sat | rweek: 352 | %2: 0 == 0 | %3: 1 == 1 | ? no
|
|
453
|
+
2025-10-05 sun | rweek: 352 | %2: 0 == 0 | %3: 1 == 1 | ? no
|
|
454
|
+
|
|
455
|
+
2025-10-06 *MON | rweek: 353 | %2: 1 == 0 | %3: 2 == 1 | ? no
|
|
456
|
+
2025-10-07 tue | rweek: 353 | %2: 1 == 0 | %3: 2 == 1 | ? no
|
|
457
|
+
2025-10-08 *WED | rweek: 353 | %2: 1 == 0 | %3: 2 == 1 | ? no
|
|
458
|
+
2025-10-09 thu | rweek: 353 | %2: 1 == 0 | %3: 2 == 1 | ? no
|
|
459
|
+
2025-10-10 fri | rweek: 353 | %2: 1 == 0 | %3: 2 == 1 | ? no
|
|
460
|
+
2025-10-11 sat | rweek: 353 | %2: 1 == 0 | %3: 2 == 1 | ? no
|
|
461
|
+
2025-10-12 sun | rweek: 353 | %2: 1 == 0 | %3: 2 == 1 | ? no
|
|
462
|
+
|
|
463
|
+
2025-10-13 *MON | rweek: 354 | %2: 0 == 0 | %3: 0 == 1 | ? YES
|
|
464
|
+
2025-10-14 tue | rweek: 354 | %2: 0 == 0 | %3: 0 == 1 | ? no
|
|
465
|
+
2025-10-15 *WED | rweek: 354 | %2: 0 == 0 | %3: 0 == 1 | ? no
|
|
466
|
+
2025-10-16 thu | rweek: 354 | %2: 0 == 0 | %3: 0 == 1 | ? no
|
|
467
|
+
2025-10-17 fri | rweek: 354 | %2: 0 == 0 | %3: 0 == 1 | ? no
|
|
468
|
+
2025-10-18 sat | rweek: 354 | %2: 0 == 0 | %3: 0 == 1 | ? no
|
|
469
|
+
2025-10-19 sun | rweek: 354 | %2: 0 == 0 | %3: 0 == 1 | ? no
|
|
470
|
+
|
|
471
|
+
2025-10-20 *MON | rweek: 355 | %2: 1 == 0 | %3: 1 == 1 | ? no
|
|
472
|
+
2025-10-21 tue | rweek: 355 | %2: 1 == 0 | %3: 1 == 1 | ? no
|
|
473
|
+
2025-10-22 *WED | rweek: 355 | %2: 1 == 0 | %3: 1 == 1 | ? YES
|
|
474
|
+
2025-10-23 thu | rweek: 355 | %2: 1 == 0 | %3: 1 == 1 | ? no
|
|
475
|
+
2025-10-24 fri | rweek: 355 | %2: 1 == 0 | %3: 1 == 1 | ? no
|
|
476
|
+
2025-10-25 sat | rweek: 355 | %2: 1 == 0 | %3: 1 == 1 | ? no
|
|
477
|
+
2025-10-26 sun | rweek: 355 | %2: 1 == 0 | %3: 1 == 1 | ? no
|
|
478
|
+
|
|
479
|
+
2025-10-27 *MON | rweek: 356 | %2: 0 == 0 | %3: 2 == 1 | ? YES
|
|
480
|
+
2025-10-28 tue | rweek: 356 | %2: 0 == 0 | %3: 2 == 1 | ? no
|
|
481
|
+
2025-10-29 *WED | rweek: 356 | %2: 0 == 0 | %3: 2 == 1 | ? no
|
|
482
|
+
2025-10-30 thu | rweek: 356 | %2: 0 == 0 | %3: 2 == 1 | ? no
|
|
483
|
+
2025-10-31 fri | rweek: 356 | %2: 0 == 0 | %3: 2 == 1 | ? no
|
|
484
|
+
2025-11-01 sat | rweek: 356 | %2: 0 == 0 | %3: 2 == 1 | ? no
|
|
485
|
+
2025-11-02 sun | rweek: 356 | %2: 0 == 0 | %3: 2 == 1 | ? no
|
|
486
|
+
```
|
|
336
487
|
|
|
337
488
|
|
|
338
489
|
### the second extension
|
data/fugit.gemspec
CHANGED
|
@@ -41,7 +41,7 @@ Time tools for flor and the floraison project. Cron parsing and occurrence compu
|
|
|
41
41
|
# this dependency appears in 'et-orbi'
|
|
42
42
|
|
|
43
43
|
s.add_runtime_dependency 'raabro', '~> 1.4'
|
|
44
|
-
s.add_runtime_dependency 'et-orbi', '~> 1
|
|
44
|
+
s.add_runtime_dependency 'et-orbi', '~> 1.4'
|
|
45
45
|
|
|
46
46
|
s.add_development_dependency 'rspec', '~> 3.8'
|
|
47
47
|
s.add_development_dependency 'chronic', '~> 0.10'
|
data/lib/fugit/at.rb
CHANGED
|
@@ -6,14 +6,19 @@ module Fugit
|
|
|
6
6
|
|
|
7
7
|
class << self
|
|
8
8
|
|
|
9
|
-
def parse(s)
|
|
9
|
+
def parse(s, opts={})
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
do_parse(s, opts || {}) rescue nil
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def do_parse(s)
|
|
14
|
+
def do_parse(s, opts={})
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
case s
|
|
17
|
+
when /^now$/i then ::EtOrbi::EoTime.now
|
|
18
|
+
when String then ::EtOrbi.parse(s, opts || {})
|
|
19
|
+
when ::EtOrbi::EoTime then s
|
|
20
|
+
else ::EtOrbi.make_time(s)
|
|
21
|
+
end
|
|
17
22
|
end
|
|
18
23
|
end
|
|
19
24
|
end
|
data/lib/fugit/cron.rb
CHANGED
|
@@ -175,34 +175,30 @@ module Fugit
|
|
|
175
175
|
|
|
176
176
|
def weekday_hash_match?(nt, hsh)
|
|
177
177
|
|
|
178
|
+
return false unless hsh.is_a?(Integer)
|
|
179
|
+
|
|
178
180
|
phsh, nhsh = nt.wday_in_month
|
|
181
|
+
#
|
|
182
|
+
# positive wday, from the beginning of the month
|
|
183
|
+
# negative wday, from the end of the month, -1 == last
|
|
179
184
|
|
|
180
|
-
|
|
181
|
-
hsh == phsh # positive wday, from the beginning of the month
|
|
182
|
-
else
|
|
183
|
-
hsh == nhsh # negative wday, from the end of the month, -1 == last
|
|
184
|
-
end
|
|
185
|
+
(hsh == phsh) || (hsh == nhsh)
|
|
185
186
|
end
|
|
186
187
|
|
|
187
188
|
def weekday_modulo_match?(nt, mod)
|
|
188
189
|
|
|
189
|
-
(
|
|
190
|
+
mod.is_a?(Array) &&
|
|
191
|
+
((nt.rweek % mod[0]) == (mod[1] % mod[0]))
|
|
190
192
|
end
|
|
191
193
|
|
|
192
194
|
def weekday_match?(nt)
|
|
193
195
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if hom.is_a?(Array)
|
|
202
|
-
weekday_modulo_match?(nt, hom)
|
|
203
|
-
else
|
|
204
|
-
weekday_hash_match?(nt, hom)
|
|
205
|
-
end
|
|
196
|
+
@weekdays.nil? ||
|
|
197
|
+
@weekdays.find { |wd, hom|
|
|
198
|
+
(nt.wday == wd) &&
|
|
199
|
+
(hom.nil? ||
|
|
200
|
+
weekday_modulo_match?(nt, hom) ||
|
|
201
|
+
weekday_hash_match?(nt, hom)) }
|
|
206
202
|
end
|
|
207
203
|
|
|
208
204
|
def monthday_match?(nt)
|
|
@@ -595,6 +591,8 @@ module Fugit
|
|
|
595
591
|
# let it go, "* */24 * * *" and "* */27 * * *" are okay
|
|
596
592
|
# gh-86 and gh-103
|
|
597
593
|
|
|
594
|
+
return false if sla && sla < 1
|
|
595
|
+
|
|
598
596
|
edn = max if sla && edn.nil?
|
|
599
597
|
|
|
600
598
|
return nil if sta.nil? && edn.nil? && sla.nil?
|
|
@@ -694,8 +692,11 @@ module Fugit
|
|
|
694
692
|
if ha || mo
|
|
695
693
|
@weekdays << [ a, ha || mo ]
|
|
696
694
|
elsif sl
|
|
697
|
-
|
|
698
|
-
|
|
695
|
+
z ||= (a ? a : 6)
|
|
696
|
+
a ||= 0
|
|
697
|
+
z = z + 7 if a > z
|
|
698
|
+
(a..z).step(sl < 1 ? 1 : sl)
|
|
699
|
+
.each { |i| @weekdays << [ (i > 6) ? i - 7 : i ] }
|
|
699
700
|
elsif z
|
|
700
701
|
z = z + 7 if a > z
|
|
701
702
|
(a..z).each { |i| @weekdays << [ (i > 6) ? i - 7 : i ] }
|
|
@@ -735,7 +736,8 @@ module Fugit
|
|
|
735
736
|
else
|
|
736
737
|
a.collect(&:to_s).join('#')
|
|
737
738
|
end }
|
|
738
|
-
.join(',')
|
|
739
|
+
.join(',') +
|
|
740
|
+
(@day_and ? '&' : '')
|
|
739
741
|
end
|
|
740
742
|
|
|
741
743
|
module Parser include Raabro
|
data/lib/fugit/nat.rb
CHANGED
|
@@ -719,6 +719,8 @@ module Fugit
|
|
|
719
719
|
end
|
|
720
720
|
end
|
|
721
721
|
|
|
722
|
+
SLASH_REGEX = /^(\d+|\*)\/(\d+)$/.freeze
|
|
723
|
+
|
|
722
724
|
# Return nil if the cron is "not strict"
|
|
723
725
|
#
|
|
724
726
|
# For example, "0 0/17 * * *" (gh-86) is a perfectly valid
|
|
@@ -729,16 +731,18 @@ module Fugit
|
|
|
729
731
|
#
|
|
730
732
|
def restrict(a, cron)
|
|
731
733
|
|
|
732
|
-
if m = ((a[
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
734
|
+
if m = ((a[0] && a[0] != [ 0 ] && a[0][0]) || '').match(SLASH_REGEX)
|
|
735
|
+
return nil unless (1..60).include?(m[1].to_i)
|
|
736
|
+
end
|
|
737
|
+
if m = ((a[1] && a[1][0]) || '').match(SLASH_REGEX)
|
|
738
|
+
return nil unless [ 1, 2, 3, 4, 5, 6, 8, 12 ].include?(m[1].to_i)
|
|
736
739
|
end
|
|
737
740
|
|
|
738
741
|
cron
|
|
739
742
|
end
|
|
740
743
|
|
|
741
744
|
def slot(key, default)
|
|
745
|
+
|
|
742
746
|
s = @slots[key]
|
|
743
747
|
s ? s.data0 : [ default ]
|
|
744
748
|
end
|
data/lib/fugit/parse.rb
CHANGED
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
module Fugit
|
|
4
4
|
|
|
5
|
+
DO_PARSE_ORDER = %i[ cron duration nat at ].freeze
|
|
6
|
+
|
|
5
7
|
class << self
|
|
6
8
|
|
|
7
9
|
def parse_cron(s); ::Fugit::Cron.parse(s); end
|
|
8
10
|
def parse_duration(s); ::Fugit::Duration.parse(s); end
|
|
9
|
-
def parse_nat(s, opts={}); ::Fugit::Nat.parse(s, opts); end
|
|
10
|
-
def parse_at(s); ::Fugit::At.parse(s); end
|
|
11
|
+
def parse_nat(s, opts={}); ::Fugit::Nat.parse(s, opts || {}); end
|
|
12
|
+
def parse_at(s, opts={}); ::Fugit::At.parse(s, opts || {}); end
|
|
11
13
|
def parse_in(s); parse_duration(s); end
|
|
12
14
|
|
|
13
15
|
def do_parse_cron(s); ::Fugit::Cron.do_parse(s); end
|
|
14
16
|
def do_parse_duration(s); ::Fugit::Duration.do_parse(s); end
|
|
15
|
-
def do_parse_nat(s, opts={}); ::Fugit::Nat.do_parse(s, opts); end
|
|
17
|
+
def do_parse_nat(s, opts={}); ::Fugit::Nat.do_parse(s, opts || {}); end
|
|
16
18
|
def do_parse_at(s); ::Fugit::At.do_parse(s); end
|
|
17
19
|
def do_parse_in(s); do_parse_duration(s); end
|
|
18
20
|
|
|
@@ -22,8 +24,8 @@ module Fugit
|
|
|
22
24
|
|
|
23
25
|
(opts[:cron] != false && parse_cron(s)) || # 542ms 616ms
|
|
24
26
|
(opts[:duration] != false && parse_duration(s)) || # 645ms # 534ms
|
|
25
|
-
(opts[:nat] != false && parse_nat(s, opts)) || # 2s # 35s
|
|
26
|
-
(opts[:at] != false && parse_at(s)) || # 568ms 622ms
|
|
27
|
+
(opts[:nat] != false && parse_nat(s, opts || {})) || # 2s # 35s
|
|
28
|
+
(opts[:at] != false && parse_at(s, opts || {})) || # 568ms 622ms
|
|
27
29
|
nil
|
|
28
30
|
end
|
|
29
31
|
|
|
@@ -34,7 +36,7 @@ module Fugit
|
|
|
34
36
|
result = nil
|
|
35
37
|
errors = []
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
DO_PARSE_ORDER
|
|
38
40
|
.each { |k|
|
|
39
41
|
begin
|
|
40
42
|
result ||= (opts[k] != false && self.send("do_parse_#{k}", s))
|
data/lib/fugit.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fugit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.12.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Mettraux
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-07-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: raabro
|
|
@@ -30,20 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '1'
|
|
34
|
-
- - ">="
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: 1.2.11
|
|
33
|
+
version: '1.4'
|
|
37
34
|
type: :runtime
|
|
38
35
|
prerelease: false
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
37
|
requirements:
|
|
41
38
|
- - "~>"
|
|
42
39
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: '1'
|
|
44
|
-
- - ">="
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: 1.2.11
|
|
40
|
+
version: '1.4'
|
|
47
41
|
- !ruby/object:Gem::Dependency
|
|
48
42
|
name: rspec
|
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|