whenever 0.4.2 → 0.5.0
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/CHANGELOG.rdoc +9 -0
- data/README.rdoc +22 -0
- data/bin/whenever +4 -0
- data/lib/whenever.rb +1 -12
- data/lib/whenever/base.rb +1 -5
- data/lib/whenever/command_line.rb +4 -4
- data/lib/whenever/job.rb +22 -0
- data/lib/whenever/job_list.rb +24 -24
- data/lib/whenever/job_types/default.rb +3 -27
- data/lib/whenever/outputs/cron.rb +1 -1
- data/lib/whenever/version.rb +1 -1
- data/test/command_line_test.rb +78 -2
- data/test/output_at_test.rb +59 -0
- data/test/output_defined_job_test.rb +87 -0
- data/test/output_runner_test.rb +0 -34
- data/whenever.gemspec +5 -4
- metadata +7 -6
- data/lib/whenever/job_types/rake_task.rb +0 -12
- data/lib/whenever/job_types/runner.rb +0 -12
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 0.5.0 / June 28th, 2010
|
2
|
+
|
3
|
+
* New job_type API for writing custom jobs. Internals use this to define command, runner, and rake. [Javan Makhmali - inspired by idlefingers (Damien)]
|
4
|
+
|
5
|
+
* Jobs < 1.hour can specify an :at. [gorenje]
|
6
|
+
|
7
|
+
* --clear option to remove crontab entries for a specific [identifier]. [mraidel (Michael Raidel)]
|
8
|
+
|
9
|
+
|
1
10
|
== 0.4.2 / April 26th, 2010
|
2
11
|
|
3
12
|
* runners now cd into the app's directory and then execute. [Michael Guterl]
|
data/README.rdoc
CHANGED
@@ -39,6 +39,28 @@ This will create an initial "config/schedule.rb" file you.
|
|
39
39
|
|
40
40
|
More examples on the wiki: http://wiki.github.com/javan/whenever/instructions-and-examples
|
41
41
|
|
42
|
+
== Define your own job types
|
43
|
+
|
44
|
+
Whenever ships with three pre-defined job types: command, runner, and rake. You can define your own with <code>job_type</code>.
|
45
|
+
|
46
|
+
For example:
|
47
|
+
|
48
|
+
job_type :awesome, '/usr/local/bin/awesome :task :fun_level'
|
49
|
+
|
50
|
+
every 2.hours do
|
51
|
+
awesome "party", :fun_level => "extreme"
|
52
|
+
end
|
53
|
+
|
54
|
+
Would run <code>/usr/local/bin/awesome party extreme</code> every two hours. <code>:task</code> is always replaced with the first argument, and any additional <code>:whatevers</code> are replaced with the options passed in or by variables that have been defined with <code>set</code>.
|
55
|
+
|
56
|
+
The default job types that ship with Whenever are defined like so:
|
57
|
+
|
58
|
+
job_type :command, ':task'
|
59
|
+
job_type :runner, 'cd :path && script/runner -e :environment ":task"'
|
60
|
+
job_type :rake, 'cd :path && RAILS_ENV=:environment /usr/bin/env rake :task'
|
61
|
+
|
62
|
+
If a <code>:path</code> is not set it will default to the directory in which <code>whenever</code> was executed. <code>:environment</code> will default to 'production'.
|
63
|
+
|
42
64
|
== Cron output
|
43
65
|
|
44
66
|
$ cd /my/rails/app
|
data/bin/whenever
CHANGED
@@ -14,6 +14,10 @@ OptionParser.new do |opts|
|
|
14
14
|
options[:update] = true
|
15
15
|
options[:identifier] = identifier if identifier
|
16
16
|
end
|
17
|
+
opts.on('-c', '--clear-crontab [identifier]') do |identifier|
|
18
|
+
options[:clear] = true
|
19
|
+
options[:identifier] = identifier if identifier
|
20
|
+
end
|
17
21
|
opts.on('-f', '--load-file [schedule file]', 'Default: config/schedule.rb') do |file|
|
18
22
|
options[:file] = file if file
|
19
23
|
end
|
data/lib/whenever.rb
CHANGED
@@ -1,14 +1,5 @@
|
|
1
1
|
require 'chronic'
|
2
2
|
|
3
|
-
# Hoping to load Rails' Rakefile
|
4
|
-
begin
|
5
|
-
load 'Rakefile'
|
6
|
-
rescue LoadError
|
7
|
-
nil
|
8
|
-
end
|
9
|
-
|
10
|
-
# If Rails' rakefile was loaded than so was active_support, but
|
11
|
-
# if this is being used in a non-rails enviroment we need to require it.
|
12
3
|
# It was previously defined as a dependency of this gem, but that became
|
13
4
|
# problematic. See: http://github.com/javan/whenever/issues#issue/1
|
14
5
|
begin
|
@@ -22,9 +13,7 @@ end
|
|
22
13
|
# Whenever files
|
23
14
|
require 'whenever/base'
|
24
15
|
require 'whenever/job_list'
|
25
|
-
require 'whenever/
|
26
|
-
require 'whenever/job_types/rake_task'
|
27
|
-
require 'whenever/job_types/runner'
|
16
|
+
require 'whenever/job'
|
28
17
|
require 'whenever/outputs/cron'
|
29
18
|
require 'whenever/outputs/cron/output_redirection'
|
30
19
|
require 'whenever/command_line'
|
data/lib/whenever/base.rb
CHANGED
@@ -19,14 +19,14 @@ module Whenever
|
|
19
19
|
exit(1)
|
20
20
|
end
|
21
21
|
|
22
|
-
if @options[:update]
|
23
|
-
warn("[fail] Can
|
22
|
+
if [@options[:update], @options[:write], @options[:clear]].compact.length > 1
|
23
|
+
warn("[fail] Can only update, write or clear. Choose one.")
|
24
24
|
exit(1)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def run
|
29
|
-
if @options[:update]
|
29
|
+
if @options[:update] || @options[:clear]
|
30
30
|
write_crontab(updated_crontab)
|
31
31
|
elsif @options[:write]
|
32
32
|
write_crontab(whenever_cron)
|
@@ -43,7 +43,7 @@ module Whenever
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def whenever_cron
|
46
|
-
@whenever_cron ||= [comment_open, Whenever.cron(@options), comment_close].join("\n") + "\n"
|
46
|
+
@whenever_cron ||= [comment_open, (Whenever.cron(@options) unless @options[:clear]), comment_close].compact.join("\n") + "\n"
|
47
47
|
end
|
48
48
|
|
49
49
|
def read_crontab
|
data/lib/whenever/job.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Whenever
|
2
|
+
class Job
|
3
|
+
|
4
|
+
attr_accessor :at, :output_redirection
|
5
|
+
|
6
|
+
def initialize(options = {})
|
7
|
+
@options = options
|
8
|
+
|
9
|
+
@at = options[:at]
|
10
|
+
@output_redirection = options.has_key?(:output) ? options[:output] : :not_set
|
11
|
+
@options[:environment] ||= :production
|
12
|
+
@options[:path] ||= Whenever.path
|
13
|
+
end
|
14
|
+
|
15
|
+
def output
|
16
|
+
@options[:template].gsub(/:\w+/) do |key|
|
17
|
+
@options[key.sub(':', '').to_sym]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/whenever/job_list.rb
CHANGED
@@ -2,8 +2,7 @@ module Whenever
|
|
2
2
|
class JobList
|
3
3
|
|
4
4
|
def initialize(options)
|
5
|
-
@jobs =
|
6
|
-
@env = Hash.new
|
5
|
+
@jobs, @env, @set_variables = {}, {}, {}
|
7
6
|
|
8
7
|
case options
|
9
8
|
when String
|
@@ -16,7 +15,12 @@ module Whenever
|
|
16
15
|
end
|
17
16
|
pre_set(options[:set])
|
18
17
|
end
|
19
|
-
|
18
|
+
|
19
|
+
# Load all job type files.
|
20
|
+
Dir["#{File.expand_path(File.dirname(__FILE__))}/job_types/*.rb"].each do |file|
|
21
|
+
eval(File.read(file))
|
22
|
+
end
|
23
|
+
|
20
24
|
eval(config)
|
21
25
|
end
|
22
26
|
|
@@ -25,6 +29,7 @@ module Whenever
|
|
25
29
|
|
26
30
|
instance_variable_set("@#{variable}".to_sym, value)
|
27
31
|
self.class.send(:attr_reader, variable.to_sym)
|
32
|
+
@set_variables[variable] = value
|
28
33
|
end
|
29
34
|
|
30
35
|
def env(variable, value)
|
@@ -37,26 +42,21 @@ module Whenever
|
|
37
42
|
yield
|
38
43
|
end
|
39
44
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
def rake(task, options = {})
|
57
|
-
options.reverse_merge!(:environment => @environment, :path => @path)
|
58
|
-
options[:class] = Whenever::Job::RakeTask
|
59
|
-
command(task, options)
|
45
|
+
def job_type(name, template)
|
46
|
+
class_eval do
|
47
|
+
define_method(name) do |task, *args|
|
48
|
+
options = { :task => task, :template => template }
|
49
|
+
options.merge!(args[0]) if args[0].is_a? Hash
|
50
|
+
|
51
|
+
# :cron_log was an old option for output redirection, it remains for backwards compatibility
|
52
|
+
options[:output] = (options[:cron_log] || @cron_log) if defined?(@cron_log) || options.has_key?(:cron_log)
|
53
|
+
# :output is the newer, more flexible option.
|
54
|
+
options[:output] = @output if defined?(@output) && !options.has_key?(:output)
|
55
|
+
|
56
|
+
@jobs[@current_time_scope] ||= []
|
57
|
+
@jobs[@current_time_scope] << Whenever::Job.new(@options.merge(@set_variables).merge(options))
|
58
|
+
end
|
59
|
+
end
|
60
60
|
end
|
61
61
|
|
62
62
|
def generate_cron_output
|
@@ -79,7 +79,7 @@ module Whenever
|
|
79
79
|
pairs.each do |pair|
|
80
80
|
next unless pair.index('=')
|
81
81
|
variable, value = *pair.split('=')
|
82
|
-
set(variable.strip, value.strip) unless variable.blank? || value.blank?
|
82
|
+
set(variable.strip.to_sym, value.strip) unless variable.blank? || value.blank?
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -1,27 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
attr_accessor :task, :at, :output, :output_redirection
|
6
|
-
|
7
|
-
def initialize(options = {})
|
8
|
-
@task = options[:task]
|
9
|
-
@at = options[:at]
|
10
|
-
@output_redirection = options.has_key?(:output) ? options[:output] : :not_set
|
11
|
-
@environment = options[:environment] || :production
|
12
|
-
@path = options[:path] || Whenever.path
|
13
|
-
end
|
14
|
-
|
15
|
-
def output
|
16
|
-
task
|
17
|
-
end
|
18
|
-
|
19
|
-
protected
|
20
|
-
|
21
|
-
def path_required
|
22
|
-
raise ArgumentError, "No path available; set :path, '/your/path' in your schedule file" if @path.blank?
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
1
|
+
job_type :command, ':task'
|
2
|
+
job_type :runner, 'cd :path && script/runner -e :environment ":task"'
|
3
|
+
job_type :rake, 'cd :path && RAILS_ENV=:environment /usr/bin/env rake :task'
|
@@ -77,7 +77,7 @@ module Whenever
|
|
77
77
|
raise ArgumentError, "Time must be in minutes or higher"
|
78
78
|
when 1.minute...1.hour
|
79
79
|
minute_frequency = @time / 60
|
80
|
-
timing[0] = comma_separated_timing(minute_frequency, 59)
|
80
|
+
timing[0] = comma_separated_timing(minute_frequency, 59, @at || 0)
|
81
81
|
when 1.hour...1.day
|
82
82
|
hour_frequency = (@time / 60 / 60).round
|
83
83
|
timing[0] = @at.is_a?(Time) ? @at.min : @at
|
data/lib/whenever/version.rb
CHANGED
data/test/command_line_test.rb
CHANGED
@@ -74,6 +74,63 @@ EXISTING_CRON
|
|
74
74
|
#{@task}
|
75
75
|
# End Whenever generated tasks for: My identifier
|
76
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 delete" do
|
90
|
+
setup do
|
91
|
+
File.expects(:exists?).with('config/schedule.rb').returns(true)
|
92
|
+
@command = Whenever::CommandLine.new(:clear => true, :identifier => 'My identifier')
|
93
|
+
@task = "#{two_hours} /my/command"
|
94
|
+
end
|
95
|
+
|
96
|
+
should "add an empty identifier block if there is no existing one" do
|
97
|
+
existing = '# Existing crontab'
|
98
|
+
@command.expects(:read_crontab).at_least_once.returns(existing)
|
99
|
+
|
100
|
+
new_cron = <<-EXPECTED
|
101
|
+
#{existing}
|
102
|
+
|
103
|
+
# Begin Whenever generated tasks for: My identifier
|
104
|
+
# End Whenever generated tasks for: My identifier
|
105
|
+
EXPECTED
|
106
|
+
|
107
|
+
assert_equal new_cron, @command.send(:updated_crontab)
|
108
|
+
|
109
|
+
@command.expects(:write_crontab).with(new_cron).returns(true)
|
110
|
+
assert @command.run
|
111
|
+
end
|
112
|
+
|
113
|
+
should "delete an existing block if the identifier matches" do
|
114
|
+
existing = <<-EXISTING_CRON
|
115
|
+
# Something
|
116
|
+
|
117
|
+
# Begin Whenever generated tasks for: My identifier
|
118
|
+
My whenever job that was already here
|
119
|
+
# End Whenever generated tasks for: My identifier
|
120
|
+
|
121
|
+
# Begin Whenever generated tasks for: Other identifier
|
122
|
+
This shouldn't get replaced
|
123
|
+
# End Whenever generated tasks for: Other identifier
|
124
|
+
EXISTING_CRON
|
125
|
+
|
126
|
+
@command.expects(:read_crontab).at_least_once.returns(existing)
|
127
|
+
|
128
|
+
new_cron = <<-NEW_CRON
|
129
|
+
# Something
|
130
|
+
|
131
|
+
# Begin Whenever generated tasks for: My identifier
|
132
|
+
# End Whenever generated tasks for: My identifier
|
133
|
+
|
77
134
|
# Begin Whenever generated tasks for: Other identifier
|
78
135
|
This shouldn't get replaced
|
79
136
|
# End Whenever generated tasks for: Other identifier
|
@@ -97,5 +154,24 @@ NEW_CRON
|
|
97
154
|
assert_equal "Whenever generated tasks for: DEFAULT", @command.send(:comment_base)
|
98
155
|
end
|
99
156
|
end
|
100
|
-
|
101
|
-
|
157
|
+
|
158
|
+
context "combined params" do
|
159
|
+
setup do
|
160
|
+
Whenever::CommandLine.any_instance.expects(:exit)
|
161
|
+
Whenever::CommandLine.any_instance.expects(:warn)
|
162
|
+
File.expects(:exists?).with('config/schedule.rb').returns(true)
|
163
|
+
end
|
164
|
+
|
165
|
+
should "exit with write and clear" do
|
166
|
+
@command = Whenever::CommandLine.new(:write => true, :clear => true)
|
167
|
+
end
|
168
|
+
|
169
|
+
should "exit with write and update" do
|
170
|
+
@command = Whenever::CommandLine.new(:write => true, :update => true)
|
171
|
+
end
|
172
|
+
|
173
|
+
should "exit with update and clear" do
|
174
|
+
@command = Whenever::CommandLine.new(:update => true, :clear => true)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
data/test/output_at_test.rb
CHANGED
@@ -175,4 +175,63 @@ class OutputAtTest < Test::Unit::TestCase
|
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
+
context "every 5 minutes but but starting at 1" do
|
179
|
+
setup do
|
180
|
+
@output = Whenever.cron \
|
181
|
+
<<-file
|
182
|
+
every 5.minutes, :at => 1 do
|
183
|
+
command "blahblah"
|
184
|
+
end
|
185
|
+
file
|
186
|
+
end
|
187
|
+
|
188
|
+
should "output the command using that time" do
|
189
|
+
assert_match '1,6,11,16,21,26,31,36,41,46,51,56 * * * * blahblah', @output
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
context "every 4 minutes but starting at 2" do
|
194
|
+
setup do
|
195
|
+
@output = Whenever.cron \
|
196
|
+
<<-file
|
197
|
+
every 4.minutes, :at => 2 do
|
198
|
+
command "blahblah"
|
199
|
+
end
|
200
|
+
file
|
201
|
+
end
|
202
|
+
|
203
|
+
should "output the command using that time" do
|
204
|
+
assert_match '2,6,10,14,18,22,26,30,34,38,42,46,50,54,58 * * * * blahblah', @output
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
context "every 3 minutes but starting at 7" do
|
209
|
+
setup do
|
210
|
+
@output = Whenever.cron \
|
211
|
+
<<-file
|
212
|
+
every 3.minutes, :at => 7 do
|
213
|
+
command "blahblah"
|
214
|
+
end
|
215
|
+
file
|
216
|
+
end
|
217
|
+
|
218
|
+
should "output the command using that time" do
|
219
|
+
assert_match '7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58 * * * * blahblah', @output
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
context "every 2 minutes but starting at 27" do
|
224
|
+
setup do
|
225
|
+
@output = Whenever.cron \
|
226
|
+
<<-file
|
227
|
+
every 2.minutes, :at => 27 do
|
228
|
+
command "blahblah"
|
229
|
+
end
|
230
|
+
file
|
231
|
+
end
|
232
|
+
|
233
|
+
should "output the command using that time" do
|
234
|
+
assert_match '27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59 * * * * blahblah', @output
|
235
|
+
end
|
236
|
+
end
|
178
237
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
2
|
+
|
3
|
+
class OutputDefinedJobTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "A defined job with a :task" do
|
6
|
+
setup do
|
7
|
+
@output = Whenever.cron \
|
8
|
+
<<-file
|
9
|
+
job_type :some_job, "before :task after"
|
10
|
+
every 2.hours do
|
11
|
+
some_job "during"
|
12
|
+
end
|
13
|
+
file
|
14
|
+
end
|
15
|
+
|
16
|
+
should "output the defined job with the task" do
|
17
|
+
assert_match /^.+ .+ .+ .+ before during after$/, @output
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "A defined job with a :task and some options" do
|
22
|
+
setup do
|
23
|
+
@output = Whenever.cron \
|
24
|
+
<<-file
|
25
|
+
job_type :some_job, "before :task after :option1 :option2"
|
26
|
+
every 2.hours do
|
27
|
+
some_job "during", :option1 => 'happy', :option2 => 'birthday'
|
28
|
+
end
|
29
|
+
file
|
30
|
+
end
|
31
|
+
|
32
|
+
should "output the defined job with the task and options" do
|
33
|
+
assert_match /^.+ .+ .+ .+ before during after happy birthday$/, @output
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "A defined job with a :task and an option where the option is set globally" do
|
38
|
+
setup do
|
39
|
+
@output = Whenever.cron \
|
40
|
+
<<-file
|
41
|
+
job_type :some_job, "before :task after :option1"
|
42
|
+
set :option1, 'happy'
|
43
|
+
every 2.hours do
|
44
|
+
some_job "during"
|
45
|
+
end
|
46
|
+
file
|
47
|
+
end
|
48
|
+
|
49
|
+
should "output the defined job with the task and options" do
|
50
|
+
assert_match /^.+ .+ .+ .+ before during after happy$/, @output
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "A defined job with a :task and an option where the option is set globally and locally" do
|
55
|
+
setup do
|
56
|
+
@output = Whenever.cron \
|
57
|
+
<<-file
|
58
|
+
job_type :some_job, "before :task after :option1"
|
59
|
+
set :option1, 'global'
|
60
|
+
every 2.hours do
|
61
|
+
some_job "during", :option1 => 'local'
|
62
|
+
end
|
63
|
+
file
|
64
|
+
end
|
65
|
+
|
66
|
+
should "output the defined job using the local option" do
|
67
|
+
assert_match /^.+ .+ .+ .+ before during after local$/, @output
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "A defined job with a :task and an option that is not set" do
|
72
|
+
setup do
|
73
|
+
@output = Whenever.cron \
|
74
|
+
<<-file
|
75
|
+
job_type :some_job, "before :task after :option1"
|
76
|
+
every 2.hours do
|
77
|
+
some_job "during", :option2 => 'happy'
|
78
|
+
end
|
79
|
+
file
|
80
|
+
end
|
81
|
+
|
82
|
+
should "output the defined job with that option removed" do
|
83
|
+
assert_match /^.+ .+ .+ .+ before during after$/, @output
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
data/test/output_runner_test.rb
CHANGED
@@ -70,24 +70,6 @@ class OutputRunnerTest < Test::Unit::TestCase
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
context "A runner with no path set and no RAILS_ROOT defined" do
|
74
|
-
setup do
|
75
|
-
Whenever.stubs(:path).returns(nil)
|
76
|
-
|
77
|
-
@input = <<-file
|
78
|
-
every 2.hours do
|
79
|
-
runner "blahblah"
|
80
|
-
end
|
81
|
-
file
|
82
|
-
end
|
83
|
-
|
84
|
-
should "raise an exception" do
|
85
|
-
assert_raises ArgumentError do
|
86
|
-
Whenever.cron(@input)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
73
|
context "A runner with an environment set" do
|
92
74
|
setup do
|
93
75
|
@output = Whenever.cron \
|
@@ -190,20 +172,4 @@ class OutputRunnerTest < Test::Unit::TestCase
|
|
190
172
|
end
|
191
173
|
end
|
192
174
|
|
193
|
-
context "A runner which makes use of double quotes" do
|
194
|
-
setup do
|
195
|
-
@output = Whenever.cron \
|
196
|
-
<<-file
|
197
|
-
set :path, '/my/path'
|
198
|
-
every 2.hours do
|
199
|
-
runner 'Product.import("http://example.com/product.xml")'
|
200
|
-
end
|
201
|
-
file
|
202
|
-
end
|
203
|
-
|
204
|
-
should "output the runner using the original environmnet" do
|
205
|
-
assert_match two_hours + ' cd /my/path && script/runner -e production "Product.import(\"http://example.com/product.xml\")"', @output
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
175
|
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.0"
|
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{2010-
|
12
|
+
s.date = %q{2010-06-28}
|
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,10 +26,9 @@ 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/job.rb",
|
29
30
|
"lib/whenever/job_list.rb",
|
30
31
|
"lib/whenever/job_types/default.rb",
|
31
|
-
"lib/whenever/job_types/rake_task.rb",
|
32
|
-
"lib/whenever/job_types/runner.rb",
|
33
32
|
"lib/whenever/outputs/cron.rb",
|
34
33
|
"lib/whenever/outputs/cron/output_redirection.rb",
|
35
34
|
"lib/whenever/version.rb",
|
@@ -37,6 +36,7 @@ Gem::Specification.new do |s|
|
|
37
36
|
"test/cron_test.rb",
|
38
37
|
"test/output_at_test.rb",
|
39
38
|
"test/output_command_test.rb",
|
39
|
+
"test/output_defined_job_test.rb",
|
40
40
|
"test/output_env_test.rb",
|
41
41
|
"test/output_rake_test.rb",
|
42
42
|
"test/output_redirection_test.rb",
|
@@ -54,6 +54,7 @@ Gem::Specification.new do |s|
|
|
54
54
|
"test/cron_test.rb",
|
55
55
|
"test/output_at_test.rb",
|
56
56
|
"test/output_command_test.rb",
|
57
|
+
"test/output_defined_job_test.rb",
|
57
58
|
"test/output_env_test.rb",
|
58
59
|
"test/output_rake_test.rb",
|
59
60
|
"test/output_redirection_test.rb",
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 5
|
8
|
+
- 0
|
9
|
+
version: 0.5.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Javan Makhmali
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-28 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -50,10 +50,9 @@ files:
|
|
50
50
|
- lib/whenever.rb
|
51
51
|
- lib/whenever/base.rb
|
52
52
|
- lib/whenever/command_line.rb
|
53
|
+
- lib/whenever/job.rb
|
53
54
|
- lib/whenever/job_list.rb
|
54
55
|
- lib/whenever/job_types/default.rb
|
55
|
-
- lib/whenever/job_types/rake_task.rb
|
56
|
-
- lib/whenever/job_types/runner.rb
|
57
56
|
- lib/whenever/outputs/cron.rb
|
58
57
|
- lib/whenever/outputs/cron/output_redirection.rb
|
59
58
|
- lib/whenever/version.rb
|
@@ -61,6 +60,7 @@ files:
|
|
61
60
|
- test/cron_test.rb
|
62
61
|
- test/output_at_test.rb
|
63
62
|
- test/output_command_test.rb
|
63
|
+
- test/output_defined_job_test.rb
|
64
64
|
- test/output_env_test.rb
|
65
65
|
- test/output_rake_test.rb
|
66
66
|
- test/output_redirection_test.rb
|
@@ -102,6 +102,7 @@ test_files:
|
|
102
102
|
- test/cron_test.rb
|
103
103
|
- test/output_at_test.rb
|
104
104
|
- test/output_command_test.rb
|
105
|
+
- test/output_defined_job_test.rb
|
105
106
|
- test/output_env_test.rb
|
106
107
|
- test/output_rake_test.rb
|
107
108
|
- test/output_redirection_test.rb
|