whenever 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +0 -5
- data/README.md +3 -1
- data/lib/whenever.rb +10 -11
- data/lib/whenever/capistrano/v3/tasks/whenever.rake +2 -2
- data/lib/whenever/command_line.rb +9 -9
- data/lib/whenever/cron.rb +11 -11
- data/lib/whenever/job.rb +2 -2
- data/lib/whenever/job_list.rb +18 -7
- data/lib/whenever/numeric_seconds.rb +54 -0
- data/lib/whenever/tasks/whenever.rake +2 -2
- data/lib/whenever/version.rb +1 -1
- data/test/functional/command_line_test.rb +221 -224
- data/test/functional/output_at_test.rb +188 -249
- data/test/functional/output_default_defined_jobs_test.rb +214 -290
- data/test/functional/output_defined_job_test.rb +65 -91
- data/test/functional/output_env_test.rb +22 -26
- data/test/functional/output_jobs_for_roles_test.rb +46 -66
- data/test/functional/output_redirection_test.rb +231 -309
- data/test/test_case.rb +39 -0
- data/test/test_helper.rb +33 -14
- data/test/unit/capistrano_support_test.rb +126 -148
- data/test/unit/cron_test.rb +188 -215
- data/test/unit/job_test.rb +111 -121
- data/whenever.gemspec +0 -2
- metadata +15 -41
data/test/unit/job_test.rb
CHANGED
@@ -1,124 +1,114 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
class JobTest <
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
)
|
84
|
-
assert_equal %q(before 'quote -> '\'' <- quote' after), job.output
|
85
|
-
end
|
86
|
-
|
87
|
-
should "output escaped double quotes when it's wrapped in them" do
|
88
|
-
job = new_job(
|
89
|
-
:template => 'before ":foo" after',
|
90
|
-
:foo => 'quote -> " <- quote'
|
91
|
-
)
|
92
|
-
assert_equal %q(before "quote -> \" <- quote" after), job.output
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context "A Job with a job_template" do
|
97
|
-
should "use the job template" do
|
98
|
-
job = new_job(:template => ':task', :task => 'abc123', :job_template => 'left :job right')
|
99
|
-
assert_equal 'left abc123 right', job.output
|
100
|
-
end
|
101
|
-
|
102
|
-
should "reuse parameter in the job template" do
|
103
|
-
job = new_job(:template => ':path :task', :path => 'path', :task => "abc123", :job_template => ':path left :job right')
|
104
|
-
assert_equal 'path left path abc123 right', job.output
|
105
|
-
end
|
106
|
-
|
107
|
-
should "escape single quotes" do
|
108
|
-
job = new_job(:template => "before ':task' after", :task => "quote -> ' <- quote", :job_template => "left ':job' right")
|
109
|
-
assert_equal %q(left 'before '\''quote -> '\\''\\'\\'''\\'' <- quote'\'' after' right), job.output
|
110
|
-
end
|
111
|
-
|
112
|
-
should "escape double quotes" do
|
113
|
-
job = new_job(:template => 'before ":task" after', :task => 'quote -> " <- quote', :job_template => 'left ":job" right')
|
114
|
-
assert_equal %q(left "before \"quote -> \\\" <- quote\" after" right), job.output
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
private
|
119
|
-
|
120
|
-
def new_job(options={})
|
121
|
-
Whenever::Job.new(options)
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class JobTest < Whenever::TestCase
|
4
|
+
should "return the :at set when #at is called" do
|
5
|
+
assert_equal 'foo', new_job(:at => 'foo').at
|
6
|
+
end
|
7
|
+
|
8
|
+
should "return the :roles set when #roles is called" do
|
9
|
+
assert_equal ['foo', 'bar'], new_job(:roles => ['foo', 'bar']).roles
|
10
|
+
end
|
11
|
+
|
12
|
+
should "return whether it has a role from #has_role?" do
|
13
|
+
assert new_job(:roles => 'foo').has_role?('foo')
|
14
|
+
assert_equal false, new_job(:roles => 'bar').has_role?('foo')
|
15
|
+
end
|
16
|
+
|
17
|
+
should "substitute the :task when #output is called" do
|
18
|
+
job = new_job(:template => ":task", :task => 'abc123')
|
19
|
+
assert_equal 'abc123', job.output
|
20
|
+
end
|
21
|
+
|
22
|
+
should "substitute the :path when #output is called" do
|
23
|
+
assert_equal 'foo', new_job(:template => ':path', :path => 'foo').output
|
24
|
+
end
|
25
|
+
|
26
|
+
should "substitute the :path with the default Whenever.path if none is provided when #output is called" do
|
27
|
+
Whenever.expects(:path).returns('/my/path')
|
28
|
+
assert_equal '/my/path', new_job(:template => ':path').output
|
29
|
+
end
|
30
|
+
|
31
|
+
should "not substitute parameters for which no value is set" do
|
32
|
+
assert_equal 'Hello :world', new_job(:template => ':matching :world', :matching => 'Hello').output
|
33
|
+
end
|
34
|
+
|
35
|
+
should "escape the :path" do
|
36
|
+
assert_equal '/my/spacey\ path', new_job(:template => ':path', :path => '/my/spacey path').output
|
37
|
+
end
|
38
|
+
|
39
|
+
should "escape percent signs" do
|
40
|
+
job = new_job(
|
41
|
+
:template => "before :foo after",
|
42
|
+
:foo => "percent -> % <- percent"
|
43
|
+
)
|
44
|
+
assert_equal %q(before percent -> \% <- percent after), job.output
|
45
|
+
end
|
46
|
+
|
47
|
+
should "assume percent signs are not already escaped" do
|
48
|
+
job = new_job(
|
49
|
+
:template => "before :foo after",
|
50
|
+
:foo => %q(percent preceded by a backslash -> \% <-)
|
51
|
+
)
|
52
|
+
assert_equal %q(before percent preceded by a backslash -> \\\% <- after), job.output
|
53
|
+
end
|
54
|
+
|
55
|
+
should "squish spaces and newlines" do
|
56
|
+
job = new_job(
|
57
|
+
:template => "before :foo after",
|
58
|
+
:foo => "newline -> \n <- newline space -> <- space"
|
59
|
+
)
|
60
|
+
|
61
|
+
assert_equal "before newline -> <- newline space -> <- space after", job.output
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
class JobWithQuotesTest < Whenever::TestCase
|
67
|
+
should "output the :task if it's in single quotes" do
|
68
|
+
job = new_job(:template => "':task'", :task => 'abc123')
|
69
|
+
assert_equal %q('abc123'), job.output
|
70
|
+
end
|
71
|
+
|
72
|
+
should "output the :task if it's in double quotes" do
|
73
|
+
job = new_job(:template => '":task"', :task => 'abc123')
|
74
|
+
assert_equal %q("abc123"), job.output
|
75
|
+
end
|
76
|
+
|
77
|
+
should "output escaped single quotes in when it's wrapped in them" do
|
78
|
+
job = new_job(
|
79
|
+
:template => "before ':foo' after",
|
80
|
+
:foo => "quote -> ' <- quote"
|
81
|
+
)
|
82
|
+
assert_equal %q(before 'quote -> '\'' <- quote' after), job.output
|
122
83
|
end
|
123
84
|
|
85
|
+
should "output escaped double quotes when it's wrapped in them" do
|
86
|
+
job = new_job(
|
87
|
+
:template => 'before ":foo" after',
|
88
|
+
:foo => 'quote -> " <- quote'
|
89
|
+
)
|
90
|
+
assert_equal %q(before "quote -> \" <- quote" after), job.output
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class JobWithJobTemplateTest < Whenever::TestCase
|
95
|
+
should "use the job template" do
|
96
|
+
job = new_job(:template => ':task', :task => 'abc123', :job_template => 'left :job right')
|
97
|
+
assert_equal 'left abc123 right', job.output
|
98
|
+
end
|
99
|
+
|
100
|
+
should "reuse parameter in the job template" do
|
101
|
+
job = new_job(:template => ':path :task', :path => 'path', :task => "abc123", :job_template => ':path left :job right')
|
102
|
+
assert_equal 'path left path abc123 right', job.output
|
103
|
+
end
|
104
|
+
|
105
|
+
should "escape single quotes" do
|
106
|
+
job = new_job(:template => "before ':task' after", :task => "quote -> ' <- quote", :job_template => "left ':job' right")
|
107
|
+
assert_equal %q(left 'before '\''quote -> '\\''\\'\\'''\\'' <- quote'\'' after' right), job.output
|
108
|
+
end
|
109
|
+
|
110
|
+
should "escape double quotes" do
|
111
|
+
job = new_job(:template => 'before ":task" after', :task => 'quote -> " <- quote', :job_template => 'left ":job" right')
|
112
|
+
assert_equal %q(left "before \"quote -> \\\" <- quote\" after" right), job.output
|
113
|
+
end
|
124
114
|
end
|
data/whenever.gemspec
CHANGED
@@ -18,9 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
20
|
s.add_dependency "chronic", ">= 0.6.3"
|
21
|
-
s.add_dependency "activesupport", ">= 2.3.4"
|
22
21
|
|
23
|
-
s.add_development_dependency "shoulda", ">= 2.1.1"
|
24
22
|
s.add_development_dependency "mocha", ">= 0.9.5"
|
25
23
|
s.add_development_dependency "rake"
|
26
24
|
end
|
metadata
CHANGED
@@ -1,83 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whenever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javan Makhmali
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.6.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.6.3
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activesupport
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 2.3.4
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 2.3.4
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: shoulda
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 2.1.1
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 2.1.1
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: mocha
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
58
30
|
requirements:
|
59
|
-
- -
|
31
|
+
- - ">="
|
60
32
|
- !ruby/object:Gem::Version
|
61
33
|
version: 0.9.5
|
62
34
|
type: :development
|
63
35
|
prerelease: false
|
64
36
|
version_requirements: !ruby/object:Gem::Requirement
|
65
37
|
requirements:
|
66
|
-
- -
|
38
|
+
- - ">="
|
67
39
|
- !ruby/object:Gem::Version
|
68
40
|
version: 0.9.5
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: rake
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
72
44
|
requirements:
|
73
|
-
- -
|
45
|
+
- - ">="
|
74
46
|
- !ruby/object:Gem::Version
|
75
47
|
version: '0'
|
76
48
|
type: :development
|
77
49
|
prerelease: false
|
78
50
|
version_requirements: !ruby/object:Gem::Requirement
|
79
51
|
requirements:
|
80
|
-
- -
|
52
|
+
- - ">="
|
81
53
|
- !ruby/object:Gem::Version
|
82
54
|
version: '0'
|
83
55
|
description: Clean ruby syntax for writing and deploying cron jobs.
|
@@ -89,8 +61,8 @@ executables:
|
|
89
61
|
extensions: []
|
90
62
|
extra_rdoc_files: []
|
91
63
|
files:
|
92
|
-
- .gitignore
|
93
|
-
- .travis.yml
|
64
|
+
- ".gitignore"
|
65
|
+
- ".travis.yml"
|
94
66
|
- CHANGELOG.md
|
95
67
|
- Gemfile
|
96
68
|
- LICENSE
|
@@ -108,6 +80,7 @@ files:
|
|
108
80
|
- lib/whenever/cron.rb
|
109
81
|
- lib/whenever/job.rb
|
110
82
|
- lib/whenever/job_list.rb
|
83
|
+
- lib/whenever/numeric_seconds.rb
|
111
84
|
- lib/whenever/output_redirection.rb
|
112
85
|
- lib/whenever/setup.rb
|
113
86
|
- lib/whenever/tasks/whenever.rake
|
@@ -119,6 +92,7 @@ files:
|
|
119
92
|
- test/functional/output_env_test.rb
|
120
93
|
- test/functional/output_jobs_for_roles_test.rb
|
121
94
|
- test/functional/output_redirection_test.rb
|
95
|
+
- test/test_case.rb
|
122
96
|
- test/test_helper.rb
|
123
97
|
- test/unit/capistrano_support_test.rb
|
124
98
|
- test/unit/cron_test.rb
|
@@ -134,17 +108,17 @@ require_paths:
|
|
134
108
|
- lib
|
135
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
136
110
|
requirements:
|
137
|
-
- -
|
111
|
+
- - ">="
|
138
112
|
- !ruby/object:Gem::Version
|
139
113
|
version: '0'
|
140
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
115
|
requirements:
|
142
|
-
- -
|
116
|
+
- - ">="
|
143
117
|
- !ruby/object:Gem::Version
|
144
118
|
version: '0'
|
145
119
|
requirements: []
|
146
120
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.2.2
|
148
122
|
signing_key:
|
149
123
|
specification_version: 4
|
150
124
|
summary: Cron jobs in ruby.
|