Skip to content
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

Accept wildcards when specifying day of week #72

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ Event Parameters
**:MM
HH:**
(Mon|mon|Monday|monday) HH:MM
(Mon|mon|Monday|monday) HH:**
(Mon|mon|Monday|monday) **:MM
(Mon|mon|Monday|monday) **:**

#### Examples

Expand Down Expand Up @@ -320,6 +323,10 @@ You can specify the day of week to run:

```ruby
every(1.week, 'myjob', :at => 'Monday 16:20')
# This runs every Monday at 16:20

every(1.hour, 'myjob', :at => 'Monday **:**')
# This runs every hour only on Mondays
```

If another task is already running at the specified time, clockwork will skip execution of the task with the `:at` option.
Expand Down
6 changes: 6 additions & 0 deletions lib/clockwork/at.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ class FailedToParse < StandardError; end
def self.parse(at)
return unless at
case at
when /\A([[:alpha:]]+)\s\*{1,2}:\*{1,2}\z/
if wday = WDAYS[$1]
new(NOT_SPECIFIED, NOT_SPECIFIED, wday)
else
raise FailedToParse, at
end
when /\A([[:alpha:]]+)\s(.*)\z/
if wday = WDAYS[$1]
parsed_time = parse($2)
Expand Down