fugit 1.12.0 → 1.12.2

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: 31f13ce15ee0d51e6029539634fd55e14401f60ba03cdc6ad90c8e47bd4b711e
4
- data.tar.gz: 91db0bb6fd6aa714e44e4c6d2b67fdbffc70495da77bf9946cda8d859bdf510a
3
+ metadata.gz: dbfc8b39f64a9745e37dcc8f20b5e923378a76a66a5ceecda42d9892ebcfc6fb
4
+ data.tar.gz: 19dc7123a550e62a242aed23ce401a8f3084cbc6fb6321e281dc03b706702b0a
5
5
  SHA512:
6
- metadata.gz: 604a819a90770a746f33f2d93cdab4524f036a71ac901d311fb74c438f20eaa01a4fb13187f5eca96b7a449354d7864ef3b515674088b3bc60b36710afd8c9df
7
- data.tar.gz: c83c544fa51e1a3e8bc2f76ff163276caa61a93927db6bbfe47642d91ffa85281c8522e1b36a2e9c988c85963c34edc86b47fab98dc1ee516a4495df63839ac8
6
+ metadata.gz: '089240f70ced2e63f3cd18c74dd58da00e372137ee2768b002a24fb452cf6c0f0bd539e192667a0e20b2dd83082eccefc82ff2c8605a0ca405e667c6ba3c81c6'
7
+ data.tar.gz: 59dca013d409f191481ad0f3038ed697627f5f2f5b589cfd33c9547cde3d35ab6771c35f28b751504dc6325b107b1556b75949fab0f4ca94d47204ebfb3b14b1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## fugit 1.12.2 released 2026-05-28
6
+
7
+ * Fix "divide by zero" gh-117
8
+ * Let at parse 'now', gh-111
9
+ * Let Fugit::At pass options to Chronic, gh-116
10
+
11
+
12
+ ## fugit 1.12.1 released 2025-10-14
13
+
14
+ * Fix Fugit::Cron#to_cron_s to include & if @day_and
15
+
16
+
5
17
  ## fugit 1.12.0 released 2025-09-30
6
18
 
7
19
  * Upgrade et-orbi to ~> 1.4.0 for EtOrbi.rweek_ref=, gh-114
data/CREDITS.md CHANGED
@@ -1,7 +1,9 @@
1
1
 
2
2
  # fugit credits
3
3
 
4
- * Hugh Kelsey https://github.com/hughkelsey gh-94 rweek/rday / wed%4+1,wed%4
4
+ * JebeenLee https://github.com/JebeenLee gh-117 divide by zero
5
+ * Eric Claerhout https://github.com/swebra gh-114 rweek readme clarity
6
+ * Hugh Kelsey https://github.com/hughkelsey gh-114 rweek/rday / wed%4+1,wed%4
5
7
  * Mark R. James, https://github.com/mrj, AM vs America/Los_Angeles, gh-113
6
8
  * Tejas Bubane, https://github.com/tejasbubane, r3.4 in test matrix, gh-109
7
9
  * Luis Castillo, https://github.com/lekastillo, nice_hash gh-108
