whenever 0.4.1 → 0.5.3
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 +38 -0
- data/README.rdoc +24 -12
- data/Rakefile +9 -6
- data/bin/whenever +8 -3
- data/lib/whenever/base.rb +1 -5
- data/lib/whenever/command_line.rb +28 -11
- data/lib/whenever/{outputs/cron.rb → cron.rb} +3 -5
- data/lib/whenever/job.rb +41 -0
- data/lib/whenever/job_list.rb +24 -24
- data/lib/whenever/job_types/default.rb +3 -27
- data/lib/whenever/{outputs/cron/output_redirection.rb → output_redirection.rb} +9 -3
- data/lib/whenever/version.rb +1 -1
- data/lib/whenever.rb +4 -25
- data/test/functional/command_line_test.rb +326 -0
- data/test/{output_at_test.rb → functional/output_at_test.rb} +63 -4
- data/test/{output_rake_test.rb → functional/output_default_defined_jobs_test.rb} +37 -21
- data/test/functional/output_defined_job_test.rb +105 -0
- data/test/{output_env_test.rb → functional/output_env_test.rb} +1 -1
- data/test/{output_redirection_test.rb → functional/output_redirection_test.rb} +11 -11
- data/test/test_helper.rb +5 -18
- data/test/{cron_test.rb → unit/cron_test.rb} +1 -1
- data/test/unit/job_test.rb +69 -0
- data/whenever.gemspec +36 -28
- metadata +95 -30
- data/lib/whenever/job_types/rake_task.rb +0 -12
- data/lib/whenever/job_types/runner.rb +0 -12
- data/test/command_line_test.rb +0 -101
- data/test/output_command_test.rb +0 -37
- data/test/output_runner_test.rb +0 -209
|
@@ -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
|
|
|
@@ -46,7 +46,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
should "output the command without the log syntax appended" do
|
|
49
|
-
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2
|
|
49
|
+
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
@@ -80,7 +80,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
|
80
80
|
|
|
81
81
|
should "output the command with the overridden redirection syntax appended" do
|
|
82
82
|
assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
|
|
83
|
-
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2
|
|
83
|
+
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
@@ -130,7 +130,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
should "output the command without the redirection syntax appended" do
|
|
133
|
-
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2
|
|
133
|
+
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
|
|
134
134
|
end
|
|
135
135
|
end
|
|
136
136
|
|
|
@@ -145,8 +145,8 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
|
145
145
|
file
|
|
146
146
|
end
|
|
147
147
|
|
|
148
|
-
should "output the command without the standard
|
|
149
|
-
assert_match /^.+ .+ .+ .+ blahblah 2
|
|
148
|
+
should "output the command without the standard error syntax appended" do
|
|
149
|
+
assert_match /^.+ .+ .+ .+ blahblah 2>> dev_null$/, @output
|
|
150
150
|
end
|
|
151
151
|
end
|
|
152
152
|
|
|
@@ -177,7 +177,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
should "output the command without the log syntax appended" do
|
|
180
|
-
assert_match /^.+ .+ .+ .+ blahblah 2
|
|
180
|
+
assert_match /^.+ .+ .+ .+ blahblah 2>> dev_err$/, @output
|
|
181
181
|
end
|
|
182
182
|
end
|
|
183
183
|
|
|
@@ -207,7 +207,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
|
207
207
|
end
|
|
208
208
|
|
|
209
209
|
should "output the command with stdout directed to /dev/null" do
|
|
210
|
-
assert_match /^.+ .+ .+ .+ blahblah
|
|
210
|
+
assert_match /^.+ .+ .+ .+ blahblah > \/dev\/null$/, @output
|
|
211
211
|
end
|
|
212
212
|
end
|
|
213
213
|
|
|
@@ -237,7 +237,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
|
237
237
|
end
|
|
238
238
|
|
|
239
239
|
should "output the command with stderr directed to /dev/null" do
|
|
240
|
-
assert_match /^.+ .+ .+ .+ blahblah
|
|
240
|
+
assert_match /^.+ .+ .+ .+ blahblah > \/dev\/null 2>&1$/, @output
|
|
241
241
|
end
|
|
242
242
|
end
|
|
243
243
|
|
|
@@ -267,7 +267,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
|
267
267
|
end
|
|
268
268
|
|
|
269
269
|
should "output the command with stderr directed to /dev/null" do
|
|
270
|
-
assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2
|
|
270
|
+
assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2>> my_error.log$/, @output
|
|
271
271
|
end
|
|
272
272
|
end
|
|
273
273
|
|
|
@@ -286,4 +286,4 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|
|
286
286
|
assert_match /^.+ .+ .+ .+ blahblah >> cron.log 2>&1$/, @output
|
|
287
287
|
end
|
|
288
288
|
end
|
|
289
|
-
end
|
|
289
|
+
end
|
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,69 @@
|
|
|
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 "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
|
+
should "substitute the :task when #output is called" do
|
|
19
|
+
job = new_job(:template => ":task", :task => 'abc123')
|
|
20
|
+
assert_equal 'abc123', job.output
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
should "substitute the :path when #output is called" do
|
|
24
|
+
assert_equal 'foo', new_job(:template => ':path', :path => 'foo').output
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
should "substitute the :path with the default Whenever.path if none is provided when #output is called" do
|
|
28
|
+
Whenever.expects(:path).returns('/my/path')
|
|
29
|
+
assert_equal '/my/path', new_job(:template => ':path').output
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
context "A Job with quotes" do
|
|
35
|
+
|
|
36
|
+
should "output the :task if it's in single quotes" do
|
|
37
|
+
job = new_job(:template => "':task'", :task => 'abc123')
|
|
38
|
+
assert_equal %q('abc123'), job.output
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
should "output the :task if it's in double quotes" do
|
|
42
|
+
job = new_job(:template => '":task"', :task => 'abc123')
|
|
43
|
+
assert_equal %q("abc123"), job.output
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
should "output escaped single quotes in when it's wrapped in them" do
|
|
47
|
+
job = new_job(
|
|
48
|
+
:template => "before ':foo' after",
|
|
49
|
+
:foo => "quote -> ' <- quote"
|
|
50
|
+
)
|
|
51
|
+
assert_equal %q(before 'quote -> '\'' <- quote' after), job.output
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
should "output escaped double quotes when it's wrapped in them" do
|
|
55
|
+
job = new_job(
|
|
56
|
+
:template => 'before ":foo" after',
|
|
57
|
+
:foo => 'quote -> " <- quote'
|
|
58
|
+
)
|
|
59
|
+
assert_equal %q(before "quote -> \" <- quote" after), job.output
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
def new_job(options={})
|
|
66
|
+
Whenever::Job.new(options)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
data/whenever.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{whenever}
|
|
8
|
-
s.version = "0.
|
|
8
|
+
s.version = "0.5.3"
|
|
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{
|
|
12
|
+
s.date = %q{2010-09-24}
|
|
13
13
|
s.description = %q{Clean ruby syntax for defining and deploying messy cron jobs.}
|
|
14
14
|
s.email = %q{javan@javan.us}
|
|
15
15
|
s.executables = ["whenever", "wheneverize"]
|
|
@@ -26,52 +26,60 @@ Gem::Specification.new do |s|
|
|
|
26
26
|
"lib/whenever.rb",
|
|
27
27
|
"lib/whenever/base.rb",
|
|
28
28
|
"lib/whenever/command_line.rb",
|
|
29
|
+
"lib/whenever/cron.rb",
|
|
30
|
+
"lib/whenever/job.rb",
|
|
29
31
|
"lib/whenever/job_list.rb",
|
|
30
32
|
"lib/whenever/job_types/default.rb",
|
|
31
|
-
"lib/whenever/
|
|
32
|
-
"lib/whenever/job_types/runner.rb",
|
|
33
|
-
"lib/whenever/outputs/cron.rb",
|
|
34
|
-
"lib/whenever/outputs/cron/output_redirection.rb",
|
|
33
|
+
"lib/whenever/output_redirection.rb",
|
|
35
34
|
"lib/whenever/version.rb",
|
|
36
|
-
"test/command_line_test.rb",
|
|
37
|
-
"test/
|
|
38
|
-
"test/
|
|
39
|
-
"test/
|
|
40
|
-
"test/output_env_test.rb",
|
|
41
|
-
"test/
|
|
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.
|
|
49
|
+
s.rubygems_version = %q{1.3.7}
|
|
51
50
|
s.summary = %q{Clean ruby syntax for defining and deploying messy cron jobs.}
|
|
52
51
|
s.test_files = [
|
|
53
|
-
"test/command_line_test.rb",
|
|
54
|
-
"test/
|
|
55
|
-
"test/
|
|
56
|
-
"test/
|
|
57
|
-
"test/output_env_test.rb",
|
|
58
|
-
"test/
|
|
59
|
-
"test/
|
|
60
|
-
"test/
|
|
61
|
-
"test/
|
|
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"
|
|
62
61
|
]
|
|
63
62
|
|
|
64
63
|
if s.respond_to? :specification_version then
|
|
65
64
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
66
65
|
s.specification_version = 3
|
|
67
66
|
|
|
68
|
-
if Gem::Version.new(Gem::
|
|
69
|
-
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"])
|
|
70
72
|
else
|
|
71
|
-
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"])
|
|
72
77
|
end
|
|
73
78
|
else
|
|
74
|
-
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"])
|
|
75
83
|
end
|
|
76
84
|
end
|
|
77
85
|
|
metadata
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: whenever
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
4
|
+
hash: 13
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 5
|
|
9
|
+
- 3
|
|
10
|
+
version: 0.5.3
|
|
5
11
|
platform: ruby
|
|
6
12
|
authors:
|
|
7
13
|
- Javan Makhmali
|
|
@@ -9,19 +15,73 @@ autorequire:
|
|
|
9
15
|
bindir: bin
|
|
10
16
|
cert_chain: []
|
|
11
17
|
|
|
12
|
-
date:
|
|
18
|
+
date: 2010-09-24 00:00:00 -04:00
|
|
13
19
|
default_executable:
|
|
14
20
|
dependencies:
|
|
15
21
|
- !ruby/object:Gem::Dependency
|
|
16
|
-
name: chronic
|
|
22
|
+
name: aaronh-chronic
|
|
23
|
+
prerelease: false
|
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
hash: 1
|
|
30
|
+
segments:
|
|
31
|
+
- 0
|
|
32
|
+
- 3
|
|
33
|
+
- 9
|
|
34
|
+
version: 0.3.9
|
|
17
35
|
type: :runtime
|
|
18
|
-
|
|
19
|
-
|
|
36
|
+
version_requirements: *id001
|
|
37
|
+
- !ruby/object:Gem::Dependency
|
|
38
|
+
name: activesupport
|
|
39
|
+
prerelease: false
|
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
hash: 11
|
|
46
|
+
segments:
|
|
47
|
+
- 2
|
|
48
|
+
- 3
|
|
49
|
+
- 4
|
|
50
|
+
version: 2.3.4
|
|
51
|
+
type: :runtime
|
|
52
|
+
version_requirements: *id002
|
|
53
|
+
- !ruby/object:Gem::Dependency
|
|
54
|
+
name: shoulda
|
|
55
|
+
prerelease: false
|
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
hash: 9
|
|
62
|
+
segments:
|
|
63
|
+
- 2
|
|
64
|
+
- 1
|
|
65
|
+
- 1
|
|
66
|
+
version: 2.1.1
|
|
67
|
+
type: :development
|
|
68
|
+
version_requirements: *id003
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: mocha
|
|
71
|
+
prerelease: false
|
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
20
74
|
requirements:
|
|
21
75
|
- - ">="
|
|
22
76
|
- !ruby/object:Gem::Version
|
|
23
|
-
|
|
24
|
-
|
|
77
|
+
hash: 49
|
|
78
|
+
segments:
|
|
79
|
+
- 0
|
|
80
|
+
- 9
|
|
81
|
+
- 5
|
|
82
|
+
version: 0.9.5
|
|
83
|
+
type: :development
|
|
84
|
+
version_requirements: *id004
|
|
25
85
|
description: Clean ruby syntax for defining and deploying messy cron jobs.
|
|
26
86
|
email: javan@javan.us
|
|
27
87
|
executables:
|
|
@@ -41,22 +101,21 @@ files:
|
|
|
41
101
|
- lib/whenever.rb
|
|
42
102
|
- lib/whenever/base.rb
|
|
43
103
|
- lib/whenever/command_line.rb
|
|
104
|
+
- lib/whenever/cron.rb
|
|
105
|
+
- lib/whenever/job.rb
|
|
44
106
|
- lib/whenever/job_list.rb
|
|
45
107
|
- lib/whenever/job_types/default.rb
|
|
46
|
-
- lib/whenever/
|
|
47
|
-
- lib/whenever/job_types/runner.rb
|
|
48
|
-
- lib/whenever/outputs/cron.rb
|
|
49
|
-
- lib/whenever/outputs/cron/output_redirection.rb
|
|
108
|
+
- lib/whenever/output_redirection.rb
|
|
50
109
|
- lib/whenever/version.rb
|
|
51
|
-
- test/command_line_test.rb
|
|
52
|
-
- test/
|
|
53
|
-
- test/
|
|
54
|
-
- test/
|
|
55
|
-
- test/output_env_test.rb
|
|
56
|
-
- test/
|
|
57
|
-
- test/output_redirection_test.rb
|
|
58
|
-
- 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
|
|
59
116
|
- test/test_helper.rb
|
|
117
|
+
- test/unit/cron_test.rb
|
|
118
|
+
- test/unit/job_test.rb
|
|
60
119
|
- whenever.gemspec
|
|
61
120
|
has_rdoc: true
|
|
62
121
|
homepage: http://github.com/javan/whenever
|
|
@@ -68,31 +127,37 @@ rdoc_options:
|
|
|
68
127
|
require_paths:
|
|
69
128
|
- lib
|
|
70
129
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
|
+
none: false
|
|
71
131
|
requirements:
|
|
72
132
|
- - ">="
|
|
73
133
|
- !ruby/object:Gem::Version
|
|
134
|
+
hash: 3
|
|
135
|
+
segments:
|
|
136
|
+
- 0
|
|
74
137
|
version: "0"
|
|
75
|
-
version:
|
|
76
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
|
+
none: false
|
|
77
140
|
requirements:
|
|
78
141
|
- - ">="
|
|
79
142
|
- !ruby/object:Gem::Version
|
|
143
|
+
hash: 3
|
|
144
|
+
segments:
|
|
145
|
+
- 0
|
|
80
146
|
version: "0"
|
|
81
|
-
version:
|
|
82
147
|
requirements: []
|
|
83
148
|
|
|
84
149
|
rubyforge_project:
|
|
85
|
-
rubygems_version: 1.3.
|
|
150
|
+
rubygems_version: 1.3.7
|
|
86
151
|
signing_key:
|
|
87
152
|
specification_version: 3
|
|
88
153
|
summary: Clean ruby syntax for defining and deploying messy cron jobs.
|
|
89
154
|
test_files:
|
|
90
|
-
- test/command_line_test.rb
|
|
91
|
-
- test/
|
|
92
|
-
- test/
|
|
93
|
-
- test/
|
|
94
|
-
- test/output_env_test.rb
|
|
95
|
-
- test/
|
|
96
|
-
- test/output_redirection_test.rb
|
|
97
|
-
- test/output_runner_test.rb
|
|
155
|
+
- test/functional/command_line_test.rb
|
|
156
|
+
- test/functional/output_at_test.rb
|
|
157
|
+
- test/functional/output_default_defined_jobs_test.rb
|
|
158
|
+
- test/functional/output_defined_job_test.rb
|
|
159
|
+
- test/functional/output_env_test.rb
|
|
160
|
+
- test/functional/output_redirection_test.rb
|
|
98
161
|
- test/test_helper.rb
|
|
162
|
+
- test/unit/cron_test.rb
|
|
163
|
+
- test/unit/job_test.rb
|
data/test/command_line_test.rb
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
|
2
|
-
|
|
3
|
-
class CommandLineTest < Test::Unit::TestCase
|
|
4
|
-
|
|
5
|
-
context "A command line write" do
|
|
6
|
-
setup do
|
|
7
|
-
File.expects(:exists?).with('config/schedule.rb').returns(true)
|
|
8
|
-
@command = Whenever::CommandLine.new(:write => true, :identifier => 'My identifier')
|
|
9
|
-
@task = "#{two_hours} /my/command"
|
|
10
|
-
Whenever.expects(:cron).returns(@task)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
should "output the cron job with identifier blocks" do
|
|
14
|
-
output = <<-EXPECTED
|
|
15
|
-
# Begin Whenever generated tasks for: My identifier
|
|
16
|
-
#{@task}
|
|
17
|
-
# End Whenever generated tasks for: My identifier
|
|
18
|
-
EXPECTED
|
|
19
|
-
|
|
20
|
-
assert_equal output, @command.send(:whenever_cron)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
should "write the crontab when run" do
|
|
24
|
-
@command.expects(:write_crontab).returns(true)
|
|
25
|
-
assert @command.run
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
context "A command line update" do
|
|
30
|
-
setup do
|
|
31
|
-
File.expects(:exists?).with('config/schedule.rb').returns(true)
|
|
32
|
-
@command = Whenever::CommandLine.new(:update => true, :identifier => 'My identifier')
|
|
33
|
-
@task = "#{two_hours} /my/command"
|
|
34
|
-
Whenever.expects(:cron).returns(@task)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
should "add the cron to the end of the file if there is no existing identifier block" do
|
|
38
|
-
existing = '# Existing crontab'
|
|
39
|
-
@command.expects(:read_crontab).at_least_once.returns(existing)
|
|
40
|
-
|
|
41
|
-
new_cron = <<-EXPECTED
|
|
42
|
-
#{existing}
|
|
43
|
-
|
|
44
|
-
# Begin Whenever generated tasks for: My identifier
|
|
45
|
-
#{@task}
|
|
46
|
-
# End Whenever generated tasks for: My identifier
|
|
47
|
-
EXPECTED
|
|
48
|
-
|
|
49
|
-
assert_equal new_cron, @command.send(:updated_crontab)
|
|
50
|
-
|
|
51
|
-
@command.expects(:write_crontab).with(new_cron).returns(true)
|
|
52
|
-
assert @command.run
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
should "replace an existing block if the identifier matches" do
|
|
56
|
-
existing = <<-EXISTING_CRON
|
|
57
|
-
# Something
|
|
58
|
-
|
|
59
|
-
# Begin Whenever generated tasks for: My identifier
|
|
60
|
-
My whenever job that was already here
|
|
61
|
-
# End Whenever generated tasks for: My identifier
|
|
62
|
-
|
|
63
|
-
# Begin Whenever generated tasks for: Other identifier
|
|
64
|
-
This shouldn't get replaced
|
|
65
|
-
# End Whenever generated tasks for: Other identifier
|
|
66
|
-
EXISTING_CRON
|
|
67
|
-
|
|
68
|
-
@command.expects(:read_crontab).at_least_once.returns(existing)
|
|
69
|
-
|
|
70
|
-
new_cron = <<-NEW_CRON
|
|
71
|
-
# Something
|
|
72
|
-
|
|
73
|
-
# Begin Whenever generated tasks for: My identifier
|
|
74
|
-
#{@task}
|
|
75
|
-
# End Whenever generated tasks for: My identifier
|
|
76
|
-
|
|
77
|
-
# Begin Whenever generated tasks for: Other identifier
|
|
78
|
-
This shouldn't get replaced
|
|
79
|
-
# End Whenever generated tasks for: Other identifier
|
|
80
|
-
NEW_CRON
|
|
81
|
-
|
|
82
|
-
assert_equal new_cron, @command.send(:updated_crontab)
|
|
83
|
-
|
|
84
|
-
@command.expects(:write_crontab).with(new_cron).returns(true)
|
|
85
|
-
assert @command.run
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
context "A command line update with no identifier" do
|
|
90
|
-
setup do
|
|
91
|
-
File.expects(:exists?).with('config/schedule.rb').returns(true)
|
|
92
|
-
Whenever::CommandLine.any_instance.expects(:default_identifier).returns('DEFAULT')
|
|
93
|
-
@command = Whenever::CommandLine.new(:update => true, :file => @file)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
should "use the default identifier" do
|
|
97
|
-
assert_equal "Whenever generated tasks for: DEFAULT", @command.send(:comment_base)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
end
|
data/test/output_command_test.rb
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
|
2
|
-
|
|
3
|
-
class OutputCommandTest < Test::Unit::TestCase
|
|
4
|
-
|
|
5
|
-
context "A plain command" do
|
|
6
|
-
setup do
|
|
7
|
-
@output = Whenever.cron \
|
|
8
|
-
<<-file
|
|
9
|
-
every 2.hours do
|
|
10
|
-
command "blahblah"
|
|
11
|
-
end
|
|
12
|
-
file
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
should "output the command" do
|
|
16
|
-
assert_match /^.+ .+ .+ .+ blahblah$/, @output
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context "An every statement with two commands in it" do
|
|
21
|
-
setup do
|
|
22
|
-
@output = Whenever.cron \
|
|
23
|
-
<<-file
|
|
24
|
-
every 1.hour do
|
|
25
|
-
command "first"
|
|
26
|
-
command "second"
|
|
27
|
-
end
|
|
28
|
-
file
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
should "output both commands" do
|
|
32
|
-
assert_match "0 * * * * first", @output
|
|
33
|
-
assert_match "0 * * * * second", @output
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|