whenever 0.5.3 → 0.6.8
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/.gitignore +1 -0
- data/{CHANGELOG.rdoc → CHANGELOG.md} +67 -17
- data/Gemfile +4 -0
- data/README.md +150 -0
- data/Rakefile +6 -30
- data/bin/whenever +11 -8
- data/bin/wheneverize +0 -0
- data/lib/whenever/capistrano.rb +32 -0
- data/lib/whenever/command_line.rb +18 -8
- data/lib/whenever/cron.rb +30 -19
- data/lib/whenever/job.rb +14 -8
- data/lib/whenever/job_list.rb +12 -25
- data/lib/whenever/output_redirection.rb +48 -50
- data/lib/whenever/setup.rb +18 -0
- data/lib/whenever/version.rb +2 -2
- data/lib/whenever.rb +14 -2
- data/test/functional/command_line_test.rb +26 -30
- data/test/functional/output_at_test.rb +34 -3
- data/test/functional/output_default_defined_jobs_test.rb +77 -3
- data/test/functional/output_defined_job_test.rb +7 -1
- data/test/functional/output_env_test.rb +9 -32
- data/test/functional/output_redirection_test.rb +18 -0
- data/test/unit/cron_test.rb +21 -6
- data/test/unit/job_test.rb +17 -9
- data/whenever.gemspec +17 -80
- metadata +21 -20
- data/README.rdoc +0 -127
- data/lib/whenever/base.rb +0 -11
- data/lib/whenever/job_types/default.rb +0 -3
|
@@ -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'
|
|
@@ -8,6 +8,8 @@ class OutputEnvTest < Test::Unit::TestCase
|
|
|
8
8
|
<<-file
|
|
9
9
|
env :MYVAR, 'blah'
|
|
10
10
|
env 'MAILTO', "someone@example.com"
|
|
11
|
+
env :BLANKVAR, ''
|
|
12
|
+
env :NILVAR, nil
|
|
11
13
|
file
|
|
12
14
|
end
|
|
13
15
|
|
|
@@ -18,39 +20,14 @@ class OutputEnvTest < Test::Unit::TestCase
|
|
|
18
20
|
should "output MAILTO environment variable" do
|
|
19
21
|
assert_match "MAILTO=someone@example.com", @output
|
|
20
22
|
end
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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"
|
|
23
|
+
|
|
24
|
+
should "output BLANKVAR environment variable" do
|
|
25
|
+
assert_match "BLANKVAR=\"\"", @output
|
|
49
26
|
end
|
|
50
|
-
|
|
51
|
-
should "
|
|
52
|
-
|
|
27
|
+
|
|
28
|
+
should "output NILVAR environment variable" do
|
|
29
|
+
assert_match "NILVAR=\"\"", @output
|
|
53
30
|
end
|
|
54
31
|
end
|
|
55
32
|
|
|
56
|
-
end
|
|
33
|
+
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/cron_test.rb
CHANGED
|
@@ -174,20 +174,26 @@ class CronTest < Test::Unit::TestCase
|
|
|
174
174
|
context "When parsing time using the cron shortcuts" do
|
|
175
175
|
should "parse a :symbol into the correct shortcut" do
|
|
176
176
|
assert_equal '@reboot', parse_time(:reboot)
|
|
177
|
-
assert_equal '@annually', parse_time(:
|
|
177
|
+
assert_equal '@annually', parse_time(:annually)
|
|
178
178
|
assert_equal '@annually', parse_time(:yearly)
|
|
179
|
-
assert_equal '@daily', parse_time(:day)
|
|
180
179
|
assert_equal '@daily', parse_time(:daily)
|
|
181
180
|
assert_equal '@midnight', parse_time(:midnight)
|
|
182
|
-
assert_equal '@monthly', parse_time(:month)
|
|
183
181
|
assert_equal '@monthly', parse_time(:monthly)
|
|
184
|
-
assert_equal '@
|
|
182
|
+
assert_equal '@weekly', parse_time(:weekly)
|
|
185
183
|
assert_equal '@hourly', parse_time(:hourly)
|
|
186
184
|
end
|
|
187
185
|
|
|
186
|
+
should "convert time-based shortcuts to times" do
|
|
187
|
+
assert_equal '0 0 1 * *', parse_time(:month)
|
|
188
|
+
assert_equal '0 0 * * *', parse_time(:day)
|
|
189
|
+
assert_equal '0 * * * *', parse_time(:hour)
|
|
190
|
+
assert_equal '0 0 1 12 *', parse_time(:year)
|
|
191
|
+
assert_equal '0 0 1,8,15,22 * *', parse_time(:week)
|
|
192
|
+
end
|
|
193
|
+
|
|
188
194
|
should "raise an exception if a valid shortcut is given but also an :at" do
|
|
189
195
|
assert_raises ArgumentError do
|
|
190
|
-
parse_time(:
|
|
196
|
+
parse_time(:hourly, nil, "1:00 am")
|
|
191
197
|
end
|
|
192
198
|
|
|
193
199
|
assert_raises ArgumentError do
|
|
@@ -195,7 +201,16 @@ class CronTest < Test::Unit::TestCase
|
|
|
195
201
|
end
|
|
196
202
|
|
|
197
203
|
assert_raises ArgumentError do
|
|
198
|
-
parse_time(:
|
|
204
|
+
parse_time(:daily, nil, '4:20pm')
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
context "When given raw cron sytax" do
|
|
210
|
+
should "return the same cron sytax" do
|
|
211
|
+
crons = ['0 0 27-31 * *', '* * * * *', '2/3 1,9,22 11-26 1-6 *']
|
|
212
|
+
crons.each do |cron|
|
|
213
|
+
assert_equal cron, parse_time(cron)
|
|
199
214
|
end
|
|
200
215
|
end
|
|
201
216
|
end
|
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
|
@@ -1,85 +1,22 @@
|
|
|
1
|
-
# Generated by jeweler
|
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
|
4
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "whenever/version"
|
|
5
4
|
|
|
6
5
|
Gem::Specification.new do |s|
|
|
7
|
-
s.name
|
|
8
|
-
s.version
|
|
9
|
-
|
|
10
|
-
s.
|
|
11
|
-
s.
|
|
12
|
-
s.
|
|
13
|
-
s.
|
|
14
|
-
s.
|
|
15
|
-
s.
|
|
16
|
-
s.
|
|
17
|
-
|
|
18
|
-
]
|
|
19
|
-
s.files = [
|
|
20
|
-
".gitignore",
|
|
21
|
-
"CHANGELOG.rdoc",
|
|
22
|
-
"README.rdoc",
|
|
23
|
-
"Rakefile",
|
|
24
|
-
"bin/whenever",
|
|
25
|
-
"bin/wheneverize",
|
|
26
|
-
"lib/whenever.rb",
|
|
27
|
-
"lib/whenever/base.rb",
|
|
28
|
-
"lib/whenever/command_line.rb",
|
|
29
|
-
"lib/whenever/cron.rb",
|
|
30
|
-
"lib/whenever/job.rb",
|
|
31
|
-
"lib/whenever/job_list.rb",
|
|
32
|
-
"lib/whenever/job_types/default.rb",
|
|
33
|
-
"lib/whenever/output_redirection.rb",
|
|
34
|
-
"lib/whenever/version.rb",
|
|
35
|
-
"test/functional/command_line_test.rb",
|
|
36
|
-
"test/functional/output_at_test.rb",
|
|
37
|
-
"test/functional/output_default_defined_jobs_test.rb",
|
|
38
|
-
"test/functional/output_defined_job_test.rb",
|
|
39
|
-
"test/functional/output_env_test.rb",
|
|
40
|
-
"test/functional/output_redirection_test.rb",
|
|
41
|
-
"test/test_helper.rb",
|
|
42
|
-
"test/unit/cron_test.rb",
|
|
43
|
-
"test/unit/job_test.rb",
|
|
44
|
-
"whenever.gemspec"
|
|
45
|
-
]
|
|
46
|
-
s.homepage = %q{http://github.com/javan/whenever}
|
|
47
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
|
6
|
+
s.name = "whenever"
|
|
7
|
+
s.version = Whenever::VERSION
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.authors = ["Javan Makhmali"]
|
|
10
|
+
s.email = ["javan@javan.us"]
|
|
11
|
+
s.homepage = ""
|
|
12
|
+
s.summary = %q{Cron jobs in ruby.}
|
|
13
|
+
s.description = %q{Clean ruby syntax for writing and deploying cron jobs.}
|
|
14
|
+
s.files = `git ls-files`.split("\n")
|
|
15
|
+
s.test_files = `git ls-files -- test/{functional,unit}/*`.split("\n")
|
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
48
17
|
s.require_paths = ["lib"]
|
|
49
|
-
s.
|
|
50
|
-
s.
|
|
51
|
-
s.
|
|
52
|
-
|
|
53
|
-
"test/functional/output_at_test.rb",
|
|
54
|
-
"test/functional/output_default_defined_jobs_test.rb",
|
|
55
|
-
"test/functional/output_defined_job_test.rb",
|
|
56
|
-
"test/functional/output_env_test.rb",
|
|
57
|
-
"test/functional/output_redirection_test.rb",
|
|
58
|
-
"test/test_helper.rb",
|
|
59
|
-
"test/unit/cron_test.rb",
|
|
60
|
-
"test/unit/job_test.rb"
|
|
61
|
-
]
|
|
62
|
-
|
|
63
|
-
if s.respond_to? :specification_version then
|
|
64
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
65
|
-
s.specification_version = 3
|
|
66
|
-
|
|
67
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
68
|
-
s.add_runtime_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
|
|
69
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.4"])
|
|
70
|
-
s.add_development_dependency(%q<shoulda>, [">= 2.1.1"])
|
|
71
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.5"])
|
|
72
|
-
else
|
|
73
|
-
s.add_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
|
|
74
|
-
s.add_dependency(%q<activesupport>, [">= 2.3.4"])
|
|
75
|
-
s.add_dependency(%q<shoulda>, [">= 2.1.1"])
|
|
76
|
-
s.add_dependency(%q<mocha>, [">= 0.9.5"])
|
|
77
|
-
end
|
|
78
|
-
else
|
|
79
|
-
s.add_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
|
|
80
|
-
s.add_dependency(%q<activesupport>, [">= 2.3.4"])
|
|
81
|
-
s.add_dependency(%q<shoulda>, [">= 2.1.1"])
|
|
82
|
-
s.add_dependency(%q<mocha>, [">= 0.9.5"])
|
|
83
|
-
end
|
|
18
|
+
s.add_runtime_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
|
|
19
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.4"])
|
|
20
|
+
s.add_development_dependency(%q<shoulda>, [">= 2.1.1"])
|
|
21
|
+
s.add_development_dependency(%q<mocha>, [">= 0.9.5"])
|
|
84
22
|
end
|
|
85
|
-
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: whenever
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
5
|
-
prerelease:
|
|
4
|
+
hash: 23
|
|
5
|
+
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
version: 0.
|
|
8
|
+
- 6
|
|
9
|
+
- 8
|
|
10
|
+
version: 0.6.8
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Javan Makhmali
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date:
|
|
18
|
+
date: 2011-05-24 00:00:00 -04:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -82,30 +82,32 @@ dependencies:
|
|
|
82
82
|
version: 0.9.5
|
|
83
83
|
type: :development
|
|
84
84
|
version_requirements: *id004
|
|
85
|
-
description: Clean ruby syntax for
|
|
86
|
-
email:
|
|
85
|
+
description: Clean ruby syntax for writing and deploying cron jobs.
|
|
86
|
+
email:
|
|
87
|
+
- javan@javan.us
|
|
87
88
|
executables:
|
|
88
89
|
- whenever
|
|
89
90
|
- wheneverize
|
|
90
91
|
extensions: []
|
|
91
92
|
|
|
92
|
-
extra_rdoc_files:
|
|
93
|
-
|
|
93
|
+
extra_rdoc_files: []
|
|
94
|
+
|
|
94
95
|
files:
|
|
95
96
|
- .gitignore
|
|
96
|
-
- CHANGELOG.
|
|
97
|
-
-
|
|
97
|
+
- CHANGELOG.md
|
|
98
|
+
- Gemfile
|
|
99
|
+
- README.md
|
|
98
100
|
- Rakefile
|
|
99
101
|
- bin/whenever
|
|
100
102
|
- bin/wheneverize
|
|
101
103
|
- lib/whenever.rb
|
|
102
|
-
- lib/whenever/
|
|
104
|
+
- lib/whenever/capistrano.rb
|
|
103
105
|
- lib/whenever/command_line.rb
|
|
104
106
|
- lib/whenever/cron.rb
|
|
105
107
|
- lib/whenever/job.rb
|
|
106
108
|
- lib/whenever/job_list.rb
|
|
107
|
-
- lib/whenever/job_types/default.rb
|
|
108
109
|
- lib/whenever/output_redirection.rb
|
|
110
|
+
- lib/whenever/setup.rb
|
|
109
111
|
- lib/whenever/version.rb
|
|
110
112
|
- test/functional/command_line_test.rb
|
|
111
113
|
- test/functional/output_at_test.rb
|
|
@@ -118,12 +120,12 @@ files:
|
|
|
118
120
|
- test/unit/job_test.rb
|
|
119
121
|
- whenever.gemspec
|
|
120
122
|
has_rdoc: true
|
|
121
|
-
homepage:
|
|
123
|
+
homepage: ""
|
|
122
124
|
licenses: []
|
|
123
125
|
|
|
124
126
|
post_install_message:
|
|
125
|
-
rdoc_options:
|
|
126
|
-
|
|
127
|
+
rdoc_options: []
|
|
128
|
+
|
|
127
129
|
require_paths:
|
|
128
130
|
- lib
|
|
129
131
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
@@ -147,10 +149,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
147
149
|
requirements: []
|
|
148
150
|
|
|
149
151
|
rubyforge_project:
|
|
150
|
-
rubygems_version: 1.
|
|
152
|
+
rubygems_version: 1.4.2
|
|
151
153
|
signing_key:
|
|
152
154
|
specification_version: 3
|
|
153
|
-
summary:
|
|
155
|
+
summary: Cron jobs in ruby.
|
|
154
156
|
test_files:
|
|
155
157
|
- test/functional/command_line_test.rb
|
|
156
158
|
- test/functional/output_at_test.rb
|
|
@@ -158,6 +160,5 @@ test_files:
|
|
|
158
160
|
- test/functional/output_defined_job_test.rb
|
|
159
161
|
- test/functional/output_env_test.rb
|
|
160
162
|
- test/functional/output_redirection_test.rb
|
|
161
|
-
- test/test_helper.rb
|
|
162
163
|
- test/unit/cron_test.rb
|
|
163
164
|
- test/unit/job_test.rb
|
data/README.rdoc
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
== Introduction
|
|
2
|
-
|
|
3
|
-
Whenever is a Ruby gem that provides a clear syntax for defining cron jobs. It outputs valid cron syntax and can even write your crontab file for you. It is designed to work well with Rails applications and can be deployed with Capistrano. Whenever works fine independently as well.
|
|
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
|
|
8
|
-
|
|
9
|
-
== Installation
|
|
10
|
-
|
|
11
|
-
$ sudo gem install whenever
|
|
12
|
-
|
|
13
|
-
== Getting started
|
|
14
|
-
|
|
15
|
-
$ cd /my/rails/app
|
|
16
|
-
$ wheneverize .
|
|
17
|
-
|
|
18
|
-
This will create an initial "config/schedule.rb" file you.
|
|
19
|
-
|
|
20
|
-
== Example schedule.rb file
|
|
21
|
-
|
|
22
|
-
every 3.hours do
|
|
23
|
-
runner "MyModel.some_process"
|
|
24
|
-
rake "my:rake:task"
|
|
25
|
-
command "/usr/bin/my_great_command"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
every 1.day, :at => '4:30 am' do
|
|
29
|
-
runner "MyModel.task_to_run_at_four_thirty_in_the_morning"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
every :hour do # Many shortcuts available: :hour, :day, :month, :year, :reboot
|
|
33
|
-
runner "SomeModel.ladeeda"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
every :sunday, :at => '12pm' do # Use any day of the week or :weekend, :weekday
|
|
37
|
-
runner "Task.do_something_great"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
More examples on the wiki: http://wiki.github.com/javan/whenever/instructions-and-examples
|
|
41
|
-
|
|
42
|
-
== Define your own job types
|
|
43
|
-
|
|
44
|
-
Whenever ships with three pre-defined job types: command, runner, and rake. You can define your own with <code>job_type</code>.
|
|
45
|
-
|
|
46
|
-
For example:
|
|
47
|
-
|
|
48
|
-
job_type :awesome, '/usr/local/bin/awesome :task :fun_level'
|
|
49
|
-
|
|
50
|
-
every 2.hours do
|
|
51
|
-
awesome "party", :fun_level => "extreme"
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
Would run <code>/usr/local/bin/awesome party extreme</code> every two hours. <code>:task</code> is always replaced with the first argument, and any additional <code>:whatevers</code> are replaced with the options passed in or by variables that have been defined with <code>set</code>.
|
|
55
|
-
|
|
56
|
-
The default job types that ship with Whenever are defined like so:
|
|
57
|
-
|
|
58
|
-
job_type :command, ":task"
|
|
59
|
-
job_type :runner, "cd :path && script/runner -e :environment ':task'"
|
|
60
|
-
job_type :rake, "cd :path && RAILS_ENV=:environment /usr/bin/env rake :task"
|
|
61
|
-
|
|
62
|
-
If a <code>:path</code> is not set it will default to the directory in which <code>whenever</code> was executed. <code>:environment</code> will default to 'production'.
|
|
63
|
-
|
|
64
|
-
== Cron output
|
|
65
|
-
|
|
66
|
-
$ cd /my/rails/app
|
|
67
|
-
$ whenever
|
|
68
|
-
|
|
69
|
-
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
|
-
|
|
71
|
-
== Capistrano integration
|
|
72
|
-
|
|
73
|
-
In your "config/deploy.rb" file do something like:
|
|
74
|
-
|
|
75
|
-
after "deploy:symlink", "deploy:update_crontab"
|
|
76
|
-
|
|
77
|
-
namespace :deploy do
|
|
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
|
|
83
|
-
|
|
84
|
-
This will update your crontab file, leaving any existing entries unharmed. When using the <code>--update-crontab</code> option, Whenever will only update the entries in your crontab file related to the current schedule.rb file. You can replace the <code>#{application}</code> with any identifying string you'd like. You can have any number of apps deploy to the same crontab file peacefully given they each use a different identifier.
|
|
85
|
-
|
|
86
|
-
If you wish to simply overwrite your crontab file each time you deploy, use the <code>--write-crontab</code> option. This is ideal if you are only working with one app and every crontab entry is contained in a single schedule.rb file.
|
|
87
|
-
|
|
88
|
-
By mixing and matching the <code>--load-file</code> and <code>--user</code> options with your various :roles in Capistrano it is entirely possible to deploy different crontab schedules under different users to all your various servers. Get creative!
|
|
89
|
-
|
|
90
|
-
If you want to override a variable (like your environment) at the time of deployment you can do so with the <code>--set</code> option: http://wiki.github.com/javan/whenever/setting-variables-on-the-fly
|
|
91
|
-
|
|
92
|
-
== Credit
|
|
93
|
-
|
|
94
|
-
Whenever was created for use at Inkling (http://inklingmarkets.com) where I work. Their take on it: http://blog.inklingmarkets.com/2009/02/whenever-easy-way-to-do-cron-jobs-from.html
|
|
95
|
-
|
|
96
|
-
While building Whenever, I learned a lot by digging through the source code of Capistrano - http://github.com/jamis/capistrano
|
|
97
|
-
|
|
98
|
-
== Discussion / Feedback / Issues / Bugs
|
|
99
|
-
|
|
100
|
-
For general discussion and questions, please use the google group: http://groups.google.com/group/whenever-gem
|
|
101
|
-
|
|
102
|
-
If you've found a genuine bug or issue, please use the Issues section on github: http://github.com/javan/whenever/issues
|
|
103
|
-
|
|
104
|
-
== License
|
|
105
|
-
|
|
106
|
-
Copyright (c) 2009+ Javan Makhmali
|
|
107
|
-
|
|
108
|
-
Permission is hereby granted, free of charge, to any person
|
|
109
|
-
obtaining a copy of this software and associated documentation
|
|
110
|
-
files (the "Software"), to deal in the Software without
|
|
111
|
-
restriction, including without limitation the rights to use,
|
|
112
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
113
|
-
copies of the Software, and to permit persons to whom the
|
|
114
|
-
Software is furnished to do so, subject to the following
|
|
115
|
-
conditions:
|
|
116
|
-
|
|
117
|
-
The above copyright notice and this permission notice shall be
|
|
118
|
-
included in all copies or substantial portions of the Software.
|
|
119
|
-
|
|
120
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
121
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
122
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
123
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
124
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
125
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
126
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
127
|
-
OTHER DEALINGS IN THE SOFTWARE.
|