data/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2017-2025, John Mettraux, jmettraux+flor@gmail.com
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
  [![tests](https://github.com/floraison/fugit/workflows/test/badge.svg)](https://github.com/floraison/fugit/actions)
5
11
  [![Gem Version](https://badge.fury.io/rb/fugit.svg)](http://badge.fury.io/rb/fugit)
6
12
 
@@ -296,125 +302,187 @@ The hash extension can only be used in the day-of-week field.
296
302
 
297
303
  ### the modulo extension
298
304
 
299
- Fugit, since 1.1.10, 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".
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).
306
312
 
307
- But what does it reference to? It starts at 1 on 2019-01-01 (in the EtOrbi instance timezone, not the UTC "timezone").
308
-
309
- Since [et-orbi](https://github.com/floraison/et-orbi) 1.4.0, the reference has been switched to make `Monday 2018-12-31` as the reference, so that weeks start on Monday (read a bit below on how to make it start on another day).
313
+ What does `sun%2` actually mean?
314
+ ```ruby
315
+ t.wday == 0 && t.rweek % 2 == 0
316
+ ```
310
317
 
318
+ What does `tue%3+2` mean?
311
319
  ```ruby
312
- require 'et-orbi' # >= 1.1.8 and < 1.4.0
320
+ t.wday == 2 && t.rweek % 3 == 2
321
+ ```
313
322
 
314
- class EtOrbi::EoTime
315
- def d # debug
316
- "%14s | rday: %4d | rweek: %3d" % [ strftime('%a'), rday, rweek ]
317
- end
318
- end
323
+ #### et-orbi < 1.4.0 : reference set on Tuesday 2019-01-01
319
324
 
320
- # the reference
321
- puts EtOrbi.parse('2019-01-01').d # => Tue | rday: 1 | rweek: 1
322
- p EtOrbi.parse('2019-01-01').rweek % 2 # => 1
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.
323
326
 
324
- # today (as of this coding...)
325
- puts EtOrbi.parse('2019-04-11').d # => Thu | rday: 101 | rweek: 15
326
- p EtOrbi.parse('2019-04-11').rweek % 2 # => 1
327
+ Consider this iteration through the days around 2019-01-01.
328
+ ```ruby
329
+ require 'fugit'
327
330
 
328
- c = Fugit.parse('* * * * tue%2')
329
- p c.match?('2019-01-01') # => false, since rweek % 2 == 1
330
- p c.match?('2019-01-08') # => true, since rweek % 2 == 0
331
+ t = EtOrbi.parse('2018-12-28 12:00')
331
332
 
332
- c = Fugit.parse('* * * * tue%2+1')
333
- p c.match?('2019-01-01') # => true, since (rweek + 1) % 2 == 0
334
- p c.match?('2019-01-08') # => false, since (rweek + 1) % 2 == 1
333
+ 15.times do |i|
335
334
 
336
- # ...
335
+ puts " * %14s / rday: %5d / rweek: %5d" % [
336
+ t.strftime('%F %a'), t.rday, t.rweek ]
337
337
 
338
- class EtOrbi::EoTime
339
- def d # debug
340
- "%14s | rday: %4d | rweek: %3d" % [ strftime('%F %a'), rday, rweek ]
338
+ w = t.rweek
339
+ t = t.add(24 * 3600)
340
+ puts if t.rweek != w
341
+
342
+ if i == 7
343
+ puts "\n (...)\n\n"
344
+ t = EtOrbi.parse('2025-10-04 12:00')
341
345
  end
342
346
  end
347
+ ```
343
348
 
344
- c = Fugit.parse_cron('20 0 * * mon%2,wed%3+1')
345
- puts c.next('2025-09-21').take(10).map(&:d)
346
- #
347
- # => 2025-09-24 Wed | rday: 2459 | rweek: 352
348
- # 2025-09-29 Mon | rday: 2464 | rweek: 352
349
- # 2025-10-13 Mon | rday: 2478 | rweek: 354
350
- # 2025-10-15 Wed | rday: 2480 | rweek: 355
351
- # 2025-10-27 Mon | rday: 2492 | rweek: 356
352
- # 2025-11-05 Wed | rday: 2501 | rweek: 358
353
- # 2025-11-10 Mon | rday: 2506 | rweek: 358
354
- # 2025-11-24 Mon | rday: 2520 | rweek: 360
355
- # 2025-11-26 Wed | rday: 2522 | rweek: 361
356
- # 2025-12-08 Mon | rday: 2534 | rweek: 362
357
- ```
358
-
359
- `sun%2` matches if Sunday and `current_date.rweek % 2 == 0`
360
- `tue%3+2` matches if Tuesday and `current_date.rweek + 2 % 3 == 0`
361
- `tue%x+y` matches if Tuesday and `current_date.rweek + y % x == 0`
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
+ ```
362
372
 
363
- ```ruby
364
- require 'et-orbi' # >= 1.4.0
373
+ This [was problematic](https://github.com/floraison/fugit/issues/114), since the week started on, well, Tuesday.
365
374
 
366
- class EtOrbi::EoTime
367
- def d # debug
368
- "%14s | rday: %4d | rweek: %3d" % [ strftime('%a'), rday, rweek ]
369
- end
370
- end
371
375
 
372
- puts EtOrbi.parse('2018-12-30').d # => Sun | rday: -1 | rweek: -1
373
- puts EtOrbi.parse('2018-12-31').d # => Mon | rday: 0 | rweek: 0 >REF<
374
- puts EtOrbi.parse('2019-01-01').d # => Tue | rday: 1 | rweek: 0
375
- puts EtOrbi.parse('2019-01-02').d # => Wed | rday: 2 | rweek: 0
376
- puts EtOrbi.parse('2019-01-31').d # => Thu | rday: 31 | rweek: 4
376
+ #### et-orbi >= 1.4.0 : reference set on Monday 2018-12-31
377
377
 
378
- puts EtOrbi.parse('2019-04-11').d # => Thu | rday: 101 | rweek: 14
379
- puts EtOrbi.parse('2025-09-30').d # => Tue | rday: 2465 | rweek: 352
378
+ Since 1.4.0, et-orbi starts by default on Monday (2018-12-31), as rday 0 with rweek 0.
380
379
 
381
- class EtOrbi::EoTime
382
- def d # debug
383
- "%14s | rday: %4d | rweek: %3d" % [ strftime('%F %a'), rday, rweek ]
384
- end
385
- end
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
+ ```
386
403
 
387
- p EtOrbi.rweek_ref # => "2018-12-31"
388
404
 
389
- c = Fugit.parse_cron('20 0 * * mon%2,wed%3+1')
390
- puts c.next('2025-09-21').take(10).map(&:d)
391
- #
392
- # => 2025-09-29 Mon | rday: 2464 | rweek: 352
393
- # 2025-10-01 Wed | rday: 2466 | rweek: 352
394
- # 2025-10-13 Mon | rday: 2478 | rweek: 354
395
- # 2025-10-22 Wed | rday: 2487 | rweek: 355
396
- # 2025-10-27 Mon | rday: 2492 | rweek: 356
397
- # 2025-11-10 Mon | rday: 2506 | rweek: 358
398
- # 2025-11-12 Wed | rday: 2508 | rweek: 358
399
- # 2025-11-24 Mon | rday: 2520 | rweek: 360
400
- # 2025-12-03 Wed | rday: 2529 | rweek: 361
401
- # 2025-12-08 Mon | rday: 2534 | rweek: 362
402
- ```
403
-
404
- One can tell et-orbi >= 1.4.0 which day to take as reference:
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.
408
+
405
409
  ```ruby
406
- EtOrbi.rweek_ref = :us # or
407
- EtOrbi.rweek_ref = :sunday # to start on a Sunday (2018-12-30)
410
+ require 'fugit'
411
+
412
+ c = Fugit.parse_cron('0 12 * * mon%2,wed%3+1')
413
+
414
+ t = EtOrbi.parse('2025-09-20 12:00')
408
415
 
409
- EtOrbi.rweek_ref = :iso # or
410
- EtOrbi.rweek_ref = :monday # or
411
- EtOrbi.rweek_ref = :default # to start on a Monday (2019-12-31)
416
+ 44.times do
412
417
 
413
- EtOrbi.rweek_ref = :saturday # to start on, well, a Saturday (2019-01-05)
418
+ wd = t.strftime('%a')
419
+ wd = %w[ Mon Wed ].include?(wd) ? '*' + wd.upcase : ' ' + wd.downcase
414
420
 
415
- EtOrbi.rweek_ref = '2025-09-30' # to start on this very Tuesday...
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 }
416
427
 
417
- p EtOrbi.rweek_ref # to determine what the current setting is...
428
+ w = t.rweek
429
+ t = t.add(24 * 3600)
430
+ puts if t.rweek != w
431
+ end
432
+ ```
433
+
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
418
486
  ```
419
487
 
420
488
 
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
- ::EtOrbi.make_time(s) rescue nil
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
- ::EtOrbi.make_time(s)
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
@@ -591,6 +591,8 @@ module Fugit
591
591
  # let it go, "* */24 * * *" and "* */27 * * *" are okay
592
592
  # gh-86 and gh-103
593
593
 
594
+ return false if sla && sla < 1
595
+
594
596
  edn = max if sla && edn.nil?
595
597
 
596
598
  return nil if sta.nil? && edn.nil? && sla.nil?
@@ -731,7 +733,8 @@ module Fugit
731
733
  else
732
734
  a.collect(&:to_s).join('#')
733
735
  end }
734
- .join(',')
736
+ .join(',') +
737
+ (@day_and ? '&' : '')
735
738
  end
736
739
 
737
740
  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[1] && a[1][0]) || '').match(/^(\d+|\*)\/(\d+)$/)
733
- #p m
734
- sla = m[1].to_i
735
- return nil unless [ 1, 2, 3, 4, 5, 6, 8, 12 ].include?(sla)
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
- %i[ cron duration nat at ]
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
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Fugit
5
5
 
6
- VERSION = '1.12.0'
6
+ VERSION = '1.12.2'
7
7
  end
8
8
 
9
9
  require 'time'
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.12.0
4
+ version: 1.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-30 00:00:00.000000000 Z
11
+ date: 2026-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raabro