From 800f05d6b2a74728cae0e06cffb4ccf8fbcd5817 Mon Sep 17 00:00:00 2001 From: Redithion Date: Wed, 29 Dec 2021 16:06:34 -0300 Subject: [PATCH 1/4] Accept Mon **:** in at Accept not specified minutes and hour with a given weekday. --- lib/clockwork/at.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/clockwork/at.rb b/lib/clockwork/at.rb index 19ca4f9..ada8855 100644 --- a/lib/clockwork/at.rb +++ b/lib/clockwork/at.rb @@ -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) From 3a408011e8f83f33aae898539ad80c7a90a83198 Mon Sep 17 00:00:00 2001 From: Redithion Date: Wed, 29 Dec 2021 16:11:37 -0300 Subject: [PATCH 2/4] Update Readme to reflect new at option Added the new formats supported and an example --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index f5432dc..bb35a22 100644 --- a/README.md +++ b/README.md @@ -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 @@ -320,6 +323,12 @@ 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 +``` + +```ruby +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. From dc0c18f81a2ec01441a6fd56848cf88169f70e79 Mon Sep 17 00:00:00 2001 From: Redithion Date: Wed, 29 Dec 2021 16:14:11 -0300 Subject: [PATCH 3/4] Combined two blocks of code in README Combined two separate blocks of code into one in :at example --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index bb35a22..892eb32 100644 --- a/README.md +++ b/README.md @@ -324,9 +324,7 @@ 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 -``` -```ruby every(1.hour, 'myjob', :at => 'Monday **:**') # This runs every hour only on Mondays ``` From 5cbb69418072ba3e046a0a7cbeaee1f60e5b8d94 Mon Sep 17 00:00:00 2001 From: Redithion Date: Wed, 29 Dec 2021 16:49:02 -0300 Subject: [PATCH 4/4] Fix indentation --- lib/clockwork/at.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/clockwork/at.rb b/lib/clockwork/at.rb index ada8855..39113cc 100644 --- a/lib/clockwork/at.rb +++ b/lib/clockwork/at.rb @@ -16,7 +16,7 @@ def self.parse(at) if wday = WDAYS[$1] new(NOT_SPECIFIED, NOT_SPECIFIED, wday) else - raise FailedToParse, at + raise FailedToParse, at end when /\A([[:alpha:]]+)\s(.*)\z/ if wday = WDAYS[$1]