ewoutvonk-whenever 0.3.6.002 → 0.3.7.001
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/Manifest +1 -0
- data/lib/job_list.rb +12 -5
- data/lib/job_types/default.rb +20 -16
- data/lib/job_types/rake_task.rb +1 -1
- data/lib/job_types/runner.rb +1 -1
- data/lib/version.rb +1 -1
- data/test/output_at_test.rb +41 -0
- data/whenever.gemspec +5 -4
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
data/Manifest
CHANGED
data/lib/job_list.rb
CHANGED
@@ -112,7 +112,7 @@ module Whenever
|
|
112
112
|
# them into one that runs on the 2nd minute at the 3rd and 4th hour.
|
113
113
|
#
|
114
114
|
def combine(entries)
|
115
|
-
entries.map! { |entry| entry.split(/ +/,6
|
115
|
+
entries.map! { |entry| entry.split(/ +/, 6) }
|
116
116
|
0.upto(4) do |f|
|
117
117
|
(entries.length-1).downto(1) do |i|
|
118
118
|
next if entries[i][f] == '*'
|
@@ -134,18 +134,25 @@ module Whenever
|
|
134
134
|
def cron_jobs
|
135
135
|
return if @jobs.empty?
|
136
136
|
|
137
|
-
|
137
|
+
shortcut_jobs = []
|
138
|
+
regular_jobs = []
|
139
|
+
|
138
140
|
@jobs.each do |time, jobs|
|
139
141
|
jobs.each do |job|
|
140
142
|
Whenever::Output::Cron.output(time, job) do |cron|
|
141
143
|
cron << " >> #{job.cron_log} 2>&1" if job.cron_log
|
142
144
|
cron << "\n\n"
|
143
|
-
|
145
|
+
|
146
|
+
if cron.starts_with?("@")
|
147
|
+
shortcut_jobs << cron
|
148
|
+
else
|
149
|
+
regular_jobs << cron
|
150
|
+
end
|
144
151
|
end
|
145
152
|
end
|
146
153
|
end
|
147
|
-
|
148
|
-
combine(
|
154
|
+
|
155
|
+
shortcut_jobs.join + combine(regular_jobs).join
|
149
156
|
end
|
150
157
|
|
151
158
|
end
|
data/lib/job_types/default.rb
CHANGED
@@ -5,32 +5,36 @@ module Whenever
|
|
5
5
|
attr_accessor :task, :at, :cron_log
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
|
-
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@cron_log =
|
12
|
-
@environment =
|
13
|
-
@path =
|
8
|
+
opts = options.clone
|
9
|
+
@task = opts.delete(:task)
|
10
|
+
@at = opts.delete(:at)
|
11
|
+
@cron_log = opts.delete(:cron_log)
|
12
|
+
@environment = opts.delete(:environment) || :production
|
13
|
+
@path = opts.delete(:path) || Whenever.path
|
14
|
+
@envvars = opts
|
14
15
|
end
|
15
16
|
|
16
17
|
def output
|
17
18
|
envvars + task
|
18
19
|
end
|
19
20
|
|
20
|
-
protected
|
21
|
-
|
22
21
|
def envvars
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
vars = ''
|
23
|
+
if !@envvars.nil? && @envvars.keys.size > 0
|
24
|
+
vars = @envvars.collect do |key,value|
|
25
|
+
if key.is_a?(String)
|
26
|
+
key.to_s + "=" + value.to_s
|
27
|
+
else
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
end.compact.join(' ')
|
31
31
|
end
|
32
|
+
|
33
|
+
vars.empty? ? '' : vars + ' '
|
32
34
|
end
|
33
35
|
|
36
|
+
protected
|
37
|
+
|
34
38
|
def path_required
|
35
39
|
raise ArgumentError, "No path available; set :path, '/your/path' in your schedule file" if @path.blank?
|
36
40
|
end
|
data/lib/job_types/rake_task.rb
CHANGED
data/lib/job_types/runner.rb
CHANGED
data/lib/version.rb
CHANGED
data/test/output_at_test.rb
CHANGED
@@ -134,4 +134,45 @@ class OutputAtTest < Test::Unit::TestCase
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
+
context "Multiple commands output every :reboot" do
|
138
|
+
setup do
|
139
|
+
@output = Whenever.cron \
|
140
|
+
<<-file
|
141
|
+
every :reboot do
|
142
|
+
command "command_1"
|
143
|
+
command "command_2"
|
144
|
+
end
|
145
|
+
file
|
146
|
+
end
|
147
|
+
|
148
|
+
should "output both commands @reboot" do
|
149
|
+
assert_match "@reboot command_1", @output
|
150
|
+
assert_match "@reboot command_2", @output
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context "Many different job types output every :day" do
|
155
|
+
setup do
|
156
|
+
@output = Whenever.cron \
|
157
|
+
<<-file
|
158
|
+
set :path, '/your/path'
|
159
|
+
every :day do
|
160
|
+
rake "blah:blah"
|
161
|
+
runner "runner_1"
|
162
|
+
command "command_1"
|
163
|
+
runner "runner_2"
|
164
|
+
command "command_2"
|
165
|
+
end
|
166
|
+
file
|
167
|
+
end
|
168
|
+
|
169
|
+
should "output all of the commands @daily" do
|
170
|
+
assert_match '@daily cd /your/path && RAILS_ENV=production /usr/bin/env rake blah:blah', @output
|
171
|
+
assert_match '@daily /your/path/script/runner -e production "runner_1"', @output
|
172
|
+
assert_match '@daily command_1', @output
|
173
|
+
assert_match '@daily /your/path/script/runner -e production "runner_2"', @output
|
174
|
+
assert_match '@daily command_2', @output
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
137
178
|
end
|
data/whenever.gemspec
CHANGED
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{whenever}
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.7.001"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Ewout Vonk"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-09-10}
|
10
|
+
|
10
11
|
s.description = %q{Provides clean ruby syntax for defining messy cron jobs and running them Whenever.}
|
11
12
|
s.email = %q{ewoutvonk@ewout.info}
|
12
13
|
s.executables = ["whenever", "wheneverize"]
|
@@ -17,13 +18,13 @@ Gem::Specification.new do |s|
|
|
17
18
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Whenever", "--main", "README.rdoc"]
|
18
19
|
s.require_paths = ["lib"]
|
19
20
|
s.rubyforge_project = %q{whenever}
|
20
|
-
s.rubygems_version = %q{1.3.
|
21
|
+
s.rubygems_version = %q{1.3.5}
|
21
22
|
s.summary = %q{Provides clean ruby syntax for defining messy cron jobs and running them Whenever.}
|
22
23
|
s.test_files = ["test/command_line_test.rb", "test/cron_test.rb", "test/output_at_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
24
|
|
24
25
|
if s.respond_to? :specification_version then
|
25
26
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
26
|
-
s.specification_version =
|
27
|
+
s.specification_version = 3
|
27
28
|
|
28
29
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
30
|
s.add_runtime_dependency(%q<chronic>, [">= 0.2.3"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ewoutvonk-whenever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7.001
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ewout Vonk
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-10 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -97,7 +97,7 @@ requirements: []
|
|
97
97
|
rubyforge_project: whenever
|
98
98
|
rubygems_version: 1.2.0
|
99
99
|
signing_key:
|
100
|
-
specification_version:
|
100
|
+
specification_version: 3
|
101
101
|
summary: Provides clean ruby syntax for defining messy cron jobs and running them Whenever.
|
102
102
|
test_files:
|
103
103
|
- test/command_line_test.rb
|