cwninja-whenever 0.1.5.3 → 0.1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/whenever +1 -0
- data/lib/job_list.rb +4 -2
- data/lib/job_types/default.rb +2 -1
- data/lib/version.rb +1 -1
- data/test/output_command_test.rb +54 -1
- data/whenever.gemspec +4 -4
- metadata +2 -3
data/bin/whenever
CHANGED
@@ -17,6 +17,7 @@ OptionParser.new do |opts|
|
|
17
17
|
opts.on('-p', '--update-crontab') { options[:update] = true }
|
18
18
|
opts.on('-m', '--marker [a specific string token]') { |token| options[:marker] = token }
|
19
19
|
opts.on('-l', '--cron_log [logfile for cron output]') { |token| options[:cron_log] = token }
|
20
|
+
opts.on('-E', '--no-error-redirection') { options[:no_stderr_redirect] = true }
|
20
21
|
opts.on('-f', '--load-file [schedule file]', 'default: config/schedule.rb') do |file|
|
21
22
|
options[:file] = file if file
|
22
23
|
end
|
data/lib/job_list.rb
CHANGED
@@ -9,7 +9,7 @@ module Whenever
|
|
9
9
|
when String then options
|
10
10
|
when Hash
|
11
11
|
@cron_log = options[:cron_log] if options.has_key? :cron_log
|
12
|
-
|
12
|
+
@no_stderr_redirect = options[:no_stderr_redirect] if options.has_key? :no_stderr_redirect
|
13
13
|
if options[:string]
|
14
14
|
options[:string]
|
15
15
|
elsif options[:file]
|
@@ -37,6 +37,7 @@ module Whenever
|
|
37
37
|
|
38
38
|
def command(task, options = {})
|
39
39
|
options[:cron_log] ||= @cron_log unless options[:cron_log] === false
|
40
|
+
options[:no_stderr_redirect] ||= @no_stderr_redirect unless options[:no_stderr_redirect] === false
|
40
41
|
options[:class] ||= Whenever::Job::Default
|
41
42
|
@jobs[@current_time_scope] ||= []
|
42
43
|
@jobs[@current_time_scope] << options[:class].new(@options.merge(:task => task).merge(options))
|
@@ -79,7 +80,8 @@ module Whenever
|
|
79
80
|
@jobs.each do |time, jobs|
|
80
81
|
jobs.each do |job|
|
81
82
|
cron = Whenever::Output::Cron.output(time, job)
|
82
|
-
cron << " >> #{job.cron_log}
|
83
|
+
cron << " >> #{job.cron_log}" if job.cron_log
|
84
|
+
cron << " 2>&1" if job.cron_log && job.no_stderr_redirect.blank?
|
83
85
|
cron << "\n\n"
|
84
86
|
output << cron
|
85
87
|
end
|
data/lib/job_types/default.rb
CHANGED
@@ -2,12 +2,13 @@ module Whenever
|
|
2
2
|
module Job
|
3
3
|
class Default
|
4
4
|
|
5
|
-
attr_accessor :task, :at, :cron_log
|
5
|
+
attr_accessor :task, :at, :cron_log, :no_stderr_redirect
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
8
|
@task = options[:task]
|
9
9
|
@at = options[:at]
|
10
10
|
@cron_log = options[:cron_log]
|
11
|
+
@no_stderr_redirect = options[:no_stderr_redirect]
|
11
12
|
@environment = options[:environment] || :production
|
12
13
|
@path = options[:path] || Whenever.path
|
13
14
|
end
|
data/lib/version.rb
CHANGED
data/test/output_command_test.rb
CHANGED
@@ -83,6 +83,59 @@ class OutputCommandTest < Test::Unit::TestCase
|
|
83
83
|
assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
|
84
84
|
assert_match /^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1$/, @output
|
85
85
|
end
|
86
|
-
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "A command when the cron_log is set and the no_stderr_redirect is set too" do
|
89
|
+
setup do
|
90
|
+
@output = Whenever.cron \
|
91
|
+
<<-file
|
92
|
+
set :cron_log, 'logfile.log'
|
93
|
+
set :no_stderr_redirect, true
|
94
|
+
every 2.hours do
|
95
|
+
command "blahblah"
|
96
|
+
end
|
97
|
+
file
|
98
|
+
end
|
99
|
+
|
100
|
+
should "output the command with the log syntax appended but no error redirection" do
|
101
|
+
assert_match /^.+ .+ .+ .+ blahblah >> logfile.log$/, @output
|
102
|
+
end
|
103
|
+
end
|
87
104
|
|
105
|
+
|
106
|
+
context "A command when the cron_log is set but no_stderr_redirect is set to false" do
|
107
|
+
setup do
|
108
|
+
@output = Whenever.cron \
|
109
|
+
<<-file
|
110
|
+
set :cron_log, 'logfile.log'
|
111
|
+
set :no_stderr_redirect, false
|
112
|
+
every 2.hours do
|
113
|
+
command "blahblah"
|
114
|
+
end
|
115
|
+
file
|
116
|
+
end
|
117
|
+
|
118
|
+
should "output the command with the log syntax appended with error redirection" do
|
119
|
+
assert_match /^.+ .+ .+ .+ blahblah >> logfile.log 2>&1$/, @output
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "A command when cron_log and no_stderr_redirect are not set but the the command line sets them instead." do
|
124
|
+
setup do
|
125
|
+
@output = Whenever.cron(
|
126
|
+
:cron_log => "otherlog.log",
|
127
|
+
:no_stderr_redirect => true,
|
128
|
+
:string => %%
|
129
|
+
every 2.hours do
|
130
|
+
command "blahblah"
|
131
|
+
end
|
132
|
+
%
|
133
|
+
)
|
134
|
+
end
|
135
|
+
|
136
|
+
should "output the command with the log syntax appended but no error redirection" do
|
137
|
+
assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log/, @output
|
138
|
+
assert_match /^.+ .+ .+ .+ blahblah >> otherlog.log$/, @output
|
139
|
+
end
|
140
|
+
end
|
88
141
|
end
|
data/whenever.gemspec
CHANGED
@@ -2,22 +2,22 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{whenever}
|
5
|
-
s.version = "0.1.5.
|
5
|
+
s.version = "0.1.5.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Javan Makhmali"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-07-21}
|
10
10
|
s.description = %q{Provides clean ruby syntax for defining messy cron jobs and running them Whenever.}
|
11
11
|
s.email = %q{javan@javan.us}
|
12
12
|
s.executables = ["whenever", "wheneverize"]
|
13
13
|
s.extra_rdoc_files = ["bin/whenever", "bin/wheneverize", "CHANGELOG.rdoc", "lib/base.rb", "lib/command_line.rb", "lib/job_list.rb", "lib/job_types/default.rb", "lib/job_types/rake_task.rb", "lib/job_types/runner.rb", "lib/outputs/cron.rb", "lib/version.rb", "lib/whenever.rb", "README.rdoc"]
|
14
|
-
s.files = ["bin/whenever", "bin/wheneverize", "CHANGELOG.rdoc", "lib/base.rb", "lib/command_line.rb", "lib/job_list.rb", "lib/job_types/default.rb", "lib/job_types/rake_task.rb", "lib/job_types/runner.rb", "lib/outputs/cron.rb", "lib/version.rb", "lib/whenever.rb", "Rakefile", "README.rdoc", "test/command_line_test.rb", "test/cron_test.rb", "test/output_command_test.rb", "test/output_env_test.rb", "test/output_rake_test.rb", "test/output_runner_test.rb", "test/test_helper.rb", "whenever.gemspec"
|
14
|
+
s.files = ["bin/whenever", "bin/wheneverize", "CHANGELOG.rdoc", "lib/base.rb", "lib/command_line.rb", "lib/job_list.rb", "lib/job_types/default.rb", "lib/job_types/rake_task.rb", "lib/job_types/runner.rb", "lib/outputs/cron.rb", "lib/version.rb", "lib/whenever.rb", "Rakefile", "README.rdoc", "test/command_line_test.rb", "test/cron_test.rb", "test/output_command_test.rb", "test/output_env_test.rb", "test/output_rake_test.rb", "test/output_runner_test.rb", "test/test_helper.rb", "whenever.gemspec"]
|
15
15
|
s.has_rdoc = true
|
16
16
|
s.homepage = %q{http://github.com/javan/whenever}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Whenever", "--main", "README.rdoc"]
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
s.rubyforge_project = %q{whenever}
|
20
|
-
s.rubygems_version = %q{1.3.
|
20
|
+
s.rubygems_version = %q{1.3.1}
|
21
21
|
s.summary = %q{Provides clean ruby syntax for defining messy cron jobs and running them Whenever.}
|
22
22
|
s.test_files = ["test/command_line_test.rb", "test/cron_test.rb", "test/output_command_test.rb", "test/output_env_test.rb", "test/output_rake_test.rb", "test/output_runner_test.rb", "test/test_helper.rb"]
|
23
23
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cwninja-whenever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.5.
|
4
|
+
version: 0.1.5.4
|
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-07-21 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -76,7 +76,6 @@ files:
|
|
76
76
|
- test/output_runner_test.rb
|
77
77
|
- test/test_helper.rb
|
78
78
|
- whenever.gemspec
|
79
|
-
- Manifest
|
80
79
|
has_rdoc: true
|
81
80
|
homepage: http://github.com/javan/whenever
|
82
81
|
post_install_message:
|