-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added auto_load option to allow jobs to declare theirs schedule
- Loading branch information
Showing
17 changed files
with
254 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,3 @@ Style/DoubleNegation: | |
Enabled: false | ||
Metrics/PerceivedComplexity: | ||
Enabled: false | ||
Metrics/ClassLength: | ||
Max: 110 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# vim:fileencoding=utf-8 | ||
|
||
module Resque | ||
module Scheduler | ||
module Job | ||
class << self | ||
def included(base) | ||
base.extend ClassMethods | ||
end | ||
end | ||
|
||
module ClassMethods | ||
def cron(value = nil) | ||
return @cron ||= nil if value.nil? | ||
@cron = value | ||
end | ||
|
||
def every(value = nil) | ||
return @every ||= nil if value.nil? | ||
@every = value | ||
end | ||
|
||
def queue(value = nil) | ||
return @queue ||= nil if value.nil? | ||
@queue = value | ||
end | ||
|
||
def args(value = nil) | ||
return @args ||= nil if value.nil? | ||
@args = value | ||
end | ||
|
||
def description(value = nil) | ||
return @description ||= nil if value.nil? | ||
@description = value | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# vim:fileencoding=utf-8 | ||
|
||
require 'resque/scheduler/job' | ||
|
||
class ErrorJob | ||
include Resque::Scheduler::Job | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# vim:fileencoding=utf-8 | ||
|
||
require 'resque/scheduler/job' | ||
|
||
class ValidCronJob | ||
include Resque::Scheduler::Job | ||
|
||
cron '*/2 * * * *' | ||
queue 'default' | ||
args 'args' | ||
description 'description' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# vim:fileencoding=utf-8 | ||
|
||
require 'resque/scheduler/job' | ||
|
||
class ValidEveryJob | ||
include Resque::Scheduler::Job | ||
|
||
every '1d' | ||
queue 'default' | ||
args 'args' | ||
description 'description' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# vim:fileencoding=utf-8 | ||
|
||
require 'resque/scheduler/job' | ||
|
||
context 'Job' do | ||
test 'has nil default parameters' do | ||
class EmptyJob | ||
include Resque::Scheduler::Job | ||
end | ||
|
||
%i(cron every queue args description).each do |p| | ||
assert_nil EmptyJob.send(p) | ||
end | ||
end | ||
|
||
test 'saves values' do | ||
class JobWithValues | ||
include Resque::Scheduler::Job | ||
|
||
cron '* */3 * * *' | ||
every '3d' | ||
queue 'default' | ||
args 'some arg' | ||
description 'nice description' | ||
end | ||
|
||
assert_equal '* */3 * * *', JobWithValues.cron | ||
assert_equal '3d', JobWithValues.every | ||
assert_equal 'default', JobWithValues.queue | ||
assert_equal 'some arg', JobWithValues.args | ||
assert_equal 'nice description', JobWithValues.description | ||
end | ||
end |
Oops, something went wrong.