floraison / fugit

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

Parse::Nat does not accept every 15 minutes #22

Closed JanStevens closed 5 years ago

JanStevens commented 5 years ago

Issue description

Attempt to parse every 15 minutes

How to reproduce

Nat seems to be able to parse the simplest cases and also 40 minutes, but throw in 30 minutes or 15 minutes and it fails to parse it (which seems a bit unexpected)

require 'fugit'
puts Fugit.parse('every 15 minutes')
puts Fugit.parse('every 30 minutes')
puts Fugit.parse("every 5 minutes")
puts Fugit.parse("every 40 minutes")

Expected behaviour

I expect that it is able to parse every case

Context

Please replace the content of this section with the output of the following commands:

Darwin fritz-macbook 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64 i386 MacBookPro14,3 Darwin
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
bundle exec ruby -r et-orbi -e "EtOrbi._make_info"

Additional context

I'm attempting to convert an iso8601 interval to cron output (I'm using sidekiq cron for my databased custom cron jobs but they all use iso8601 interval)

JanStevens commented 5 years ago

Ha I think I found it, Fugit gets mixed up a bit when just using parse, when I use Fugit::Nat.parse it always works as expected

jmettraux commented 5 years ago

Hello, thanks for reporting this.

you can also do:

Fugit.parse_nat('every 15 minutes')
jmettraux commented 5 years ago

Released as part of fugit 1.2.2.

Thanks again!