forked from javan/whenever
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow creation of new job types from within schedule.rb. Not only doe…
…s this make it easier to define app-specific job types such as the new rails 3 runner, or jobs which need to run under bundler, but it also allows the user to create reusable system commands rather than using the :command method every time.
- Loading branch information
Showing
4 changed files
with
44 additions
and
1 deletion.
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
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,29 @@ | ||
module Whenever | ||
module Job | ||
class UserDefined < Whenever::Job::Default | ||
attr_accessor :uses_bundler, :command, :environment | ||
|
||
def initialize(options={}) | ||
super | ||
@uses_bundler = options[:uses_bundler] | ||
@command = options[:command] | ||
@env = options[:environment] | ||
end | ||
|
||
def to_options | ||
{ :uses_bundler => uses_bundler, :command => command, :environment => environment } | ||
end | ||
|
||
def output | ||
out = [] | ||
out << "cd #{File.join(@path)} &&" | ||
out << "bundle exec" if uses_bundler | ||
out << command | ||
out << "-e #{@environment}" if @env | ||
out << task.inspect | ||
out.join(" ") | ||
end | ||
|
||
end | ||
end | ||
end |