allow raw cron sytanx
This commit is contained in:
parent
6b69ebd10f
commit
a94dda4b8b
@ -37,6 +37,10 @@ This will create an initial "config/schedule.rb" file you.
|
||||
runner "Task.do_something_great"
|
||||
end
|
||||
|
||||
every '0 0 27-31 * *' do
|
||||
command "echo 'you can use raw cron sytax too'"
|
||||
end
|
||||
|
||||
More examples on the wiki: <http://wiki.github.com/javan/whenever/instructions-and-examples>
|
||||
|
||||
### Define your own job types
|
||||
|
@ -34,6 +34,7 @@ module Whenever
|
||||
|
||||
def time_in_cron_syntax
|
||||
case @time
|
||||
when /^.+ .+ .+ .+ .+.?$/ then @time # raw cron sytax given
|
||||
when Symbol then parse_symbol
|
||||
when String then parse_as_string
|
||||
else parse_time
|
||||
|
@ -248,4 +248,21 @@ class OutputAtTest < Test::Unit::TestCase
|
||||
assert_match '27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59 * * * * blahblah', @output
|
||||
end
|
||||
end
|
||||
|
||||
context "using raw cron syntax" do
|
||||
setup do
|
||||
@output = Whenever.cron \
|
||||
<<-file
|
||||
set :job_template, nil
|
||||
every '0 0 27-31 * *' do
|
||||
command "blahblah"
|
||||
end
|
||||
file
|
||||
end
|
||||
|
||||
should "output the command using the same cron syntax" do
|
||||
assert_match '0 0 27-31 * * blahblah', @output
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -200,6 +200,15 @@ class CronTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "When given raw cron sytax" do
|
||||
should "return the same cron sytax" do
|
||||
crons = ['0 0 27-31 * *', '* * * * *', '2/3 1,9,22 11-26 1-6 *']
|
||||
crons.each do |cron|
|
||||
assert_equal cron, parse_time(cron)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_days_and_hours_and_minutes_equals(expected, time)
|
||||
|
Loading…
Reference in New Issue
Block a user