-
Notifications
You must be signed in to change notification settings - Fork 725
random times for :hour and :day #596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ef37dec
dd74dac
ea33d79
e598c07
e723270
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,25 @@ def initialize(time = nil, task = nil, at = nil) | |
@at_given = at | ||
@time = time | ||
@task = task | ||
|
||
at = randomize_at(at,time) | ||
|
||
@at = at.is_a?(String) ? (Chronic.parse(at) || 0) : (at || 0) | ||
|
||
end | ||
|
||
def randomize_at(at, time) | ||
return at unless at.nil? | ||
unless time.is_a?(Symbol) && [:hour,:day].include?(time) | ||
#puts 'Sorry, the randomizing-feature works only for symbols :hour and :day' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove debug-oriented code in the PR? |
||
return at | ||
end | ||
|
||
case time | ||
when :hour then return Random.rand(0...59) | ||
when :day then return [23,0,1,2,3,4,5,6,7].sample.to_s + ':' + Random.rand(0...59).to_s | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trivial: there are more than double spaces after the symbols? |
||
end | ||
return at | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
end | ||
|
||
def self.enumerate(item, detect_cron = true) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ class OutputJobsForRolesTest < Whenever::TestCase | |
file | ||
|
||
assert_match two_hours + " /bin/bash -l -c 'role1_cmd'", output | ||
assert_match "0 * * * * /bin/bash -l -c 'role2_cmd'", output | ||
#assert_match "0 * * * * /bin/bash -l -c 'role2_cmd'", output | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is commented out? |
||
assert_match /^[1-5]?[0-9]( \*){4} \/bin\/bash -l -c 'role2_cmd'$/ , output | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps use a link in Markdown format?