whenever 0.6.2 → 0.6.6
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/.gitignore +1 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +4 -0
- data/README.md +5 -1
- data/Rakefile +6 -30
- data/bin/whenever +0 -0
- data/bin/wheneverize +0 -0
- data/lib/whenever/capistrano.rb +2 -1
- data/lib/whenever/command_line.rb +9 -3
- data/lib/whenever/cron.rb +1 -0
- data/lib/whenever/job_list.rb +1 -1
- data/lib/whenever/setup.rb +1 -1
- data/lib/whenever/version.rb +2 -2
- data/test/functional/command_line_test.rb +16 -4
- data/test/functional/output_at_test.rb +17 -0
- data/test/functional/output_default_defined_jobs_test.rb +1 -1
- data/test/functional/output_env_test.rb +11 -1
- data/test/unit/cron_test.rb +9 -0
- data/whenever.gemspec +16 -79
- metadata +15 -14
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
### 0.6.6 / March 8th, 2011
|
2
|
+
|
3
|
+
* Fix unclosed identifier bug. #119 [Javan Makhmali]
|
4
|
+
|
5
|
+
|
6
|
+
### 0.6.5 / March 8th, 2011
|
7
|
+
|
8
|
+
* Preserve whitespace at the end of crontab file. #95 [Rich Meyers]
|
9
|
+
|
10
|
+
* Setting nil or blank environment variables now properly formats output. [T.J. VanSlyke]
|
11
|
+
|
12
|
+
* Allow raw cron sytax, added -i to bash job template, general cleanup. [Javan Makhmali]
|
13
|
+
|
14
|
+
|
1
15
|
### 0.6.2 / October 26th, 2010
|
2
16
|
|
3
17
|
* --clear-crontab option completely removes entries. #63 [Javan Makhmali]
|
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -37,6 +37,10 @@ This will create an initial "config/schedule.rb" file you.
|
|
37
37
|
runner "Task.do_something_great"
|
38
38
|
end
|
39
39
|
|
40
|
+
every '0 0 27-31 * *' do
|
41
|
+
command "echo 'you can use raw cron sytax too'"
|
42
|
+
end
|
43
|
+
|
40
44
|
More examples on the wiki: <http://wiki.github.com/javan/whenever/instructions-and-examples>
|
41
45
|
|
42
46
|
### Define your own job types
|
@@ -100,7 +104,7 @@ This will simply show you your schedule.rb file converted to cron syntax. It doe
|
|
100
104
|
|
101
105
|
### Credit
|
102
106
|
|
103
|
-
Whenever was created for use at Inkling (<http://inklingmarkets.com>)
|
107
|
+
Whenever was created for use at Inkling (<http://inklingmarkets.com>). Their take on it: <http://blog.inklingmarkets.com/2009/02/whenever-easy-way-to-do-cron-jobs-from.html>
|
104
108
|
|
105
109
|
Thanks to all the contributors who have made it even better: <http://github.com/javan/whenever/contributors>
|
106
110
|
|
data/Rakefile
CHANGED
@@ -1,35 +1,11 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
require File.expand_path(File.dirname(__FILE__) + "/lib/whenever/version")
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'jeweler'
|
8
|
-
Jeweler::Tasks.new do |gemspec|
|
9
|
-
gemspec.name = "whenever"
|
10
|
-
gemspec.version = Whenever::VERSION
|
11
|
-
gemspec.summary = "Write your cron jobs in ruby."
|
12
|
-
gemspec.description = "Clean ruby syntax for writing and deploying cron jobs."
|
13
|
-
gemspec.email = "javan@javan.us"
|
14
|
-
gemspec.homepage = "http://github.com/javan/whenever"
|
15
|
-
gemspec.authors = ["Javan Makhmali"]
|
16
|
-
gemspec.add_dependency 'aaronh-chronic', '>= 0.3.9'
|
17
|
-
gemspec.add_dependency 'activesupport', '>= 2.3.4'
|
18
|
-
gemspec.add_development_dependency 'shoulda', '>= 2.1.1'
|
19
|
-
gemspec.add_development_dependency 'mocha', '>= 0.9.5'
|
20
|
-
end
|
21
|
-
Jeweler::GemcutterTasks.new
|
22
|
-
rescue LoadError
|
23
|
-
puts "Jeweler not available. Install it with: sudo gem install jeweler -s http://gemcutter.org"
|
24
|
-
end
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
25
3
|
|
26
4
|
require 'rake/testtask'
|
27
5
|
Rake::TestTask.new(:test) do |test|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
task :test => :check_dependencies
|
6
|
+
test.libs << 'lib' << 'test'
|
7
|
+
test.pattern = 'test/{functional,unit}/**/*_test.rb'
|
8
|
+
test.verbose = true
|
9
|
+
end
|
34
10
|
|
35
11
|
task :default => :test
|
data/bin/whenever
CHANGED
File without changes
|
data/bin/wheneverize
CHANGED
File without changes
|
data/lib/whenever/capistrano.rb
CHANGED
@@ -3,7 +3,8 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
3
3
|
_cset(:whenever_roles) { :db }
|
4
4
|
_cset(:whenever_command) { "whenever" }
|
5
5
|
_cset(:whenever_identifier) { application }
|
6
|
-
_cset(:
|
6
|
+
_cset(:whenever_environment) { "production" }
|
7
|
+
_cset(:whenever_update_flags) { "--update-crontab #{whenever_identifier} --set environment=#{whenever_environment}" }
|
7
8
|
_cset(:whenever_clear_flags) { "--clear-crontab #{whenever_identifier}" }
|
8
9
|
|
9
10
|
# Disable cron jobs at the begining of a deploy.
|
@@ -39,6 +39,8 @@ module Whenever
|
|
39
39
|
write_crontab(whenever_cron)
|
40
40
|
else
|
41
41
|
puts Whenever.cron(@options)
|
42
|
+
puts "[message] Above is your schedule file converted to cron syntax; your crontab file was not updated."
|
43
|
+
puts "[message] Run `whenever --help' for more options."
|
42
44
|
exit(0)
|
43
45
|
end
|
44
46
|
end
|
@@ -87,10 +89,10 @@ module Whenever
|
|
87
89
|
|
88
90
|
def updated_crontab
|
89
91
|
# Check for unopened or unclosed identifier blocks
|
90
|
-
if read_crontab =~ Regexp.new("^#{comment_open}$") && (read_crontab =~ Regexp.new("^#{comment_close}
|
92
|
+
if read_crontab =~ Regexp.new("^#{comment_open}$") && (read_crontab =~ Regexp.new("^#{comment_close}")).nil?
|
91
93
|
warn "[fail] Unclosed indentifier; Your crontab file contains '#{comment_open}', but no '#{comment_close}'"
|
92
94
|
exit(1)
|
93
|
-
elsif (read_crontab =~ Regexp.new("^#{comment_open}$")).nil? && read_crontab =~ Regexp.new("^#{comment_close}
|
95
|
+
elsif (read_crontab =~ Regexp.new("^#{comment_open}$")).nil? && read_crontab =~ Regexp.new("^#{comment_close}")
|
94
96
|
warn "[fail] Unopened indentifier; Your crontab file contains '#{comment_close}', but no '#{comment_open}'"
|
95
97
|
exit(1)
|
96
98
|
end
|
@@ -106,7 +108,11 @@ module Whenever
|
|
106
108
|
end
|
107
109
|
|
108
110
|
def prepare(contents)
|
109
|
-
|
111
|
+
# Some cron implementations require all non-comment lines to be newline-terminated.
|
112
|
+
# Preserve any whitespace at the end of contents. (issue #95)
|
113
|
+
stripped_contents = contents.strip
|
114
|
+
tail = contents[stripped_contents.length..-1]
|
115
|
+
stripped_contents.split("\n")[@options[:cut]..-1].join("\n") + tail
|
110
116
|
end
|
111
117
|
|
112
118
|
def comment_base
|
data/lib/whenever/cron.rb
CHANGED
data/lib/whenever/job_list.rb
CHANGED
data/lib/whenever/setup.rb
CHANGED
@@ -5,7 +5,7 @@ set :path, Whenever.path
|
|
5
5
|
|
6
6
|
# All jobs are wrapped in this template.
|
7
7
|
# http://blog.scoutapp.com/articles/2010/09/07/rvm-and-cron-in-production
|
8
|
-
set :job_template, "/bin/bash -l -c ':job'"
|
8
|
+
set :job_template, "/bin/bash -i -l -c ':job'"
|
9
9
|
|
10
10
|
job_type :command, ":task :output"
|
11
11
|
job_type :rake, "cd :path && RAILS_ENV=:environment rake :task --silent :output"
|
data/lib/whenever/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Whenever
|
2
|
-
VERSION = '0.6.
|
3
|
-
end
|
2
|
+
VERSION = '0.6.6'
|
3
|
+
end
|
@@ -281,8 +281,7 @@ My whenever job that was already here
|
|
281
281
|
# End Whenever generated tasks for: My identifier
|
282
282
|
EXISTING_CRON
|
283
283
|
|
284
|
-
|
285
|
-
assert_equal existing.strip, @command.send(:prepare, existing)
|
284
|
+
assert_equal existing, @command.send(:prepare, existing)
|
286
285
|
end
|
287
286
|
|
288
287
|
should "trim off the top lines of the file" do
|
@@ -302,8 +301,21 @@ My whenever job that was already here
|
|
302
301
|
# End Whenever generated tasks for: My identifier
|
303
302
|
NEW_CRON
|
304
303
|
|
305
|
-
|
306
|
-
|
304
|
+
assert_equal new_cron, @command.send(:prepare, existing)
|
305
|
+
end
|
306
|
+
|
307
|
+
should "preserve terminating newlines in files" do
|
308
|
+
@command = Whenever::CommandLine.new(:update => true, :identifier => 'My identifier')
|
309
|
+
existing = <<-EXISTING_CRON
|
310
|
+
# Begin Whenever generated tasks for: My identifier
|
311
|
+
My whenever job that was already here
|
312
|
+
# End Whenever generated tasks for: My identifier
|
313
|
+
|
314
|
+
# A non-Whenever task
|
315
|
+
My non-whenever job that was already here
|
316
|
+
EXISTING_CRON
|
317
|
+
|
318
|
+
assert_equal existing, @command.send(:prepare, existing)
|
307
319
|
end
|
308
320
|
end
|
309
321
|
|
@@ -248,4 +248,21 @@ class OutputAtTest < Test::Unit::TestCase
|
|
248
248
|
assert_match '27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59 * * * * blahblah', @output
|
249
249
|
end
|
250
250
|
end
|
251
|
+
|
252
|
+
context "using raw cron syntax" do
|
253
|
+
setup do
|
254
|
+
@output = Whenever.cron \
|
255
|
+
<<-file
|
256
|
+
set :job_template, nil
|
257
|
+
every '0 0 27-31 * *' do
|
258
|
+
command "blahblah"
|
259
|
+
end
|
260
|
+
file
|
261
|
+
end
|
262
|
+
|
263
|
+
should "output the command using the same cron syntax" do
|
264
|
+
assert_match '0 0 27-31 * * blahblah', @output
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
251
268
|
end
|
@@ -31,7 +31,7 @@ class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
should "output the command with the default job template" do
|
34
|
-
assert_match /^.+ .+ .+ .+ \/bin\/bash -l -c 'blahblah'$/, @output
|
34
|
+
assert_match /^.+ .+ .+ .+ \/bin\/bash -i -l -c 'blahblah'$/, @output
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -8,6 +8,8 @@ class OutputEnvTest < Test::Unit::TestCase
|
|
8
8
|
<<-file
|
9
9
|
env :MYVAR, 'blah'
|
10
10
|
env 'MAILTO', "someone@example.com"
|
11
|
+
env :BLANKVAR, ''
|
12
|
+
env :NILVAR, nil
|
11
13
|
file
|
12
14
|
end
|
13
15
|
|
@@ -18,6 +20,14 @@ class OutputEnvTest < Test::Unit::TestCase
|
|
18
20
|
should "output MAILTO environment variable" do
|
19
21
|
assert_match "MAILTO=someone@example.com", @output
|
20
22
|
end
|
23
|
+
|
24
|
+
should "output BLANKVAR environment variable" do
|
25
|
+
assert_match "BLANKVAR=\"\"", @output
|
26
|
+
end
|
27
|
+
|
28
|
+
should "output NILVAR environment variable" do
|
29
|
+
assert_match "NILVAR=\"\"", @output
|
30
|
+
end
|
21
31
|
end
|
22
32
|
|
23
|
-
end
|
33
|
+
end
|
data/test/unit/cron_test.rb
CHANGED
@@ -199,6 +199,15 @@ class CronTest < Test::Unit::TestCase
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
end
|
202
|
+
|
203
|
+
context "When given raw cron sytax" do
|
204
|
+
should "return the same cron sytax" do
|
205
|
+
crons = ['0 0 27-31 * *', '* * * * *', '2/3 1,9,22 11-26 1-6 *']
|
206
|
+
crons.each do |cron|
|
207
|
+
assert_equal cron, parse_time(cron)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
202
211
|
|
203
212
|
private
|
204
213
|
|
data/whenever.gemspec
CHANGED
@@ -1,85 +1,22 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "whenever/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
6
|
+
s.name = "whenever"
|
7
|
+
s.version = Whenever::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Javan Makhmali"]
|
10
|
+
s.email = ["javan@javan.us"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Cron jobs in ruby.}
|
13
13
|
s.description = %q{Clean ruby syntax for writing and deploying cron jobs.}
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
s.
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".gitignore",
|
21
|
-
"CHANGELOG.md",
|
22
|
-
"README.md",
|
23
|
-
"Rakefile",
|
24
|
-
"bin/whenever",
|
25
|
-
"bin/wheneverize",
|
26
|
-
"lib/whenever.rb",
|
27
|
-
"lib/whenever/capistrano.rb",
|
28
|
-
"lib/whenever/command_line.rb",
|
29
|
-
"lib/whenever/cron.rb",
|
30
|
-
"lib/whenever/job.rb",
|
31
|
-
"lib/whenever/job_list.rb",
|
32
|
-
"lib/whenever/output_redirection.rb",
|
33
|
-
"lib/whenever/setup.rb",
|
34
|
-
"lib/whenever/version.rb",
|
35
|
-
"test/functional/command_line_test.rb",
|
36
|
-
"test/functional/output_at_test.rb",
|
37
|
-
"test/functional/output_default_defined_jobs_test.rb",
|
38
|
-
"test/functional/output_defined_job_test.rb",
|
39
|
-
"test/functional/output_env_test.rb",
|
40
|
-
"test/functional/output_redirection_test.rb",
|
41
|
-
"test/test_helper.rb",
|
42
|
-
"test/unit/cron_test.rb",
|
43
|
-
"test/unit/job_test.rb",
|
44
|
-
"whenever.gemspec"
|
45
|
-
]
|
46
|
-
s.homepage = %q{http://github.com/javan/whenever}
|
47
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- test/{functional,unit}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
48
17
|
s.require_paths = ["lib"]
|
49
|
-
s.
|
50
|
-
s.
|
51
|
-
s.
|
52
|
-
|
53
|
-
"test/functional/output_at_test.rb",
|
54
|
-
"test/functional/output_default_defined_jobs_test.rb",
|
55
|
-
"test/functional/output_defined_job_test.rb",
|
56
|
-
"test/functional/output_env_test.rb",
|
57
|
-
"test/functional/output_redirection_test.rb",
|
58
|
-
"test/test_helper.rb",
|
59
|
-
"test/unit/cron_test.rb",
|
60
|
-
"test/unit/job_test.rb"
|
61
|
-
]
|
62
|
-
|
63
|
-
if s.respond_to? :specification_version then
|
64
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
65
|
-
s.specification_version = 3
|
66
|
-
|
67
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
|
-
s.add_runtime_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
|
69
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.4"])
|
70
|
-
s.add_development_dependency(%q<shoulda>, [">= 2.1.1"])
|
71
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.5"])
|
72
|
-
else
|
73
|
-
s.add_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
|
74
|
-
s.add_dependency(%q<activesupport>, [">= 2.3.4"])
|
75
|
-
s.add_dependency(%q<shoulda>, [">= 2.1.1"])
|
76
|
-
s.add_dependency(%q<mocha>, [">= 0.9.5"])
|
77
|
-
end
|
78
|
-
else
|
79
|
-
s.add_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
|
80
|
-
s.add_dependency(%q<activesupport>, [">= 2.3.4"])
|
81
|
-
s.add_dependency(%q<shoulda>, [">= 2.1.1"])
|
82
|
-
s.add_dependency(%q<mocha>, [">= 0.9.5"])
|
83
|
-
end
|
18
|
+
s.add_runtime_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
|
19
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.4"])
|
20
|
+
s.add_development_dependency(%q<shoulda>, [">= 2.1.1"])
|
21
|
+
s.add_development_dependency(%q<mocha>, [">= 0.9.5"])
|
84
22
|
end
|
85
|
-
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whenever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 11
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 6
|
10
|
+
version: 0.6.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Javan Makhmali
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-03-08 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -83,17 +83,19 @@ dependencies:
|
|
83
83
|
type: :development
|
84
84
|
version_requirements: *id004
|
85
85
|
description: Clean ruby syntax for writing and deploying cron jobs.
|
86
|
-
email:
|
86
|
+
email:
|
87
|
+
- javan@javan.us
|
87
88
|
executables:
|
88
89
|
- whenever
|
89
90
|
- wheneverize
|
90
91
|
extensions: []
|
91
92
|
|
92
|
-
extra_rdoc_files:
|
93
|
-
|
93
|
+
extra_rdoc_files: []
|
94
|
+
|
94
95
|
files:
|
95
96
|
- .gitignore
|
96
97
|
- CHANGELOG.md
|
98
|
+
- Gemfile
|
97
99
|
- README.md
|
98
100
|
- Rakefile
|
99
101
|
- bin/whenever
|
@@ -118,12 +120,12 @@ files:
|
|
118
120
|
- test/unit/job_test.rb
|
119
121
|
- whenever.gemspec
|
120
122
|
has_rdoc: true
|
121
|
-
homepage:
|
123
|
+
homepage: ""
|
122
124
|
licenses: []
|
123
125
|
|
124
126
|
post_install_message:
|
125
|
-
rdoc_options:
|
126
|
-
|
127
|
+
rdoc_options: []
|
128
|
+
|
127
129
|
require_paths:
|
128
130
|
- lib
|
129
131
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -147,10 +149,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
149
|
requirements: []
|
148
150
|
|
149
151
|
rubyforge_project:
|
150
|
-
rubygems_version: 1.
|
152
|
+
rubygems_version: 1.6.0
|
151
153
|
signing_key:
|
152
154
|
specification_version: 3
|
153
|
-
summary:
|
155
|
+
summary: Cron jobs in ruby.
|
154
156
|
test_files:
|
155
157
|
- test/functional/command_line_test.rb
|
156
158
|
- test/functional/output_at_test.rb
|
@@ -158,6 +160,5 @@ test_files:
|
|
158
160
|
- test/functional/output_defined_job_test.rb
|
159
161
|
- test/functional/output_env_test.rb
|
160
162
|
- test/functional/output_redirection_test.rb
|
161
|
-
- test/test_helper.rb
|
162
163
|
- test/unit/cron_test.rb
|
163
164
|
- test/unit/job_test.rb
|