Closed tomykaira closed 13 years ago
Cool feature, but why a new parameter? Could do :at => [ '16:20', '18:10' ]. Clockwork could detect whether the parameter is enumerable or a string and treat it as a single item or a list appropriately.
Do you mean I should use :at
, instead of create new :ats
parameter?
I agree that using :at
is cooler than mine.
This test does not pass at this point.
test "twice a day at 16:20 and 18:10" do
Clockwork.every(1.day, 'myjob', :at => ['16:20', '18:10'])
assert_wont_run Time.parse('jan 1 2010 16:19:59')
assert_will_run Time.parse('jan 1 2010 16:20:00')
assert_wont_run Time.parse('jan 1 2010 16:20:01')
assert_wont_run Time.parse('jan 1 2010 18:09:59')
assert_will_run Time.parse('jan 1 2010 18:10:00')
assert_wont_run Time.parse('jan 1 2010 18:10:01')
end
That is what I mean. Of course, you will need to change the implementation to handle it. e.g.
def parse_at(at)
if at.responds_to? :each
# handle array
else
# handle single value
end
end
Sorry for my poor English ability XD
https://github.com/tomykaira/clockwork/commit/66373f6b0b1bf24c9d712ccde38638efc9464545 How about this? (It's commit log should be cleaner...)
Specify multiple 'at' times in a line, for an action.
This prevent an user from copy-and-pasting his action (or generating by a loop).