le1t0-whenever 0.4.2.003 → 0.6.2.001
Sign up to get free protection for your applications and to get access to all the features.
- data/{CHANGELOG.rdoc → CHANGELOG.md} +55 -18
- data/README.md +139 -0
- data/Rakefile +9 -6
- data/bin/whenever +15 -5
- data/lib/whenever.rb +17 -27
- data/lib/whenever/capistrano.rb +31 -0
- data/lib/whenever/command_line.rb +25 -11
- data/lib/whenever/{outputs/cron.rb → cron.rb} +5 -12
- data/lib/whenever/job.rb +49 -0
- data/lib/whenever/job_list.rb +29 -42
- data/lib/whenever/output_redirection.rb +58 -0
- data/lib/whenever/setup.rb +18 -0
- data/lib/whenever/version.rb +1 -1
- data/test/functional/command_line_test.rb +310 -0
- data/test/{output_at_test.rb → functional/output_at_test.rb} +79 -6
- data/test/functional/output_default_defined_jobs_test.rb +164 -0
- data/test/functional/output_defined_job_test.rb +111 -0
- 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
- metadata +90 -37
- data/.gitignore +0 -4
- data/README.rdoc +0 -105
- data/lib/whenever/base.rb +0 -15
- data/lib/whenever/job_types/default.rb +0 -45
- data/lib/whenever/job_types/rake_task.rb +0 -12
- data/lib/whenever/job_types/runner.rb +0 -12
- data/lib/whenever/outputs/cron/output_redirection.rb +0 -60
- data/test/command_line_test.rb +0 -101
- 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 -209
@@ -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
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: le1t0-whenever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 117
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
+
- 6
|
8
9
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.
|
10
|
+
- 1
|
11
|
+
version: 0.6.2.001
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Le1t0
|
@@ -15,95 +16,147 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2010-
|
19
|
+
date: 2010-11-22 00:00:00 +01:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
22
|
-
name: chronic
|
23
|
+
name: aaronh-chronic
|
23
24
|
prerelease: false
|
24
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
25
27
|
requirements:
|
26
28
|
- - ">="
|
27
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 1
|
28
31
|
segments:
|
29
32
|
- 0
|
30
|
-
- 2
|
31
33
|
- 3
|
32
|
-
|
34
|
+
- 9
|
35
|
+
version: 0.3.9
|
33
36
|
type: :runtime
|
34
37
|
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: activesupport
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 11
|
47
|
+
segments:
|
48
|
+
- 2
|
49
|
+
- 3
|
50
|
+
- 4
|
51
|
+
version: 2.3.4
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: shoulda
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 9
|
63
|
+
segments:
|
64
|
+
- 2
|
65
|
+
- 1
|
66
|
+
- 1
|
67
|
+
version: 2.1.1
|
68
|
+
type: :development
|
69
|
+
version_requirements: *id003
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: mocha
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 49
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
- 9
|
82
|
+
- 5
|
83
|
+
version: 0.9.5
|
84
|
+
type: :development
|
85
|
+
version_requirements: *id004
|
35
86
|
description: Clean ruby syntax for defining and deploying messy cron jobs.
|
36
87
|
email: dev@ewout.to
|
37
88
|
executables:
|
38
|
-
- whenever
|
39
89
|
- wheneverize
|
90
|
+
- whenever
|
40
91
|
extensions: []
|
41
92
|
|
42
93
|
extra_rdoc_files:
|
43
|
-
- README.
|
94
|
+
- README.md
|
44
95
|
files:
|
45
|
-
- .
|
46
|
-
-
|
47
|
-
- README.rdoc
|
96
|
+
- CHANGELOG.md
|
97
|
+
- README.md
|
48
98
|
- Rakefile
|
49
99
|
- bin/whenever
|
50
100
|
- bin/wheneverize
|
51
101
|
- lib/whenever.rb
|
52
|
-
- lib/whenever/
|
102
|
+
- lib/whenever/capistrano.rb
|
53
103
|
- lib/whenever/command_line.rb
|
104
|
+
- lib/whenever/cron.rb
|
105
|
+
- lib/whenever/job.rb
|
54
106
|
- lib/whenever/job_list.rb
|
55
|
-
- lib/whenever/
|
56
|
-
- lib/whenever/
|
57
|
-
- lib/whenever/job_types/runner.rb
|
58
|
-
- lib/whenever/outputs/cron.rb
|
59
|
-
- lib/whenever/outputs/cron/output_redirection.rb
|
107
|
+
- lib/whenever/output_redirection.rb
|
108
|
+
- lib/whenever/setup.rb
|
60
109
|
- lib/whenever/version.rb
|
61
|
-
- test/command_line_test.rb
|
62
|
-
- test/
|
63
|
-
- test/
|
64
|
-
- test/
|
65
|
-
- test/output_env_test.rb
|
66
|
-
- test/
|
67
|
-
- test/output_redirection_test.rb
|
68
|
-
- test/output_runner_test.rb
|
110
|
+
- test/functional/command_line_test.rb
|
111
|
+
- test/functional/output_at_test.rb
|
112
|
+
- test/functional/output_default_defined_jobs_test.rb
|
113
|
+
- test/functional/output_defined_job_test.rb
|
114
|
+
- test/functional/output_env_test.rb
|
115
|
+
- test/functional/output_redirection_test.rb
|
69
116
|
- test/test_helper.rb
|
117
|
+
- test/unit/cron_test.rb
|
118
|
+
- test/unit/job_test.rb
|
70
119
|
has_rdoc: true
|
71
120
|
homepage: http://github.com/le1t0/whenever
|
72
121
|
licenses: []
|
73
122
|
|
74
123
|
post_install_message:
|
75
|
-
rdoc_options:
|
76
|
-
|
124
|
+
rdoc_options: []
|
125
|
+
|
77
126
|
require_paths:
|
78
127
|
- lib
|
79
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
80
130
|
requirements:
|
81
131
|
- - ">="
|
82
132
|
- !ruby/object:Gem::Version
|
133
|
+
hash: 3
|
83
134
|
segments:
|
84
135
|
- 0
|
85
136
|
version: "0"
|
86
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
87
139
|
requirements:
|
88
140
|
- - ">="
|
89
141
|
- !ruby/object:Gem::Version
|
142
|
+
hash: 3
|
90
143
|
segments:
|
91
144
|
- 0
|
92
145
|
version: "0"
|
93
146
|
requirements: []
|
94
147
|
|
95
148
|
rubyforge_project:
|
96
|
-
rubygems_version: 1.3.
|
149
|
+
rubygems_version: 1.3.7
|
97
150
|
signing_key:
|
98
151
|
specification_version: 3
|
99
152
|
summary: Clean ruby syntax for defining and deploying messy cron jobs.
|
100
153
|
test_files:
|
101
|
-
- test/command_line_test.rb
|
102
|
-
- test/
|
103
|
-
- test/
|
104
|
-
- test/
|
105
|
-
- test/output_env_test.rb
|
106
|
-
- test/
|
107
|
-
- test/output_redirection_test.rb
|
108
|
-
- test/output_runner_test.rb
|
154
|
+
- test/functional/command_line_test.rb
|
155
|
+
- test/functional/output_at_test.rb
|
156
|
+
- test/functional/output_default_defined_jobs_test.rb
|
157
|
+
- test/functional/output_defined_job_test.rb
|
158
|
+
- test/functional/output_env_test.rb
|
159
|
+
- test/functional/output_redirection_test.rb
|
109
160
|
- test/test_helper.rb
|
161
|
+
- test/unit/cron_test.rb
|
162
|
+
- test/unit/job_test.rb
|