moneypools-whenever 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -0
- data/Rakefile +1 -1
- data/bin/whenever +1 -1
- data/lib/whenever/command_line.rb +2 -2
- data/lib/whenever/job_sequence.rb +14 -8
- data/lib/whenever/version.rb +1 -1
- data/lib/whenever.rb +4 -4
- data/test/in_sequence_test.rb +34 -11
- data/test/job_sequence_test.rb +0 -16
- data/test/output_at_test.rb +6 -8
- data/test/test_helper.rb +16 -13
- data/whenever.gemspec +10 -2
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.4.1 / November 30th, 2009
|
2
|
+
|
3
|
+
* exit(0) instead of just exit to make JRuby happy. [Elan Meng]
|
4
|
+
|
5
|
+
* Fixed activesupport deprecation warning by requiring active_support. #37 [Andrew Nesbitt]
|
6
|
+
|
7
|
+
|
1
8
|
== 0.4.0 / October 20th, 2009
|
2
9
|
|
3
10
|
* New output option replaces the old cron_log option for output redirection and is much more flexible. #31 [Peer Allan]
|
data/Rakefile
CHANGED
data/bin/whenever
CHANGED
@@ -10,7 +10,7 @@ options = Hash.new
|
|
10
10
|
|
11
11
|
OptionParser.new do |opts|
|
12
12
|
opts.banner = "Usage: whenever [options]"
|
13
|
-
opts.on('-v', '--version') { puts "Whenever v#{Whenever::VERSION}"; exit }
|
13
|
+
opts.on('-v', '--version') { puts "Whenever v#{Whenever::VERSION}"; exit(0) }
|
14
14
|
opts.on('-w', '--write-crontab') { options[:write] = true }
|
15
15
|
opts.on('-i', '--update-crontab [identifier]', 'Default: full path to schedule.rb file') do |identifier|
|
16
16
|
options[:update] = true
|
@@ -29,7 +29,7 @@ module Whenever
|
|
29
29
|
write_crontab(whenever_cron)
|
30
30
|
else
|
31
31
|
puts Whenever.cron(@options)
|
32
|
-
exit
|
32
|
+
exit(0)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -67,7 +67,7 @@ module Whenever
|
|
67
67
|
action = 'written' if @options[:write]
|
68
68
|
action = 'updated' if @options[:update]
|
69
69
|
puts "[write] crontab file #{action}"
|
70
|
-
exit
|
70
|
+
exit(0)
|
71
71
|
else
|
72
72
|
warn "[fail] Couldn't write crontab; try running `whenever' with no options to ensure your schedule file is valid."
|
73
73
|
exit(1)
|
@@ -1,24 +1,30 @@
|
|
1
1
|
module Whenever
|
2
2
|
class JobSequence < Array
|
3
|
-
attr_writer :dependent
|
3
|
+
attr_writer :dependent
|
4
4
|
|
5
5
|
def initialize(options={}, size=0, obj=nil)
|
6
6
|
super(size, obj)
|
7
7
|
|
8
8
|
@options = options
|
9
9
|
@dependent = options.fetch(:dependent, true)
|
10
|
-
@on_failure = options[:on_failure]
|
11
10
|
end
|
12
11
|
|
13
12
|
def to_single_job
|
13
|
+
options = @options.dup
|
14
|
+
default_redirection = options.delete(:output)
|
15
|
+
|
14
16
|
concatenation = @dependent ? " && " : "; "
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
tasks_with_redirection = map do |t|
|
18
|
+
if redirection = t.output_redirection.nil? || t.output_redirection == :not_set ? default_redirection : t.output_redirection
|
19
|
+
t.output + " " + Output::Cron::OutputRedirection.new(redirection).to_s
|
20
|
+
else
|
21
|
+
t.output
|
22
|
+
end
|
19
23
|
end
|
24
|
+
|
25
|
+
single_task = tasks_with_redirection.join(concatenation)
|
20
26
|
|
21
|
-
Job::Default.new(
|
27
|
+
Job::Default.new(options.merge(:task => single_task))
|
22
28
|
end
|
23
29
|
end
|
24
|
-
end
|
30
|
+
end
|
data/lib/whenever/version.rb
CHANGED
data/lib/whenever.rb
CHANGED
@@ -7,15 +7,15 @@ rescue LoadError
|
|
7
7
|
nil
|
8
8
|
end
|
9
9
|
|
10
|
-
# If Rails' rakefile was loaded than so was
|
10
|
+
# If Rails' rakefile was loaded than so was active_support, but
|
11
11
|
# if this is being used in a non-rails enviroment we need to require it.
|
12
12
|
# It was previously defined as a dependency of this gem, but that became
|
13
13
|
# problematic. See: http://github.com/javan/whenever/issues#issue/1
|
14
14
|
begin
|
15
|
-
require '
|
15
|
+
require 'active_support'
|
16
16
|
rescue LoadError
|
17
|
-
warn 'To user Whenever you need the
|
18
|
-
warn '$ sudo gem install
|
17
|
+
warn 'To user Whenever you need the active_support gem:'
|
18
|
+
warn '$ sudo gem install active_support'
|
19
19
|
exit(1)
|
20
20
|
end
|
21
21
|
|
data/test/in_sequence_test.rb
CHANGED
@@ -19,40 +19,63 @@ class InSequenceTest < Test::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
context "A pair of tasks in
|
22
|
+
context "A pair of tasks in a sequence with output redirection" do
|
23
23
|
setup do
|
24
24
|
@output = Whenever.cron \
|
25
25
|
<<-file
|
26
26
|
set :path, '/my/path'
|
27
|
-
every
|
27
|
+
every 1.day, :at => "20:15" do
|
28
28
|
in_sequence do
|
29
|
-
|
30
|
-
rake "second_task"
|
29
|
+
rake "first_task", :output => 'logfile1'
|
30
|
+
rake "second_task", :output => 'logfile2'
|
31
31
|
end
|
32
32
|
end
|
33
33
|
file
|
34
34
|
end
|
35
35
|
|
36
|
-
should "
|
37
|
-
assert_match '
|
36
|
+
should "produce a set of tasks using individual output options" do
|
37
|
+
assert_match 'rake first_task >> logfile1', @output
|
38
|
+
assert_match 'rake second_task >> logfile2', @output
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "A pair of tasks in a sequence with two levels of output redirection" do
|
43
|
+
setup do
|
44
|
+
@output = Whenever.cron \
|
45
|
+
<<-file
|
46
|
+
set :path, '/my/path'
|
47
|
+
every 1.day, :at => "20:15" do
|
48
|
+
in_sequence :output => 'fallthrough' do
|
49
|
+
rake "first_task"
|
50
|
+
rake "second_task", :output => 'logfile2'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
file
|
54
|
+
end
|
55
|
+
|
56
|
+
should "use the sequence level redirection as a default" do
|
57
|
+
assert_match 'rake first_task >> fallthrough', @output
|
58
|
+
assert_match 'rake second_task >> logfile2', @output
|
38
59
|
end
|
39
60
|
end
|
61
|
+
|
40
62
|
|
41
|
-
context "A pair of
|
63
|
+
context "A pair of tasks in the same time block that should be executed in a dependent sequence" do
|
42
64
|
setup do
|
43
65
|
@output = Whenever.cron \
|
44
66
|
<<-file
|
45
67
|
set :path, '/my/path'
|
46
|
-
every
|
68
|
+
every 2.hours do
|
47
69
|
in_sequence do
|
48
|
-
|
70
|
+
cap "first_task"
|
71
|
+
rake "second_task"
|
49
72
|
end
|
50
73
|
end
|
51
74
|
file
|
52
75
|
end
|
53
76
|
|
54
|
-
should "
|
55
|
-
assert_match '
|
77
|
+
should "output the pair of tasks using &&" do
|
78
|
+
assert_match 'cd /my/path && RAILS_ENV=production /usr/bin/env cap first_task && cd /my/path && RAILS_ENV=production /usr/bin/env rake second_task', @output
|
56
79
|
end
|
57
80
|
end
|
58
81
|
|
data/test/job_sequence_test.rb
CHANGED
@@ -20,14 +20,6 @@ class JobSequenceTest < Test::Unit::TestCase
|
|
20
20
|
|
21
21
|
assert_equal sequence.to_single_job.output, "first_task && second_task"
|
22
22
|
end
|
23
|
-
|
24
|
-
should "wrap sequence and fire failure command conditionally" do
|
25
|
-
sequence = Whenever::JobSequence.new(:on_failure => "failure_command")
|
26
|
-
sequence << Whenever::Job::Default.new(:task => "first_task", :path => @path)
|
27
|
-
sequence << Whenever::Job::Default.new(:task => "second_task", :path => @path)
|
28
|
-
|
29
|
-
assert_equal sequence.to_single_job.output, "(first_task && second_task) || failure_command"
|
30
|
-
end
|
31
23
|
end
|
32
24
|
|
33
25
|
context "with independent sequences" do
|
@@ -38,14 +30,6 @@ class JobSequenceTest < Test::Unit::TestCase
|
|
38
30
|
|
39
31
|
assert_equal sequence.to_single_job.output, "first_task; second_task"
|
40
32
|
end
|
41
|
-
|
42
|
-
should "not wrap sequence since it is not meaningful" do
|
43
|
-
sequence = Whenever::JobSequence.new(:dependent => false, :on_failure => "failure_command")
|
44
|
-
sequence << Whenever::Job::Default.new(:task => "first_task", :path => @path)
|
45
|
-
sequence << Whenever::Job::Default.new(:task => "second_task", :path => @path)
|
46
|
-
|
47
|
-
assert_equal sequence.to_single_job.output, "first_task; second_task"
|
48
|
-
end
|
49
33
|
end
|
50
34
|
end
|
51
35
|
end
|
data/test/output_at_test.rb
CHANGED
@@ -113,14 +113,12 @@ class OutputAtTest < Test::Unit::TestCase
|
|
113
113
|
|
114
114
|
context "A command every 1.month at very diverse times" do
|
115
115
|
setup do
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
file
|
123
|
-
end
|
116
|
+
@output = Whenever.cron \
|
117
|
+
<<-file
|
118
|
+
every [1.month, 1.day], :at => 'january 5:02am, june 17th at 2:22pm, june 3rd at 3:33am' do
|
119
|
+
command "blahblah"
|
120
|
+
end
|
121
|
+
file
|
124
122
|
end
|
125
123
|
|
126
124
|
should "output 6 commands since none align" do
|
data/test/test_helper.rb
CHANGED
@@ -3,26 +3,29 @@ require 'test/unit'
|
|
3
3
|
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + "/../lib/whenever")
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
'
|
10
|
-
|
6
|
+
begin
|
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
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
exit(1)
|
19
|
-
end
|
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
20
|
end
|
21
21
|
|
22
|
+
|
22
23
|
module TestExtensions
|
24
|
+
|
23
25
|
def two_hours
|
24
26
|
"0 0,2,4,6,8,10,12,14,16,18,20,22 * * *"
|
25
27
|
end
|
28
|
+
|
26
29
|
end
|
27
30
|
|
28
31
|
class Test::Unit::TestCase
|
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.4.
|
8
|
+
s.version = "0.4.1"
|
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{2009-
|
12
|
+
s.date = %q{2009-12-02}
|
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"]
|
@@ -27,6 +27,8 @@ Gem::Specification.new do |s|
|
|
27
27
|
"lib/whenever/base.rb",
|
28
28
|
"lib/whenever/command_line.rb",
|
29
29
|
"lib/whenever/job_list.rb",
|
30
|
+
"lib/whenever/job_sequence.rb",
|
31
|
+
"lib/whenever/job_types/cap_task.rb",
|
30
32
|
"lib/whenever/job_types/default.rb",
|
31
33
|
"lib/whenever/job_types/rake_task.rb",
|
32
34
|
"lib/whenever/job_types/runner.rb",
|
@@ -35,7 +37,10 @@ Gem::Specification.new do |s|
|
|
35
37
|
"lib/whenever/version.rb",
|
36
38
|
"test/command_line_test.rb",
|
37
39
|
"test/cron_test.rb",
|
40
|
+
"test/in_sequence_test.rb",
|
41
|
+
"test/job_sequence_test.rb",
|
38
42
|
"test/output_at_test.rb",
|
43
|
+
"test/output_cap_test.rb",
|
39
44
|
"test/output_command_test.rb",
|
40
45
|
"test/output_env_test.rb",
|
41
46
|
"test/output_rake_test.rb",
|
@@ -52,7 +57,10 @@ Gem::Specification.new do |s|
|
|
52
57
|
s.test_files = [
|
53
58
|
"test/command_line_test.rb",
|
54
59
|
"test/cron_test.rb",
|
60
|
+
"test/in_sequence_test.rb",
|
61
|
+
"test/job_sequence_test.rb",
|
55
62
|
"test/output_at_test.rb",
|
63
|
+
"test/output_cap_test.rb",
|
56
64
|
"test/output_command_test.rb",
|
57
65
|
"test/output_env_test.rb",
|
58
66
|
"test/output_rake_test.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moneypools-whenever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javan Makhmali
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-02 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|