What is this?
A crontab(5) parser.
How to install?
In your Gemfile:
gem 'cronman', 'git: [email protected]:renatomoya/cronman.git'
How to use?
crontab = Cronman.parse(src)
from_date = Date.parse('2009-10-10')
to_date = Date.parse('2009-10-20')
crontab.entries.each do |entry|
# Access the cron definition
puts entry.cron_definition
# Access the cron definition translation
puts entry.translation.join(' ')
# Access the command
puts entry.command
# Access parsed cron definition
puts entry.schedule
# Filtering is easy!
e.schedule.from(from_date).until(to_date) do |timing|
puts timing
end
end
Most of this code is not mine. I borrowed it from @sakuro gem crontab. I added a few missing features for a personal project called cronman.