whenever 0.5.3 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +9 -0
- data/README.rdoc +40 -28
- data/Rakefile +2 -2
- data/bin/whenever +11 -8
- data/lib/whenever/capistrano.rb +31 -0
- data/lib/whenever/cron.rb +3 -8
- data/lib/whenever/job.rb +14 -8
- data/lib/whenever/job_list.rb +9 -19
- data/lib/whenever/job_types/default.rb +11 -3
- data/lib/whenever/output_redirection.rb +48 -50
- data/lib/whenever/version.rb +1 -1
- data/test/functional/command_line_test.rb +4 -0
- data/test/functional/output_at_test.rb +16 -2
- data/test/functional/output_default_defined_jobs_test.rb +58 -3
- data/test/functional/output_defined_job_test.rb +7 -1
- data/test/functional/output_env_test.rb +0 -33
- data/test/functional/output_redirection_test.rb +18 -0
- data/test/unit/job_test.rb +17 -9
- data/whenever.gemspec +5 -4
- metadata +7 -13
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 0.6.1 / October 20th, 2010
|
2
|
+
|
3
|
+
* Detect script/rails file and change runner to Rails 3 style if found. [Javan Makhmali]
|
4
|
+
|
5
|
+
* Created a new :job_template system that can be applied to all commands. Wraps all in bash -l -c 'command..' by default now for better RVM support. Stopped automatically setting the PATH too. [Javan Makhmali]
|
6
|
+
|
7
|
+
* Added a built-in Capistrano recipe. [Javan Makhmali]
|
8
|
+
|
9
|
+
|
1
10
|
== 0.5.3 / September 24th, 2010
|
2
11
|
|
3
12
|
* Better regexes for replacing Whenever blocks in the crontab. #45 [Javan Makhmali]
|
data/README.rdoc
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
== Introduction
|
2
2
|
|
3
|
-
Whenever is a Ruby gem that provides a clear syntax for
|
4
|
-
|
5
|
-
Ryan Bates created a great Railscast about Whenever: http://railscasts.com/episodes/164-cron-in-ruby
|
6
|
-
|
7
|
-
Discussion: http://groups.google.com/group/whenever-gem
|
3
|
+
Whenever is a Ruby gem that provides a clear syntax for writing and deploying cron jobs.
|
8
4
|
|
9
5
|
== Installation
|
10
6
|
|
11
|
-
$
|
7
|
+
$ gem install whenever
|
12
8
|
|
9
|
+
Or with Bundler in your Gemfile.
|
10
|
+
|
11
|
+
gem 'whenever', :require => false
|
12
|
+
|
13
13
|
== Getting started
|
14
14
|
|
15
15
|
$ cd /my/rails/app
|
@@ -41,7 +41,7 @@ More examples on the wiki: http://wiki.github.com/javan/whenever/instructions-an
|
|
41
41
|
|
42
42
|
== Define your own job types
|
43
43
|
|
44
|
-
Whenever ships with three pre-defined job types: command, runner, and rake. You can define your own with
|
44
|
+
Whenever ships with three pre-defined job types: command, runner, and rake. You can define your own with `job_type`.
|
45
45
|
|
46
46
|
For example:
|
47
47
|
|
@@ -51,43 +51,52 @@ For example:
|
|
51
51
|
awesome "party", :fun_level => "extreme"
|
52
52
|
end
|
53
53
|
|
54
|
-
Would run
|
54
|
+
Would run `/usr/local/bin/awesome party extreme` every two hours. `:task` is always replaced with the first argument, and any additional `:whatevers` are replaced with the options passed in or by variables that have been defined with `set`.
|
55
55
|
|
56
56
|
The default job types that ship with Whenever are defined like so:
|
57
57
|
|
58
|
-
job_type :command, ":task"
|
59
|
-
job_type :
|
60
|
-
job_type :
|
58
|
+
job_type :command, ":task :output"
|
59
|
+
job_type :rake, "cd :path && RAILS_ENV=:environment rake :task :output"
|
60
|
+
job_type :runner, "cd :path && script/runner -e :environment ':task' :output"
|
61
|
+
|
62
|
+
If a script/rails file is detected (like in a Rails 3 app), runner will be defined to fit:
|
61
63
|
|
62
|
-
|
64
|
+
job_type :runner, "cd :path && script/rails runner -e :environment ':task' :output"
|
63
65
|
|
64
|
-
|
66
|
+
If a `:path` is not set it will default to the directory in which `whenever` was executed. `:environment` will default to 'production'. `:output` will be replaced with your output redirection settings which you can read more about here: http://github.com/javan/whenever/wiki/Output-redirection-(logging-your-cron-jobs)
|
65
67
|
|
66
|
-
|
67
|
-
$ whenever
|
68
|
+
All jobs are by default run with `bash -l -c 'command...'`. Among other things, this allows your cron jobs to play nice with RVM by loading the entire environment instead of cron's somewhat limited environment. Read more: http://blog.scoutapp.com/articles/2010/09/07/rvm-and-cron-in-production
|
68
69
|
|
69
|
-
|
70
|
+
You can change this by setting your own job_template.
|
71
|
+
|
72
|
+
set :job_template, "bash -l -c ':job'"
|
73
|
+
|
74
|
+
Or set the job_template to nil to have your jobs execute normally.
|
75
|
+
|
76
|
+
set :job_template, nil
|
77
|
+
|
78
|
+
And you'll see your schedule.rb converted to cron sytax. Note: running `whenever` with no options does not display your current crontab file, it simply shows you the output of converting your schedule.rb file.
|
70
79
|
|
71
80
|
== Capistrano integration
|
72
81
|
|
73
|
-
|
82
|
+
Use the built-in Capistrano recipe for easy crontab updates with deploys.
|
74
83
|
|
75
|
-
|
84
|
+
In your "config/deploy.rb" file:
|
76
85
|
|
77
|
-
|
78
|
-
desc "Update the crontab file"
|
79
|
-
task :update_crontab, :roles => :db do
|
80
|
-
run "cd #{release_path} && whenever --update-crontab #{application}"
|
81
|
-
end
|
82
|
-
end
|
86
|
+
require "whenever/capistrano"
|
83
87
|
|
84
|
-
|
88
|
+
Take a look at the recipe for options you can set. http://github.com/javan/whenever/blob/master/lib/whenever/capistrano.rb
|
89
|
+
For example, if you're using bundler do this:
|
85
90
|
|
86
|
-
|
91
|
+
set :whenever_command, "bundle exec whenever"
|
92
|
+
require "whenever/capistrano"
|
87
93
|
|
88
|
-
|
94
|
+
== The `whenever` command
|
89
95
|
|
90
|
-
|
96
|
+
$ cd /my/rails/app
|
97
|
+
$ whenever
|
98
|
+
|
99
|
+
This will simply show you your schedule.rb file converted to cron syntax. It does not read or write your crontab file. Run `whenever --help` for a complete list of options.
|
91
100
|
|
92
101
|
== Credit
|
93
102
|
|
@@ -101,6 +110,9 @@ For general discussion and questions, please use the google group: http://groups
|
|
101
110
|
|
102
111
|
If you've found a genuine bug or issue, please use the Issues section on github: http://github.com/javan/whenever/issues
|
103
112
|
|
113
|
+
Ryan Bates created a great Railscast about Whenever: http://railscasts.com/episodes/164-cron-in-ruby
|
114
|
+
It's a little bit dated now, but remains a good introduction.
|
115
|
+
|
104
116
|
== License
|
105
117
|
|
106
118
|
Copyright (c) 2009+ Javan Makhmali
|
data/Rakefile
CHANGED
@@ -8,8 +8,8 @@ begin
|
|
8
8
|
Jeweler::Tasks.new do |gemspec|
|
9
9
|
gemspec.name = "whenever"
|
10
10
|
gemspec.version = Whenever::VERSION
|
11
|
-
gemspec.summary = "Clean ruby syntax for
|
12
|
-
gemspec.description = "
|
11
|
+
gemspec.summary = "Clean ruby syntax for writing and deploying cron jobs."
|
12
|
+
gemspec.description = "http://www.allyrics.net/Kid-Cudi/lyrics/Whenever/"
|
13
13
|
gemspec.email = "javan@javan.us"
|
14
14
|
gemspec.homepage = "http://github.com/javan/whenever"
|
15
15
|
gemspec.authors = ["Javan Makhmali"]
|
data/bin/whenever
CHANGED
@@ -4,32 +4,35 @@ require 'rubygems'
|
|
4
4
|
require 'optparse'
|
5
5
|
require 'whenever'
|
6
6
|
|
7
|
-
options =
|
7
|
+
options = {}
|
8
8
|
|
9
9
|
OptionParser.new do |opts|
|
10
10
|
opts.banner = "Usage: whenever [options]"
|
11
|
-
opts.on('-v', '--version') { puts "Whenever v#{Whenever::VERSION}"; exit(0) }
|
12
|
-
opts.on('-w', '--write-crontab') { options[:write] = true }
|
13
|
-
opts.on('-c', '--cut [lines]', 'Cut lines from the top of the cronfile') do |lines|
|
14
|
-
options[:cut] = lines.to_i if lines
|
15
|
-
end
|
16
11
|
opts.on('-i', '--update-crontab [identifier]', 'Default: full path to schedule.rb file') do |identifier|
|
17
12
|
options[:update] = true
|
18
13
|
options[:identifier] = identifier if identifier
|
19
14
|
end
|
15
|
+
opts.on('-w', '--write-crontab [identifier]', 'Default: full path to schedule.rb file') do |identifier|
|
16
|
+
options[:write] = true
|
17
|
+
options[:identifier] = identifier if identifier
|
18
|
+
end
|
20
19
|
opts.on('-c', '--clear-crontab [identifier]') do |identifier|
|
21
20
|
options[:clear] = true
|
22
21
|
options[:identifier] = identifier if identifier
|
23
22
|
end
|
23
|
+
opts.on('-s', '--set [variables]', 'Example: --set environment=staging&path=/my/sweet/path') do |set|
|
24
|
+
options[:set] = set if set
|
25
|
+
end
|
24
26
|
opts.on('-f', '--load-file [schedule file]', 'Default: config/schedule.rb') do |file|
|
25
27
|
options[:file] = file if file
|
26
28
|
end
|
27
29
|
opts.on('-u', '--user [user]', 'Default: current user') do |user|
|
28
30
|
options[:user] = user if user
|
29
31
|
end
|
30
|
-
opts.on('-
|
31
|
-
options[:
|
32
|
+
opts.on('-k', '--cut [lines]', 'Cut lines from the top of the cronfile') do |lines|
|
33
|
+
options[:cut] = lines.to_i if lines
|
32
34
|
end
|
35
|
+
opts.on('-v', '--version') { puts "Whenever v#{Whenever::VERSION}"; exit(0) }
|
33
36
|
end.parse!
|
34
37
|
|
35
38
|
Whenever::CommandLine.execute(options)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
_cset(:whenever_roles) { :db }
|
4
|
+
_cset(:whenever_command) { "whenever" }
|
5
|
+
_cset(:whenever_identifier) { application }
|
6
|
+
_cset(:whenever_update_flags) { "--update-crontab #{whenever_identifier}" }
|
7
|
+
_cset(:whenever_clear_flags) { "--clear-crontab #{whenever_identifier}" }
|
8
|
+
|
9
|
+
# Disable cron jobs at the begining of a deploy.
|
10
|
+
after "deploy:update_code", "whenever:clear_crontab"
|
11
|
+
# Write the new cron jobs near the end.
|
12
|
+
after "deploy:symlink", "whenever:update_crontab"
|
13
|
+
# If anything goes wrong, undo.
|
14
|
+
after "deploy:rollback", "whenever:update_crontab"
|
15
|
+
|
16
|
+
namespace :whenever do
|
17
|
+
desc "Update application's crontab entries using Whenever"
|
18
|
+
task :update_crontab, :roles => whenever_roles do
|
19
|
+
# Hack by Jamis to skip a task if the role has no servers defined. http://tinyurl.com/ckjgnz
|
20
|
+
next if find_servers_for_task(current_task).empty?
|
21
|
+
run "cd #{current_path} && #{whenever_command} #{whenever_update_flags}"
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Clear application's crontab entries using Whenever"
|
25
|
+
task :clear_crontab, :roles => whenever_roles do
|
26
|
+
next if find_servers_for_task(current_task).empty?
|
27
|
+
run "cd #{release_path} && #{whenever_command} #{whenever_clear_flags}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/whenever/cron.rb
CHANGED
@@ -4,11 +4,10 @@ module Whenever
|
|
4
4
|
|
5
5
|
attr_accessor :time, :task
|
6
6
|
|
7
|
-
def initialize(time = nil, task = nil, at = nil
|
7
|
+
def initialize(time = nil, task = nil, at = nil)
|
8
8
|
@time = time
|
9
9
|
@task = task
|
10
10
|
@at = at.is_a?(String) ? (Chronic.parse(at) || 0) : (at || 0)
|
11
|
-
@output_redirection = output_redirection
|
12
11
|
end
|
13
12
|
|
14
13
|
def self.enumerate(item)
|
@@ -24,13 +23,13 @@ module Whenever
|
|
24
23
|
def self.output(times, job)
|
25
24
|
enumerate(times).each do |time|
|
26
25
|
enumerate(job.at).each do |at|
|
27
|
-
yield new(time, job.output, at
|
26
|
+
yield new(time, job.output, at).output
|
28
27
|
end
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
32
31
|
def output
|
33
|
-
[time_in_cron_syntax, task
|
32
|
+
[time_in_cron_syntax, task].compact.join(' ').strip
|
34
33
|
end
|
35
34
|
|
36
35
|
def time_in_cron_syntax
|
@@ -40,10 +39,6 @@ module Whenever
|
|
40
39
|
else parse_time
|
41
40
|
end
|
42
41
|
end
|
43
|
-
|
44
|
-
def output_redirection
|
45
|
-
Whenever::Output::Cron::OutputRedirection.new(@output_redirection).to_s unless @output_redirection == :not_set
|
46
|
-
end
|
47
42
|
|
48
43
|
protected
|
49
44
|
|
data/lib/whenever/job.rb
CHANGED
@@ -1,21 +1,29 @@
|
|
1
1
|
module Whenever
|
2
2
|
class Job
|
3
3
|
|
4
|
-
attr_reader :at
|
4
|
+
attr_reader :at
|
5
5
|
|
6
6
|
def initialize(options = {})
|
7
7
|
@options = options
|
8
|
-
|
9
|
-
@
|
10
|
-
@
|
8
|
+
@at = options.delete(:at)
|
9
|
+
@template = options.delete(:template)
|
10
|
+
@job_template = options.delete(:job_template) || ":job"
|
11
|
+
@options[:output] = Whenever::Output::Redirection.new(options[:output]).to_s if options.has_key?(:output)
|
11
12
|
@options[:environment] ||= :production
|
12
13
|
@options[:path] ||= Whenever.path
|
13
14
|
end
|
14
15
|
|
15
16
|
def output
|
16
|
-
@options
|
17
|
+
job = process_template(@template, @options).strip
|
18
|
+
process_template(@job_template, { :job => job }).strip
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def process_template(template, options)
|
24
|
+
template.gsub(/:\w+/) do |key|
|
17
25
|
before_and_after = [$`[-1..-1], $'[0..0]]
|
18
|
-
option =
|
26
|
+
option = options[key.sub(':', '').to_sym]
|
19
27
|
|
20
28
|
if before_and_after.all? { |c| c == "'" }
|
21
29
|
escape_single_quotes(option)
|
@@ -26,8 +34,6 @@ module Whenever
|
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
29
|
-
|
30
|
-
protected
|
31
37
|
|
32
38
|
def escape_single_quotes(str)
|
33
39
|
str.gsub(/'/) { "'\\''" }
|
data/lib/whenever/job_list.rb
CHANGED
@@ -2,7 +2,7 @@ module Whenever
|
|
2
2
|
class JobList
|
3
3
|
|
4
4
|
def initialize(options)
|
5
|
-
@jobs, @env, @set_variables = {}, {}, {}
|
5
|
+
@jobs, @env, @set_variables, @pre_set_variables = {}, {}, {}, {}
|
6
6
|
|
7
7
|
case options
|
8
8
|
when String
|
@@ -25,7 +25,8 @@ module Whenever
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def set(variable, value)
|
28
|
-
|
28
|
+
variable = variable.to_sym
|
29
|
+
return if @pre_set_variables[variable]
|
29
30
|
|
30
31
|
instance_variable_set("@#{variable}".to_sym, value)
|
31
32
|
self.class.send(:attr_reader, variable.to_sym)
|
@@ -59,9 +60,7 @@ module Whenever
|
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
62
|
-
def generate_cron_output
|
63
|
-
set_path_environment_variable
|
64
|
-
|
63
|
+
def generate_cron_output
|
65
64
|
[environment_variables, cron_jobs].compact.join
|
66
65
|
end
|
67
66
|
|
@@ -79,22 +78,13 @@ module Whenever
|
|
79
78
|
pairs.each do |pair|
|
80
79
|
next unless pair.index('=')
|
81
80
|
variable, value = *pair.split('=')
|
82
|
-
|
81
|
+
unless variable.blank? || value.blank?
|
82
|
+
variable = variable.strip.to_sym
|
83
|
+
set(variable, value.strip)
|
84
|
+
@pre_set_variables[variable] = value
|
85
|
+
end
|
83
86
|
end
|
84
87
|
end
|
85
|
-
|
86
|
-
def set_path_environment_variable
|
87
|
-
return if path_should_not_be_set_automatically?
|
88
|
-
@env[:PATH] = read_path unless read_path.blank?
|
89
|
-
end
|
90
|
-
|
91
|
-
def read_path
|
92
|
-
ENV['PATH'] if ENV
|
93
|
-
end
|
94
|
-
|
95
|
-
def path_should_not_be_set_automatically?
|
96
|
-
@set_path_automatically === false || @env[:PATH] || @env["PATH"]
|
97
|
-
end
|
98
88
|
|
99
89
|
def environment_variables
|
100
90
|
return if @env.empty?
|
@@ -1,3 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# http://blog.scoutapp.com/articles/2010/09/07/rvm-and-cron-in-production
|
2
|
+
set :job_template, "/bin/bash -l -c ':job'"
|
3
|
+
|
4
|
+
job_type :command, ":task :output"
|
5
|
+
job_type :rake, "cd :path && RAILS_ENV=:environment rake :task --silent :output"
|
6
|
+
|
7
|
+
if File.exists?(File.join(Whenever.path, 'script', 'rails'))
|
8
|
+
job_type :runner, "cd :path && script/rails runner -e :environment ':task' :output"
|
9
|
+
else
|
10
|
+
job_type :runner, "cd :path && script/runner -e :environment ':task' :output"
|
11
|
+
end
|
@@ -1,60 +1,58 @@
|
|
1
1
|
module Whenever
|
2
2
|
module Output
|
3
|
-
class
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
3
|
+
class Redirection
|
4
|
+
|
5
|
+
def initialize(output)
|
6
|
+
@output = output
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
return '' unless defined?(@output)
|
11
|
+
case @output
|
12
|
+
when String then redirect_from_string
|
13
|
+
when Hash then redirect_from_hash
|
14
|
+
when NilClass then ">> /dev/null 2>&1"
|
15
|
+
else ''
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def stdout
|
22
|
+
return unless @output.has_key?(:standard)
|
23
|
+
@output[:standard].nil? ? '/dev/null' : @output[:standard]
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
def stderr
|
27
|
+
return unless @output.has_key?(:error)
|
28
|
+
@output[:error].nil? ? '/dev/null' : @output[:error]
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
31
|
+
def redirect_from_hash
|
32
|
+
case
|
33
|
+
when stdout == '/dev/null' && stderr == '/dev/null'
|
34
|
+
"> /dev/null 2>&1"
|
35
|
+
when stdout && stderr == '/dev/null'
|
36
|
+
">> #{stdout} 2> /dev/null"
|
37
|
+
when stdout && stderr
|
38
|
+
">> #{stdout} 2>> #{stderr}"
|
39
|
+
when stderr == '/dev/null'
|
40
|
+
"2> /dev/null"
|
41
|
+
when stderr
|
42
|
+
"2>> #{stderr}"
|
43
|
+
when stdout == '/dev/null'
|
44
|
+
"> /dev/null"
|
45
|
+
when stdout
|
46
|
+
">> #{stdout}"
|
47
|
+
else
|
48
|
+
''
|
51
49
|
end
|
50
|
+
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
|
52
|
+
def redirect_from_string
|
53
|
+
">> #{@output} 2>&1"
|
57
54
|
end
|
55
|
+
|
58
56
|
end
|
59
57
|
end
|
60
58
|
end
|
data/lib/whenever/version.rb
CHANGED
@@ -217,6 +217,7 @@ NEW_CRON
|
|
217
217
|
setup do
|
218
218
|
@output = Whenever.cron :set => 'environment=serious', :string => \
|
219
219
|
<<-file
|
220
|
+
set :job_template, nil
|
220
221
|
set :environment, :silly
|
221
222
|
set :path, '/my/path'
|
222
223
|
every 2.hours do
|
@@ -234,6 +235,7 @@ NEW_CRON
|
|
234
235
|
setup do
|
235
236
|
@output = Whenever.cron :set => 'environment=serious&path=/serious/path', :string => \
|
236
237
|
<<-file
|
238
|
+
set :job_template, nil
|
237
239
|
set :environment, :silly
|
238
240
|
set :path, '/silly/path'
|
239
241
|
every 2.hours do
|
@@ -251,6 +253,7 @@ NEW_CRON
|
|
251
253
|
setup do
|
252
254
|
@output = Whenever.cron :set => ' environment = serious& path =/serious/path', :string => \
|
253
255
|
<<-file
|
256
|
+
set :job_template, nil
|
254
257
|
set :environment, :silly
|
255
258
|
set :path, '/silly/path'
|
256
259
|
every 2.hours do
|
@@ -268,6 +271,7 @@ NEW_CRON
|
|
268
271
|
setup do
|
269
272
|
@output = Whenever.cron :set => ' environment=', :string => \
|
270
273
|
<<-file
|
274
|
+
set :job_template, nil
|
271
275
|
set :environment, :silly
|
272
276
|
set :path, '/silly/path'
|
273
277
|
every 2.hours do
|
@@ -6,6 +6,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
6
6
|
setup do
|
7
7
|
@output = Whenever.cron \
|
8
8
|
<<-file
|
9
|
+
set :job_template, nil
|
9
10
|
every "weekday", :at => '5:02am' do
|
10
11
|
command "blahblah"
|
11
12
|
end
|
@@ -21,6 +22,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
21
22
|
setup do
|
22
23
|
@output = Whenever.cron \
|
23
24
|
<<-file
|
25
|
+
set :job_template, nil
|
24
26
|
every "weekday", :at => %w(5:02am 3:52pm) do
|
25
27
|
command "blahblah"
|
26
28
|
end
|
@@ -37,6 +39,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
37
39
|
setup do
|
38
40
|
@output = Whenever.cron \
|
39
41
|
<<-file
|
42
|
+
set :job_template, nil
|
40
43
|
every "weekday", :at => '5:02am, 3:52pm' do
|
41
44
|
command "blahblah"
|
42
45
|
end
|
@@ -53,6 +56,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
53
56
|
setup do
|
54
57
|
@output = Whenever.cron \
|
55
58
|
<<-file
|
59
|
+
set :job_template, nil
|
56
60
|
every "weekday", :at => '5:02am, 3:02pm' do
|
57
61
|
command "blahblah"
|
58
62
|
end
|
@@ -68,6 +72,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
68
72
|
setup do
|
69
73
|
@output = Whenever.cron \
|
70
74
|
<<-file
|
75
|
+
set :job_template, nil
|
71
76
|
every "mon,wed,fri", :at => '5:02am, 3:02pm' do
|
72
77
|
command "blahblah"
|
73
78
|
end
|
@@ -83,6 +88,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
83
88
|
setup do
|
84
89
|
@output = Whenever.cron \
|
85
90
|
<<-file
|
91
|
+
set :job_template, nil
|
86
92
|
set :path, '/your/path'
|
87
93
|
every "mon,wed,fri", :at => '5:02am, 3:02pm' do
|
88
94
|
runner "blahblah"
|
@@ -99,6 +105,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
99
105
|
setup do
|
100
106
|
@output = Whenever.cron \
|
101
107
|
<<-file
|
108
|
+
set :job_template, nil
|
102
109
|
set :path, '/your/path'
|
103
110
|
every "mon,wed,fri", :at => '5:02am, 3:02pm' do
|
104
111
|
rake "blah:blah"
|
@@ -107,7 +114,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
107
114
|
end
|
108
115
|
|
109
116
|
should "output the rake task using one entry because the times are aligned" do
|
110
|
-
assert_match '2 5,15 * * 1,3,5 cd /your/path && RAILS_ENV=production
|
117
|
+
assert_match '2 5,15 * * 1,3,5 cd /your/path && RAILS_ENV=production rake blah:blah --silent', @output
|
111
118
|
end
|
112
119
|
end
|
113
120
|
|
@@ -115,6 +122,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
115
122
|
setup do
|
116
123
|
@output = Whenever.cron \
|
117
124
|
<<-file
|
125
|
+
set :job_template, nil
|
118
126
|
every [1.month, 1.day], :at => 'january 5:02am, june 17th at 2:22pm, june 3rd at 3:33am' do
|
119
127
|
command "blahblah"
|
120
128
|
end
|
@@ -138,6 +146,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
138
146
|
setup do
|
139
147
|
@output = Whenever.cron \
|
140
148
|
<<-file
|
149
|
+
set :job_template, nil
|
141
150
|
every :reboot do
|
142
151
|
command "command_1"
|
143
152
|
command "command_2"
|
@@ -155,6 +164,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
155
164
|
setup do
|
156
165
|
@output = Whenever.cron \
|
157
166
|
<<-file
|
167
|
+
set :job_template, nil
|
158
168
|
set :path, '/your/path'
|
159
169
|
every :day do
|
160
170
|
rake "blah:blah"
|
@@ -167,7 +177,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
167
177
|
end
|
168
178
|
|
169
179
|
should "output all of the commands @daily" do
|
170
|
-
assert_match '@daily cd /your/path && RAILS_ENV=production
|
180
|
+
assert_match '@daily cd /your/path && RAILS_ENV=production rake blah:blah --silent', @output
|
171
181
|
assert_match %(@daily cd /your/path && script/runner -e production 'runner_1'), @output
|
172
182
|
assert_match '@daily command_1', @output
|
173
183
|
assert_match %(@daily cd /your/path && script/runner -e production 'runner_2'), @output
|
@@ -179,6 +189,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
179
189
|
setup do
|
180
190
|
@output = Whenever.cron \
|
181
191
|
<<-file
|
192
|
+
set :job_template, nil
|
182
193
|
every 5.minutes, :at => 1 do
|
183
194
|
command "blahblah"
|
184
195
|
end
|
@@ -194,6 +205,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
194
205
|
setup do
|
195
206
|
@output = Whenever.cron \
|
196
207
|
<<-file
|
208
|
+
set :job_template, nil
|
197
209
|
every 4.minutes, :at => 2 do
|
198
210
|
command "blahblah"
|
199
211
|
end
|
@@ -209,6 +221,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
209
221
|
setup do
|
210
222
|
@output = Whenever.cron \
|
211
223
|
<<-file
|
224
|
+
set :job_template, nil
|
212
225
|
every 3.minutes, :at => 7 do
|
213
226
|
command "blahblah"
|
214
227
|
end
|
@@ -224,6 +237,7 @@ class OutputAtTest < Test::Unit::TestCase
|
|
224
237
|
setup do
|
225
238
|
@output = Whenever.cron \
|
226
239
|
<<-file
|
240
|
+
set :job_template, nil
|
227
241
|
every 2.minutes, :at => 27 do
|
228
242
|
command "blahblah"
|
229
243
|
end
|
@@ -4,10 +4,11 @@ class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
# command
|
6
6
|
|
7
|
-
context "A plain command" do
|
7
|
+
context "A plain command with the job template set to nil" do
|
8
8
|
setup do
|
9
9
|
@output = Whenever.cron \
|
10
10
|
<<-file
|
11
|
+
set :job_template, nil
|
11
12
|
every 2.hours do
|
12
13
|
command "blahblah"
|
13
14
|
end
|
@@ -19,12 +20,45 @@ class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
|
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
23
|
+
context "A plain command with no job template set" do
|
24
|
+
setup do
|
25
|
+
@output = Whenever.cron \
|
26
|
+
<<-file
|
27
|
+
every 2.hours do
|
28
|
+
command "blahblah"
|
29
|
+
end
|
30
|
+
file
|
31
|
+
end
|
32
|
+
|
33
|
+
should "output the command with the default job template" do
|
34
|
+
assert_match /^.+ .+ .+ .+ \/bin\/bash -l -c 'blahblah'$/, @output
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "A plain command that overrides the job_template set" do
|
39
|
+
setup do
|
40
|
+
@output = Whenever.cron \
|
41
|
+
<<-file
|
42
|
+
set :job_template, "/bin/bash -l -c ':job'"
|
43
|
+
every 2.hours do
|
44
|
+
command "blahblah", :job_template => "/bin/sh -l -c ':job'"
|
45
|
+
end
|
46
|
+
file
|
47
|
+
end
|
48
|
+
|
49
|
+
should "output the command using that job_template" do
|
50
|
+
assert_match /^.+ .+ .+ .+ \/bin\/sh -l -c 'blahblah'$/, @output
|
51
|
+
assert_no_match /bash/, @output
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
22
55
|
# runner
|
23
56
|
|
24
57
|
context "A runner with path set" do
|
25
58
|
setup do
|
26
59
|
@output = Whenever.cron \
|
27
60
|
<<-file
|
61
|
+
set :job_template, nil
|
28
62
|
set :path, '/my/path'
|
29
63
|
every 2.hours do
|
30
64
|
runner 'blahblah'
|
@@ -41,6 +75,7 @@ class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
|
|
41
75
|
setup do
|
42
76
|
@output = Whenever.cron \
|
43
77
|
<<-file
|
78
|
+
set :job_template, nil
|
44
79
|
set :path, '/my/path'
|
45
80
|
every 2.hours do
|
46
81
|
runner "blahblah", :path => '/some/other/path'
|
@@ -53,12 +88,31 @@ class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
|
|
53
88
|
end
|
54
89
|
end
|
55
90
|
|
91
|
+
context "A runner for a Rails 3 app" do
|
92
|
+
setup do
|
93
|
+
Whenever.expects(:path).at_least_once.returns('/my/path')
|
94
|
+
File.expects(:exists?).with('/my/path/script/rails').returns(true)
|
95
|
+
@output = Whenever.cron \
|
96
|
+
<<-file
|
97
|
+
set :job_template, nil
|
98
|
+
every 2.hours do
|
99
|
+
runner 'blahblah'
|
100
|
+
end
|
101
|
+
file
|
102
|
+
end
|
103
|
+
|
104
|
+
should "use the Rails 3 runner job by default" do
|
105
|
+
assert_match two_hours + %( cd /my/path && script/rails runner -e production 'blahblah'), @output
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
56
109
|
# rake
|
57
110
|
|
58
111
|
context "A rake command with path set" do
|
59
112
|
setup do
|
60
113
|
@output = Whenever.cron \
|
61
114
|
<<-file
|
115
|
+
set :job_template, nil
|
62
116
|
set :path, '/my/path'
|
63
117
|
every 2.hours do
|
64
118
|
rake "blahblah"
|
@@ -67,7 +121,7 @@ class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
|
|
67
121
|
end
|
68
122
|
|
69
123
|
should "output the rake command using that path" do
|
70
|
-
assert_match two_hours + ' cd /my/path && RAILS_ENV=production
|
124
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=production rake blahblah --silent', @output
|
71
125
|
end
|
72
126
|
end
|
73
127
|
|
@@ -75,6 +129,7 @@ class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
|
|
75
129
|
setup do
|
76
130
|
@output = Whenever.cron \
|
77
131
|
<<-file
|
132
|
+
set :job_template, nil
|
78
133
|
set :path, '/my/path'
|
79
134
|
every 2.hours do
|
80
135
|
rake "blahblah", :path => '/some/other/path'
|
@@ -83,7 +138,7 @@ class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
|
|
83
138
|
end
|
84
139
|
|
85
140
|
should "output the rake command using that path" do
|
86
|
-
assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production
|
141
|
+
assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production rake blahblah --silent', @output
|
87
142
|
end
|
88
143
|
end
|
89
144
|
|
@@ -6,6 +6,7 @@ class OutputDefinedJobTest < Test::Unit::TestCase
|
|
6
6
|
setup do
|
7
7
|
@output = Whenever.cron \
|
8
8
|
<<-file
|
9
|
+
set :job_template, nil
|
9
10
|
job_type :some_job, "before :task after"
|
10
11
|
every 2.hours do
|
11
12
|
some_job "during"
|
@@ -22,6 +23,7 @@ class OutputDefinedJobTest < Test::Unit::TestCase
|
|
22
23
|
setup do
|
23
24
|
@output = Whenever.cron \
|
24
25
|
<<-file
|
26
|
+
set :job_template, nil
|
25
27
|
job_type :some_job, "before :task after :option1 :option2"
|
26
28
|
every 2.hours do
|
27
29
|
some_job "during", :option1 => 'happy', :option2 => 'birthday'
|
@@ -38,6 +40,7 @@ class OutputDefinedJobTest < Test::Unit::TestCase
|
|
38
40
|
setup do
|
39
41
|
@output = Whenever.cron \
|
40
42
|
<<-file
|
43
|
+
set :job_template, nil
|
41
44
|
job_type :some_job, "before :task after :option1"
|
42
45
|
set :option1, 'happy'
|
43
46
|
every 2.hours do
|
@@ -55,6 +58,7 @@ class OutputDefinedJobTest < Test::Unit::TestCase
|
|
55
58
|
setup do
|
56
59
|
@output = Whenever.cron \
|
57
60
|
<<-file
|
61
|
+
set :job_template, nil
|
58
62
|
job_type :some_job, "before :task after :option1"
|
59
63
|
set :option1, 'global'
|
60
64
|
every 2.hours do
|
@@ -72,6 +76,7 @@ class OutputDefinedJobTest < Test::Unit::TestCase
|
|
72
76
|
setup do
|
73
77
|
@output = Whenever.cron \
|
74
78
|
<<-file
|
79
|
+
set :job_template, nil
|
75
80
|
job_type :some_job, "before :task after :option1"
|
76
81
|
every 2.hours do
|
77
82
|
some_job "during", :option2 => 'happy'
|
@@ -86,10 +91,11 @@ class OutputDefinedJobTest < Test::Unit::TestCase
|
|
86
91
|
|
87
92
|
context "A defined job that uses a :path where none is explicitly set" do
|
88
93
|
setup do
|
89
|
-
Whenever.
|
94
|
+
Whenever.stubs(:path).returns('/my/path')
|
90
95
|
|
91
96
|
@output = Whenever.cron \
|
92
97
|
<<-file
|
98
|
+
set :job_template, nil
|
93
99
|
job_type :some_job, "cd :path && :task"
|
94
100
|
every 2.hours do
|
95
101
|
some_job 'blahblah'
|
@@ -19,38 +19,5 @@ class OutputEnvTest < Test::Unit::TestCase
|
|
19
19
|
assert_match "MAILTO=someone@example.com", @output
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
23
|
-
context "No PATH environment variable set" do
|
24
|
-
setup do
|
25
|
-
Whenever::JobList.any_instance.expects(:read_path).at_least_once.returns('/usr/local/bin')
|
26
|
-
@output = Whenever.cron ""
|
27
|
-
end
|
28
|
-
|
29
|
-
should "add a PATH variable based on the user's PATH" do
|
30
|
-
assert_match "PATH=/usr/local/bin", @output
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "A PATH environment variable set" do
|
35
|
-
setup do
|
36
|
-
Whenever::JobList.stubs(:read_path).returns('/usr/local/bin')
|
37
|
-
@output = Whenever.cron "env :PATH, '/my/path'"
|
38
|
-
end
|
39
|
-
|
40
|
-
should "use that path and the user's PATH" do
|
41
|
-
assert_match "PATH=/my/path", @output
|
42
|
-
assert_no_match /local/, @output
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "No PATH set and instructed not to automatically load the user's path" do
|
47
|
-
setup do
|
48
|
-
@output = Whenever.cron "set :set_path_automatically, false"
|
49
|
-
end
|
50
|
-
|
51
|
-
should "not have a PATH set" do
|
52
|
-
assert_no_match /PATH/, @output
|
53
|
-
end
|
54
|
-
end
|
55
22
|
|
56
23
|
end
|
@@ -6,6 +6,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
6
6
|
setup do
|
7
7
|
@output = Whenever.cron \
|
8
8
|
<<-file
|
9
|
+
set :job_template, nil
|
9
10
|
set :output, nil
|
10
11
|
every 2.hours do
|
11
12
|
command "blahblah"
|
@@ -23,6 +24,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
23
24
|
setup do
|
24
25
|
@output = Whenever.cron \
|
25
26
|
<<-file
|
27
|
+
set :job_template, nil
|
26
28
|
set :output, 'logfile.log'
|
27
29
|
every 2.hours do
|
28
30
|
command "blahblah"
|
@@ -39,6 +41,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
39
41
|
setup do
|
40
42
|
@output = Whenever.cron \
|
41
43
|
<<-file
|
44
|
+
set :job_template, nil
|
42
45
|
every 2.hours do
|
43
46
|
command "blahblah", :output => {:standard => 'dev_null', :error => 'dev_err'}
|
44
47
|
end
|
@@ -54,6 +57,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
54
57
|
setup do
|
55
58
|
@output = Whenever.cron \
|
56
59
|
<<-file
|
60
|
+
set :job_template, nil
|
57
61
|
set :output, 'logfile.log'
|
58
62
|
every 2.hours do
|
59
63
|
command "blahblah", :output => 'otherlog.log'
|
@@ -71,6 +75,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
71
75
|
setup do
|
72
76
|
@output = Whenever.cron \
|
73
77
|
<<-file
|
78
|
+
set :job_template, nil
|
74
79
|
set :output, 'logfile.log'
|
75
80
|
every 2.hours do
|
76
81
|
command "blahblah", :output => {:error => 'dev_err', :standard => 'dev_null' }
|
@@ -88,6 +93,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
88
93
|
setup do
|
89
94
|
@output = Whenever.cron \
|
90
95
|
<<-file
|
96
|
+
set :job_template, nil
|
91
97
|
set :output, 'logfile.log'
|
92
98
|
every 2.hours do
|
93
99
|
command "blahblah", :output => false
|
@@ -105,6 +111,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
105
111
|
setup do
|
106
112
|
@output = Whenever.cron :set => 'output=otherlog.log', :string => \
|
107
113
|
<<-file
|
114
|
+
set :job_template, nil
|
108
115
|
set :output, 'logfile.log'
|
109
116
|
every 2.hours do
|
110
117
|
command "blahblah"
|
@@ -122,6 +129,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
122
129
|
setup do
|
123
130
|
@output = Whenever.cron \
|
124
131
|
<<-file
|
132
|
+
set :job_template, nil
|
125
133
|
set :output, {:error => 'dev_err', :standard => 'dev_null' }
|
126
134
|
every 2.hours do
|
127
135
|
command "blahblah"
|
@@ -138,6 +146,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
138
146
|
setup do
|
139
147
|
@output = Whenever.cron \
|
140
148
|
<<-file
|
149
|
+
set :job_template, nil
|
141
150
|
set :output, {:error => 'dev_null'}
|
142
151
|
every 2.hours do
|
143
152
|
command "blahblah"
|
@@ -154,6 +163,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
154
163
|
setup do
|
155
164
|
@output = Whenever.cron \
|
156
165
|
<<-file
|
166
|
+
set :job_template, nil
|
157
167
|
set :output, {:standard => 'dev_out'}
|
158
168
|
every 2.hours do
|
159
169
|
command "blahblah"
|
@@ -170,6 +180,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
170
180
|
setup do
|
171
181
|
@output = Whenever.cron \
|
172
182
|
<<-file
|
183
|
+
set :job_template, nil
|
173
184
|
every 2.hours do
|
174
185
|
command "blahblah", :output => {:error => 'dev_err'}
|
175
186
|
end
|
@@ -185,6 +196,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
185
196
|
setup do
|
186
197
|
@output = Whenever.cron \
|
187
198
|
<<-file
|
199
|
+
set :job_template, nil
|
188
200
|
every 2.hours do
|
189
201
|
command "blahblah", :output => {:standard => 'dev_out'}
|
190
202
|
end
|
@@ -200,6 +212,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
200
212
|
setup do
|
201
213
|
@output = Whenever.cron \
|
202
214
|
<<-file
|
215
|
+
set :job_template, nil
|
203
216
|
every 2.hours do
|
204
217
|
command "blahblah", :output => {:standard => nil}
|
205
218
|
end
|
@@ -215,6 +228,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
215
228
|
setup do
|
216
229
|
@output = Whenever.cron \
|
217
230
|
<<-file
|
231
|
+
set :job_template, nil
|
218
232
|
every 2.hours do
|
219
233
|
command "blahblah", :output => {:error => nil}
|
220
234
|
end
|
@@ -230,6 +244,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
230
244
|
setup do
|
231
245
|
@output = Whenever.cron \
|
232
246
|
<<-file
|
247
|
+
set :job_template, nil
|
233
248
|
every 2.hours do
|
234
249
|
command "blahblah", :output => {:error => nil, :standard => nil}
|
235
250
|
end
|
@@ -245,6 +260,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
245
260
|
setup do
|
246
261
|
@output = Whenever.cron \
|
247
262
|
<<-file
|
263
|
+
set :job_template, nil
|
248
264
|
every 2.hours do
|
249
265
|
command "blahblah", :output => {:error => nil, :standard => 'my.log'}
|
250
266
|
end
|
@@ -260,6 +276,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
260
276
|
setup do
|
261
277
|
@output = Whenever.cron \
|
262
278
|
<<-file
|
279
|
+
set :job_template, nil
|
263
280
|
every 2.hours do
|
264
281
|
command "blahblah", :output => {:error => 'my_error.log', :standard => nil}
|
265
282
|
end
|
@@ -275,6 +292,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
275
292
|
setup do
|
276
293
|
@output = Whenever.cron \
|
277
294
|
<<-file
|
295
|
+
set :job_template, nil
|
278
296
|
set :cron_log, "cron.log"
|
279
297
|
every 2.hours do
|
280
298
|
command "blahblah"
|
data/test/unit/job_test.rb
CHANGED
@@ -7,14 +7,6 @@ class JobTest < Test::Unit::TestCase
|
|
7
7
|
assert_equal 'foo', new_job(:at => 'foo').at
|
8
8
|
end
|
9
9
|
|
10
|
-
should "return :output when #output_redirection is called" do
|
11
|
-
assert_equal 'foo', new_job(:output => 'foo').output_redirection
|
12
|
-
end
|
13
|
-
|
14
|
-
should "return :not_set when #output_redirection is called and no :output is set" do
|
15
|
-
assert_equal :not_set, new_job.output_redirection
|
16
|
-
end
|
17
|
-
|
18
10
|
should "substitute the :task when #output is called" do
|
19
11
|
job = new_job(:template => ":task", :task => 'abc123')
|
20
12
|
assert_equal 'abc123', job.output
|
@@ -32,7 +24,6 @@ class JobTest < Test::Unit::TestCase
|
|
32
24
|
|
33
25
|
|
34
26
|
context "A Job with quotes" do
|
35
|
-
|
36
27
|
should "output the :task if it's in single quotes" do
|
37
28
|
job = new_job(:template => "':task'", :task => 'abc123')
|
38
29
|
assert_equal %q('abc123'), job.output
|
@@ -59,6 +50,23 @@ class JobTest < Test::Unit::TestCase
|
|
59
50
|
assert_equal %q(before "quote -> \" <- quote" after), job.output
|
60
51
|
end
|
61
52
|
end
|
53
|
+
|
54
|
+
context "A Job with a job_template" do
|
55
|
+
should "use the job template" do
|
56
|
+
job = new_job(:template => ':task', :task => 'abc123', :job_template => 'left :job right')
|
57
|
+
assert_equal 'left abc123 right', job.output
|
58
|
+
end
|
59
|
+
|
60
|
+
should "escape single quotes" do
|
61
|
+
job = new_job(:template => "before ':task' after", :task => "quote -> ' <- quote", :job_template => "left ':job' right")
|
62
|
+
assert_equal %q(left 'before '\''quote -> '\\''\\'\\'''\\'' <- quote'\'' after' right), job.output
|
63
|
+
end
|
64
|
+
|
65
|
+
should "escape double quotes" do
|
66
|
+
job = new_job(:template => 'before ":task" after', :task => 'quote -> " <- quote', :job_template => 'left ":job" right')
|
67
|
+
assert_equal %q(left "before \"quote -> \\\" <- quote\" after" right), job.output
|
68
|
+
end
|
69
|
+
end
|
62
70
|
|
63
71
|
private
|
64
72
|
|
data/whenever.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{whenever}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Javan Makhmali"]
|
12
|
-
s.date = %q{2010-
|
13
|
-
s.description = %q{
|
12
|
+
s.date = %q{2010-10-20}
|
13
|
+
s.description = %q{http://www.allyrics.net/Kid-Cudi/lyrics/Whenever/}
|
14
14
|
s.email = %q{javan@javan.us}
|
15
15
|
s.executables = ["whenever", "wheneverize"]
|
16
16
|
s.extra_rdoc_files = [
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"bin/wheneverize",
|
26
26
|
"lib/whenever.rb",
|
27
27
|
"lib/whenever/base.rb",
|
28
|
+
"lib/whenever/capistrano.rb",
|
28
29
|
"lib/whenever/command_line.rb",
|
29
30
|
"lib/whenever/cron.rb",
|
30
31
|
"lib/whenever/job.rb",
|
@@ -47,7 +48,7 @@ Gem::Specification.new do |s|
|
|
47
48
|
s.rdoc_options = ["--charset=UTF-8"]
|
48
49
|
s.require_paths = ["lib"]
|
49
50
|
s.rubygems_version = %q{1.3.7}
|
50
|
-
s.summary = %q{Clean ruby syntax for
|
51
|
+
s.summary = %q{Clean ruby syntax for writing and deploying cron jobs.}
|
51
52
|
s.test_files = [
|
52
53
|
"test/functional/command_line_test.rb",
|
53
54
|
"test/functional/output_at_test.rb",
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whenever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 13
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
7
|
+
- 6
|
8
|
+
- 1
|
9
|
+
version: 0.6.1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Javan Makhmali
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-10-20 00:00:00 -04:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 1
|
30
28
|
segments:
|
31
29
|
- 0
|
32
30
|
- 3
|
@@ -42,7 +40,6 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 11
|
46
43
|
segments:
|
47
44
|
- 2
|
48
45
|
- 3
|
@@ -58,7 +55,6 @@ dependencies:
|
|
58
55
|
requirements:
|
59
56
|
- - ">="
|
60
57
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 9
|
62
58
|
segments:
|
63
59
|
- 2
|
64
60
|
- 1
|
@@ -74,7 +70,6 @@ dependencies:
|
|
74
70
|
requirements:
|
75
71
|
- - ">="
|
76
72
|
- !ruby/object:Gem::Version
|
77
|
-
hash: 49
|
78
73
|
segments:
|
79
74
|
- 0
|
80
75
|
- 9
|
@@ -82,7 +77,7 @@ dependencies:
|
|
82
77
|
version: 0.9.5
|
83
78
|
type: :development
|
84
79
|
version_requirements: *id004
|
85
|
-
description:
|
80
|
+
description: http://www.allyrics.net/Kid-Cudi/lyrics/Whenever/
|
86
81
|
email: javan@javan.us
|
87
82
|
executables:
|
88
83
|
- whenever
|
@@ -100,6 +95,7 @@ files:
|
|
100
95
|
- bin/wheneverize
|
101
96
|
- lib/whenever.rb
|
102
97
|
- lib/whenever/base.rb
|
98
|
+
- lib/whenever/capistrano.rb
|
103
99
|
- lib/whenever/command_line.rb
|
104
100
|
- lib/whenever/cron.rb
|
105
101
|
- lib/whenever/job.rb
|
@@ -131,7 +127,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
127
|
requirements:
|
132
128
|
- - ">="
|
133
129
|
- !ruby/object:Gem::Version
|
134
|
-
hash: 3
|
135
130
|
segments:
|
136
131
|
- 0
|
137
132
|
version: "0"
|
@@ -140,7 +135,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
135
|
requirements:
|
141
136
|
- - ">="
|
142
137
|
- !ruby/object:Gem::Version
|
143
|
-
hash: 3
|
144
138
|
segments:
|
145
139
|
- 0
|
146
140
|
version: "0"
|
@@ -150,7 +144,7 @@ rubyforge_project:
|
|
150
144
|
rubygems_version: 1.3.7
|
151
145
|
signing_key:
|
152
146
|
specification_version: 3
|
153
|
-
summary: Clean ruby syntax for
|
147
|
+
summary: Clean ruby syntax for writing and deploying cron jobs.
|
154
148
|
test_files:
|
155
149
|
- test/functional/command_line_test.rb
|
156
150
|
- test/functional/output_at_test.rb
|