floraison / fugit

time tools (cron, parsing, durations, ...) for Ruby, rufus-scheduler, and flor
MIT License
353 stars 29 forks source link

Regression with parsing in 1.9+ #103

Closed mscrivo closed 2 months ago

mscrivo commented 2 months ago

Issue description

Upon upgrading to 1.10, we noticed that some of our tests started failing with the following exception:

(irb):1:in `<main>': undefined method `rough_frequency' for an instance of EtOrbi::EoTime 
(NoMethodError)

How to reproduce

require 'fugit'
Fugit.parse('* */24 * * *').rough_frequency

will throw the above exception, where it previously worked fine in 1.8.1

Note, other cron expressions work just fine, like ' *' for example.

Error and error backtrace (if any)

(irb):1:in `<main>': undefined method `rough_frequency' for an instance of EtOrbi::EoTime (NoMethodError)

Fugit.parse('* */24 * * *').rough_frequency
                           ^^^^^^^^^^^^^^^^
    from <internal:kernel>:187:in `loop'

Expected behaviour

This should not throw an exception as it's a valid cron expression

jmettraux commented 2 months ago
require 'fugit'

p Fugit.parse('* */24 * * *').class
  # ==> EtOrbi::EoTime

p Fugit.parse('* */24 * * *').to_t
  # ==> 2024-04-24 00:00:00 +0900

p Fugit.parse('* */25 * * *').to_t
  # ==> 2024-04-25 00:00:00 +0900

Thanks for spotting that, I will fix it as soon as possible.

jmettraux commented 2 months ago

Behaviour changed between 1.8.1 and 1.9.0. 1.8.1 returns Fugit::Cron instances while 1.9.0 and later return a time EtOrbi::EoTime.

jmettraux commented 2 months ago

"* */24 * * *", in the end, should be deflated into "* 0 * * *".

jmettraux commented 2 months ago

Breaking change introduced for gh-86.

jmettraux commented 2 months ago

fugit 1.11.0 released. Thanks!