rossta / montrose

Recurring events library for Ruby. Enumerable recurrence objects and convenient chainable interface.
https://rossta.net/montrose/
MIT License
843 stars 53 forks source link

Adding to_cron method to Frequency #100

Closed dcluna closed 6 years ago

dcluna commented 6 years ago

I use this gem to save some recurring events in a database. Sometimes I need to generate a crontab from a list of these recurrences, for which these shortcuts are handy.

I understand this may have some caveats given the unspecified behavior of crontab extensions. Still, I assume this is a common enough scenario for users of this gem, so please consider including this.

To use them, one can do the following:

recurrence = # retrieve Montrose::Recurrence object here
Montrose::Frequency.from_options(recurrence.to_h).to_cron # generates cron entry
airhorns commented 6 years ago

👍 this would be great to have in the library! Useful for a standard representation to exchange with other languages too, like say later.js!

rossta commented 6 years ago

@dcluna Thanks!

Perhaps a nice-to-have would be a convenience method, Recurrence#to_cron, so library users don't need to know about Montrose::Frequency.