whenever 0.5.0 → 0.6.2
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 +2 -1
- data/{CHANGELOG.rdoc → CHANGELOG.md} +51 -15
- data/README.md +139 -0
- data/Rakefile +11 -8
- data/bin/whenever +11 -5
- data/lib/whenever/capistrano.rb +31 -0
- data/lib/whenever/command_line.rb +22 -8
- data/lib/whenever/{outputs/cron.rb → cron.rb} +4 -11
- data/lib/whenever/job.rb +32 -7
- data/lib/whenever/job_list.rb +11 -24
- data/lib/whenever/output_redirection.rb +58 -0
- data/lib/whenever/setup.rb +18 -0
- data/lib/whenever/version.rb +1 -1
- data/lib/whenever.rb +16 -15
- data/test/functional/command_line_test.rb +310 -0
- data/test/{output_at_test.rb → functional/output_at_test.rb} +20 -6
- data/test/functional/output_default_defined_jobs_test.rb +164 -0
- data/test/{output_defined_job_test.rb → functional/output_defined_job_test.rb} +25 -1
- data/test/functional/output_env_test.rb +23 -0
- data/test/{output_redirection_test.rb → functional/output_redirection_test.rb} +19 -1
- data/test/test_helper.rb +5 -18
- data/test/{cron_test.rb → unit/cron_test.rb} +1 -1
- data/test/unit/job_test.rb +77 -0
- data/whenever.gemspec +42 -35
- metadata +88 -35
- data/README.rdoc +0 -127
- data/lib/whenever/base.rb +0 -11
- data/lib/whenever/job_types/default.rb +0 -3
- data/lib/whenever/outputs/cron/output_redirection.rb +0 -60
- data/test/command_line_test.rb +0 -177
- data/test/output_command_test.rb +0 -37
- data/test/output_env_test.rb +0 -56
- data/test/output_rake_test.rb +0 -74
- data/test/output_runner_test.rb +0 -175
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
|
|
3
|
+
class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
# command
|
|
6
|
+
|
|
7
|
+
context "A plain command with the job template set to nil" do
|
|
8
|
+
setup do
|
|
9
|
+
@output = Whenever.cron \
|
|
10
|
+
<<-file
|
|
11
|
+
set :job_template, nil
|
|
12
|
+
every 2.hours do
|
|
13
|
+
command "blahblah"
|
|
14
|
+
end
|
|
15
|
+
file
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
should "output the command" do
|
|
19
|
+
assert_match /^.+ .+ .+ .+ blahblah$/, @output
|
|
20
|
+
end
|
|
21
|
+
end
|
|
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
|
+
|
|
55
|
+
context "A plain command that is conditional on default environent and path" do
|
|
56
|
+
setup do
|
|
57
|
+
Whenever.expects(:path).at_least_once.returns('/what/you/want')
|
|
58
|
+
@output = Whenever.cron \
|
|
59
|
+
<<-file
|
|
60
|
+
set :job_template, nil
|
|
61
|
+
if environment == 'production' && path == '/what/you/want'
|
|
62
|
+
every 2.hours do
|
|
63
|
+
command "blahblah"
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
file
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
should "output the command" do
|
|
70
|
+
assert_match /blahblah/, @output
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# runner
|
|
75
|
+
|
|
76
|
+
context "A runner with path set" do
|
|
77
|
+
setup do
|
|
78
|
+
@output = Whenever.cron \
|
|
79
|
+
<<-file
|
|
80
|
+
set :job_template, nil
|
|
81
|
+
set :path, '/my/path'
|
|
82
|
+
every 2.hours do
|
|
83
|
+
runner 'blahblah'
|
|
84
|
+
end
|
|
85
|
+
file
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
should "output the runner using that path" do
|
|
89
|
+
assert_match two_hours + %( cd /my/path && script/runner -e production 'blahblah'), @output
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context "A runner that overrides the path set" do
|
|
94
|
+
setup do
|
|
95
|
+
@output = Whenever.cron \
|
|
96
|
+
<<-file
|
|
97
|
+
set :job_template, nil
|
|
98
|
+
set :path, '/my/path'
|
|
99
|
+
every 2.hours do
|
|
100
|
+
runner "blahblah", :path => '/some/other/path'
|
|
101
|
+
end
|
|
102
|
+
file
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
should "output the runner using that path" do
|
|
106
|
+
assert_match two_hours + %( cd /some/other/path && script/runner -e production 'blahblah'), @output
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
context "A runner for a Rails 3 app" do
|
|
111
|
+
setup do
|
|
112
|
+
Whenever.expects(:path).at_least_once.returns('/my/path')
|
|
113
|
+
File.expects(:exists?).with('/my/path/script/rails').returns(true)
|
|
114
|
+
@output = Whenever.cron \
|
|
115
|
+
<<-file
|
|
116
|
+
set :job_template, nil
|
|
117
|
+
every 2.hours do
|
|
118
|
+
runner 'blahblah'
|
|
119
|
+
end
|
|
120
|
+
file
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
should "use the Rails 3 runner job by default" do
|
|
124
|
+
assert_match two_hours + %( cd /my/path && script/rails runner -e production 'blahblah'), @output
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# rake
|
|
129
|
+
|
|
130
|
+
context "A rake command with path set" do
|
|
131
|
+
setup do
|
|
132
|
+
@output = Whenever.cron \
|
|
133
|
+
<<-file
|
|
134
|
+
set :job_template, nil
|
|
135
|
+
set :path, '/my/path'
|
|
136
|
+
every 2.hours do
|
|
137
|
+
rake "blahblah"
|
|
138
|
+
end
|
|
139
|
+
file
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
should "output the rake command using that path" do
|
|
143
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=production rake blahblah --silent', @output
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
context "A rake command that overrides the path set" do
|
|
148
|
+
setup do
|
|
149
|
+
@output = Whenever.cron \
|
|
150
|
+
<<-file
|
|
151
|
+
set :job_template, nil
|
|
152
|
+
set :path, '/my/path'
|
|
153
|
+
every 2.hours do
|
|
154
|
+
rake "blahblah", :path => '/some/other/path'
|
|
155
|
+
end
|
|
156
|
+
file
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
should "output the rake command using that path" do
|
|
160
|
+
assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production rake blahblah --silent', @output
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
2
|
|
|
3
3
|
class OutputDefinedJobTest < Test::Unit::TestCase
|
|
4
4
|
|
|
@@ -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'
|
|
@@ -84,4 +89,23 @@ class OutputDefinedJobTest < Test::Unit::TestCase
|
|
|
84
89
|
end
|
|
85
90
|
end
|
|
86
91
|
|
|
92
|
+
context "A defined job that uses a :path where none is explicitly set" do
|
|
93
|
+
setup do
|
|
94
|
+
Whenever.stubs(:path).returns('/my/path')
|
|
95
|
+
|
|
96
|
+
@output = Whenever.cron \
|
|
97
|
+
<<-file
|
|
98
|
+
set :job_template, nil
|
|
99
|
+
job_type :some_job, "cd :path && :task"
|
|
100
|
+
every 2.hours do
|
|
101
|
+
some_job 'blahblah'
|
|
102
|
+
end
|
|
103
|
+
file
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
should "default to using the Whenever.path" do
|
|
107
|
+
assert_match two_hours + %( cd /my/path && blahblah), @output
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
87
111
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
|
|
3
|
+
class OutputEnvTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
context "The output from Whenever with environment variables set" do
|
|
6
|
+
setup do
|
|
7
|
+
@output = Whenever.cron \
|
|
8
|
+
<<-file
|
|
9
|
+
env :MYVAR, 'blah'
|
|
10
|
+
env 'MAILTO', "someone@example.com"
|
|
11
|
+
file
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
should "output MYVAR environment variable" do
|
|
15
|
+
assert_match "MYVAR=blah", @output
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
should "output MAILTO environment variable" do
|
|
19
|
+
assert_match "MAILTO=someone@example.com", @output
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
2
|
|
|
3
3
|
class OutputRedirectionTest < Test::Unit::TestCase
|
|
4
4
|
|
|
@@ -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/test_helper.rb
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
|
-
require 'test/unit'
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
require 'shoulda'
|
|
8
|
-
rescue LoadError
|
|
9
|
-
warn 'To test Whenever you need the shoulda gem:'
|
|
10
|
-
warn '$ sudo gem install thoughtbot-shoulda'
|
|
11
|
-
exit(1)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
begin
|
|
15
|
-
require 'mocha'
|
|
16
|
-
rescue LoadError
|
|
17
|
-
warn 'To test Whenever you need the mocha gem:'
|
|
18
|
-
warn '$ sudo gem install mocha'
|
|
19
|
-
exit(1)
|
|
20
|
-
end
|
|
3
|
+
# Want to test the files here, in lib, not in an installed version of the gem.
|
|
4
|
+
$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
|
5
|
+
require 'whenever'
|
|
21
6
|
|
|
7
|
+
require 'shoulda'
|
|
8
|
+
require 'mocha'
|
|
22
9
|
|
|
23
10
|
module TestExtensions
|
|
24
11
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
|
|
3
|
+
class JobTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
context "A Job" do
|
|
6
|
+
should "return the :at set when #at is called" do
|
|
7
|
+
assert_equal 'foo', new_job(:at => 'foo').at
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
should "substitute the :task when #output is called" do
|
|
11
|
+
job = new_job(:template => ":task", :task => 'abc123')
|
|
12
|
+
assert_equal 'abc123', job.output
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
should "substitute the :path when #output is called" do
|
|
16
|
+
assert_equal 'foo', new_job(:template => ':path', :path => 'foo').output
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
should "substitute the :path with the default Whenever.path if none is provided when #output is called" do
|
|
20
|
+
Whenever.expects(:path).returns('/my/path')
|
|
21
|
+
assert_equal '/my/path', new_job(:template => ':path').output
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
context "A Job with quotes" do
|
|
27
|
+
should "output the :task if it's in single quotes" do
|
|
28
|
+
job = new_job(:template => "':task'", :task => 'abc123')
|
|
29
|
+
assert_equal %q('abc123'), job.output
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
should "output the :task if it's in double quotes" do
|
|
33
|
+
job = new_job(:template => '":task"', :task => 'abc123')
|
|
34
|
+
assert_equal %q("abc123"), job.output
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
should "output escaped single quotes in when it's wrapped in them" do
|
|
38
|
+
job = new_job(
|
|
39
|
+
:template => "before ':foo' after",
|
|
40
|
+
:foo => "quote -> ' <- quote"
|
|
41
|
+
)
|
|
42
|
+
assert_equal %q(before 'quote -> '\'' <- quote' after), job.output
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
should "output escaped double quotes when it's wrapped in them" do
|
|
46
|
+
job = new_job(
|
|
47
|
+
:template => 'before ":foo" after',
|
|
48
|
+
:foo => 'quote -> " <- quote'
|
|
49
|
+
)
|
|
50
|
+
assert_equal %q(before "quote -> \" <- quote" after), job.output
|
|
51
|
+
end
|
|
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
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
def new_job(options={})
|
|
74
|
+
Whenever::Job.new(options)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
data/whenever.gemspec
CHANGED
|
@@ -5,74 +5,81 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{whenever}
|
|
8
|
-
s.version = "0.
|
|
8
|
+
s.version = "0.6.2"
|
|
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{Clean ruby syntax for
|
|
12
|
+
s.date = %q{2010-10-26}
|
|
13
|
+
s.description = %q{Clean ruby syntax for writing and deploying cron jobs.}
|
|
14
14
|
s.email = %q{javan@javan.us}
|
|
15
15
|
s.executables = ["whenever", "wheneverize"]
|
|
16
16
|
s.extra_rdoc_files = [
|
|
17
|
-
"README.
|
|
17
|
+
"README.md"
|
|
18
18
|
]
|
|
19
19
|
s.files = [
|
|
20
20
|
".gitignore",
|
|
21
|
-
"CHANGELOG.
|
|
22
|
-
"README.
|
|
21
|
+
"CHANGELOG.md",
|
|
22
|
+
"README.md",
|
|
23
23
|
"Rakefile",
|
|
24
24
|
"bin/whenever",
|
|
25
25
|
"bin/wheneverize",
|
|
26
26
|
"lib/whenever.rb",
|
|
27
|
-
"lib/whenever/
|
|
27
|
+
"lib/whenever/capistrano.rb",
|
|
28
28
|
"lib/whenever/command_line.rb",
|
|
29
|
+
"lib/whenever/cron.rb",
|
|
29
30
|
"lib/whenever/job.rb",
|
|
30
31
|
"lib/whenever/job_list.rb",
|
|
31
|
-
"lib/whenever/
|
|
32
|
-
"lib/whenever/
|
|
33
|
-
"lib/whenever/outputs/cron/output_redirection.rb",
|
|
32
|
+
"lib/whenever/output_redirection.rb",
|
|
33
|
+
"lib/whenever/setup.rb",
|
|
34
34
|
"lib/whenever/version.rb",
|
|
35
|
-
"test/command_line_test.rb",
|
|
36
|
-
"test/
|
|
37
|
-
"test/
|
|
38
|
-
"test/
|
|
39
|
-
"test/
|
|
40
|
-
"test/
|
|
41
|
-
"test/output_rake_test.rb",
|
|
42
|
-
"test/output_redirection_test.rb",
|
|
43
|
-
"test/output_runner_test.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",
|
|
44
41
|
"test/test_helper.rb",
|
|
42
|
+
"test/unit/cron_test.rb",
|
|
43
|
+
"test/unit/job_test.rb",
|
|
45
44
|
"whenever.gemspec"
|
|
46
45
|
]
|
|
47
46
|
s.homepage = %q{http://github.com/javan/whenever}
|
|
48
47
|
s.rdoc_options = ["--charset=UTF-8"]
|
|
49
48
|
s.require_paths = ["lib"]
|
|
50
|
-
s.rubygems_version = %q{1.3.
|
|
51
|
-
s.summary = %q{
|
|
49
|
+
s.rubygems_version = %q{1.3.7}
|
|
50
|
+
s.summary = %q{Write your cron jobs in ruby.}
|
|
52
51
|
s.test_files = [
|
|
53
|
-
"test/command_line_test.rb",
|
|
54
|
-
"test/
|
|
55
|
-
"test/
|
|
56
|
-
"test/
|
|
57
|
-
"test/
|
|
58
|
-
"test/
|
|
59
|
-
"test/
|
|
60
|
-
"test/
|
|
61
|
-
"test/
|
|
62
|
-
"test/test_helper.rb"
|
|
52
|
+
"test/functional/command_line_test.rb",
|
|
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"
|
|
63
61
|
]
|
|
64
62
|
|
|
65
63
|
if s.respond_to? :specification_version then
|
|
66
64
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
67
65
|
s.specification_version = 3
|
|
68
66
|
|
|
69
|
-
if Gem::Version.new(Gem::
|
|
70
|
-
s.add_runtime_dependency(%q<chronic>, [">= 0.
|
|
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"])
|
|
71
72
|
else
|
|
72
|
-
s.add_dependency(%q<chronic>, [">= 0.
|
|
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"])
|
|
73
77
|
end
|
|
74
78
|
else
|
|
75
|
-
s.add_dependency(%q<chronic>, [">= 0.
|
|
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"])
|
|
76
83
|
end
|
|
77
84
|
end
|
|
78
85
|
|