whenever 0.6.6 → 0.6.7
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.md +7 -0
- data/lib/whenever/command_line.rb +13 -9
- data/lib/whenever/setup.rb +1 -1
- data/lib/whenever/version.rb +1 -1
- data/test/functional/output_default_defined_jobs_test.rb +1 -1
- metadata +5 -5
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
### 0.6.7 / March 23rd, 2011
|
2
|
+
|
3
|
+
* Fix issue with comment block being corrupted during subsequent insertion of duplicate entries to the crontab. #123 [Jeremy (@lingmann)]
|
4
|
+
|
5
|
+
* Removed -i from default job template. #118 [Javan Makhmali]
|
6
|
+
|
7
|
+
|
1
8
|
### 0.6.6 / March 8th, 2011
|
2
9
|
|
3
10
|
* Fix unclosed identifier bug. #119 [Javan Makhmali]
|
@@ -89,30 +89,34 @@ module Whenever
|
|
89
89
|
|
90
90
|
def updated_crontab
|
91
91
|
# Check for unopened or unclosed identifier blocks
|
92
|
-
if read_crontab =~ Regexp.new("^#{comment_open}
|
92
|
+
if read_crontab =~ Regexp.new("^#{comment_open}\s*$") && (read_crontab =~ Regexp.new("^#{comment_close}\s*$")).nil?
|
93
93
|
warn "[fail] Unclosed indentifier; Your crontab file contains '#{comment_open}', but no '#{comment_close}'"
|
94
94
|
exit(1)
|
95
|
-
elsif (read_crontab =~ Regexp.new("^#{comment_open}
|
95
|
+
elsif (read_crontab =~ Regexp.new("^#{comment_open}\s*$")).nil? && read_crontab =~ Regexp.new("^#{comment_close}\s*$")
|
96
96
|
warn "[fail] Unopened indentifier; Your crontab file contains '#{comment_close}', but no '#{comment_open}'"
|
97
97
|
exit(1)
|
98
98
|
end
|
99
99
|
|
100
100
|
# If an existing identier block is found, replace it with the new cron entries
|
101
|
-
if read_crontab =~ Regexp.new("^#{comment_open}
|
101
|
+
if read_crontab =~ Regexp.new("^#{comment_open}\s*$") && read_crontab =~ Regexp.new("^#{comment_close}\s*$")
|
102
102
|
# If the existing crontab file contains backslashes they get lost going through gsub.
|
103
103
|
# .gsub('\\', '\\\\\\') preserves them. Go figure.
|
104
|
-
read_crontab.gsub(Regexp.new("^#{comment_open}
|
104
|
+
read_crontab.gsub(Regexp.new("^#{comment_open}\s*$.+^#{comment_close}\s*$", Regexp::MULTILINE), whenever_cron.chomp.gsub('\\', '\\\\\\'))
|
105
105
|
else # Otherwise, append the new cron entries after any existing ones
|
106
106
|
[read_crontab, whenever_cron].join("\n\n")
|
107
107
|
end.gsub(/\n{3,}/, "\n\n") # More than two newlines becomes just two.
|
108
108
|
end
|
109
109
|
|
110
110
|
def prepare(contents)
|
111
|
-
#
|
112
|
-
#
|
113
|
-
|
114
|
-
|
115
|
-
|
111
|
+
# Strip n lines from the top of the file as specified by the :cut option.
|
112
|
+
# Use split with a -1 limit option to ensure the join is able to rebuild
|
113
|
+
# the file with all of the original seperators in-tact.
|
114
|
+
stripped_contents = contents.split($/,-1)[@options[:cut]..-1].join($/)
|
115
|
+
|
116
|
+
# Some cron implementations require all non-comment lines to be newline-
|
117
|
+
# terminated. (issue #95) Strip all newlines and replace with the default
|
118
|
+
# platform record seperator ($/)
|
119
|
+
stripped_contents.gsub!(/\s+$/, $/)
|
116
120
|
end
|
117
121
|
|
118
122
|
def comment_base
|
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 -
|
8
|
+
set :job_template, "/bin/bash -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
@@ -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 -
|
34
|
+
assert_match /^.+ .+ .+ .+ \/bin\/bash -l -c 'blahblah'$/, @output
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
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:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 7
|
10
|
+
version: 0.6.7
|
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: 2011-03-
|
18
|
+
date: 2011-03-23 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
requirements: []
|
150
150
|
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 1.
|
152
|
+
rubygems_version: 1.4.2
|
153
153
|
signing_key:
|
154
154
|
specification_version: 3
|
155
155
|
summary: Cron jobs in ruby.
|