whenever 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -0
- data/lib/whenever/command_line.rb +7 -6
- data/lib/whenever/version.rb +1 -1
- data/test/functional/command_line_test.rb +40 -2
- data/whenever.gemspec +4 -4
- metadata +17 -4
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.5.3 / September 24th, 2010
|
2
|
+
|
3
|
+
* Better regexes for replacing Whenever blocks in the crontab. #45 [Javan Makhmali]
|
4
|
+
|
5
|
+
* Preserving backslashes when updating existing crontab. #82 [Javan Makhmali]
|
6
|
+
|
7
|
+
|
1
8
|
== 0.5.2 / September 15th, 2010
|
2
9
|
|
3
10
|
* Quotes automatically escaped in jobs. [Jay Adkisson]
|
@@ -85,25 +85,26 @@ module Whenever
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
def updated_crontab
|
88
|
+
def updated_crontab
|
89
89
|
# Check for unopened or unclosed identifier blocks
|
90
|
-
if read_crontab.
|
90
|
+
if read_crontab =~ Regexp.new("^#{comment_open}$") && (read_crontab =~ Regexp.new("^#{comment_close}$")).nil?
|
91
91
|
warn "[fail] Unclosed indentifier; Your crontab file contains '#{comment_open}', but no '#{comment_close}'"
|
92
92
|
exit(1)
|
93
|
-
elsif
|
93
|
+
elsif (read_crontab =~ Regexp.new("^#{comment_open}$")).nil? && read_crontab =~ Regexp.new("^#{comment_close}$")
|
94
94
|
warn "[fail] Unopened indentifier; Your crontab file contains '#{comment_close}', but no '#{comment_open}'"
|
95
95
|
exit(1)
|
96
96
|
end
|
97
97
|
|
98
98
|
# If an existing identier block is found, replace it with the new cron entries
|
99
|
-
if read_crontab.
|
100
|
-
|
99
|
+
if read_crontab =~ Regexp.new("^#{comment_open}$") && read_crontab =~ Regexp.new("^#{comment_close}$")
|
100
|
+
# If the existing crontab file contains backslashes they get lost going through gsub.
|
101
|
+
# .gsub('\\', '\\\\\\') preserves them. Go figure.
|
102
|
+
read_crontab.gsub(Regexp.new("^#{comment_open}$.+^#{comment_close}$", Regexp::MULTILINE), whenever_cron.chomp.gsub('\\', '\\\\\\'))
|
101
103
|
else # Otherwise, append the new cron entries after any existing ones
|
102
104
|
[read_crontab, whenever_cron].join("\n\n")
|
103
105
|
end
|
104
106
|
end
|
105
107
|
|
106
|
-
#
|
107
108
|
def prepare(contents)
|
108
109
|
contents.split("\n")[@options[:cut]..-1].join("\n")
|
109
110
|
end
|
data/lib/whenever/version.rb
CHANGED
@@ -65,8 +65,6 @@ This shouldn't get replaced
|
|
65
65
|
# End Whenever generated tasks for: Other identifier
|
66
66
|
EXISTING_CRON
|
67
67
|
|
68
|
-
@command.expects(:read_crontab).at_least_once.returns(existing)
|
69
|
-
|
70
68
|
new_cron = <<-NEW_CRON
|
71
69
|
# Something
|
72
70
|
|
@@ -79,12 +77,52 @@ This shouldn't get replaced
|
|
79
77
|
# End Whenever generated tasks for: Other identifier
|
80
78
|
NEW_CRON
|
81
79
|
|
80
|
+
@command.expects(:read_crontab).at_least_once.returns(existing)
|
82
81
|
assert_equal new_cron, @command.send(:updated_crontab)
|
83
82
|
|
84
83
|
@command.expects(:write_crontab).with(new_cron).returns(true)
|
85
84
|
assert @command.run
|
86
85
|
end
|
87
86
|
end
|
87
|
+
|
88
|
+
context "A command line update that contains backslashes" do
|
89
|
+
setup do
|
90
|
+
@existing = <<-EXISTING_CRON
|
91
|
+
# Begin Whenever generated tasks for: My identifier
|
92
|
+
script/runner -e production 'puts '\\''hello'\\'''
|
93
|
+
# End Whenever generated tasks for: My identifier
|
94
|
+
EXISTING_CRON
|
95
|
+
File.expects(:exists?).with('config/schedule.rb').returns(true)
|
96
|
+
@command = Whenever::CommandLine.new(:update => true, :identifier => 'My identifier')
|
97
|
+
@command.expects(:read_crontab).at_least_once.returns(@existing)
|
98
|
+
@command.expects(:whenever_cron).returns(@existing)
|
99
|
+
end
|
100
|
+
|
101
|
+
should "replace the existing block with the backslashes in tact" do
|
102
|
+
assert_equal @existing, @command.send(:updated_crontab)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "A command line update with an identifier similar to an existing one in the crontab already" do
|
107
|
+
setup do
|
108
|
+
@existing = <<-EXISTING_CRON
|
109
|
+
# Begin Whenever generated tasks for: WheneverExisting
|
110
|
+
# End Whenever generated tasks for: WheneverExisting
|
111
|
+
EXISTING_CRON
|
112
|
+
@new = <<-NEW_CRON
|
113
|
+
# Begin Whenever generated tasks for: Whenever
|
114
|
+
# End Whenever generated tasks for: Whenever
|
115
|
+
NEW_CRON
|
116
|
+
File.expects(:exists?).with('config/schedule.rb').returns(true)
|
117
|
+
@command = Whenever::CommandLine.new(:update => true, :identifier => 'Whenever')
|
118
|
+
@command.expects(:read_crontab).at_least_once.returns(@existing)
|
119
|
+
@command.expects(:whenever_cron).returns(@new)
|
120
|
+
end
|
121
|
+
|
122
|
+
should "append the similarly named command" do
|
123
|
+
assert_equal @existing + "\n\n" + @new, @command.send(:updated_crontab)
|
124
|
+
end
|
125
|
+
end
|
88
126
|
|
89
127
|
context "A command line delete" do
|
90
128
|
setup do
|
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.5.
|
8
|
+
s.version = "0.5.3"
|
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-09-
|
12
|
+
s.date = %q{2010-09-24}
|
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"]
|
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
|
|
46
46
|
s.homepage = %q{http://github.com/javan/whenever}
|
47
47
|
s.rdoc_options = ["--charset=UTF-8"]
|
48
48
|
s.require_paths = ["lib"]
|
49
|
-
s.rubygems_version = %q{1.3.
|
49
|
+
s.rubygems_version = %q{1.3.7}
|
50
50
|
s.summary = %q{Clean ruby syntax for defining and deploying messy cron jobs.}
|
51
51
|
s.test_files = [
|
52
52
|
"test/functional/command_line_test.rb",
|
@@ -64,7 +64,7 @@ Gem::Specification.new do |s|
|
|
64
64
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
65
65
|
s.specification_version = 3
|
66
66
|
|
67
|
-
if Gem::Version.new(Gem::
|
67
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
68
|
s.add_runtime_dependency(%q<aaronh-chronic>, [">= 0.3.9"])
|
69
69
|
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.4"])
|
70
70
|
s.add_development_dependency(%q<shoulda>, [">= 2.1.1"])
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whenever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 13
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
9
|
+
- 3
|
10
|
+
version: 0.5.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Javan Makhmali
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-24 00:00:00 -04:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: aaronh-chronic
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 1
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
- 3
|
@@ -35,9 +38,11 @@ dependencies:
|
|
35
38
|
name: activesupport
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ">="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 11
|
41
46
|
segments:
|
42
47
|
- 2
|
43
48
|
- 3
|
@@ -49,9 +54,11 @@ dependencies:
|
|
49
54
|
name: shoulda
|
50
55
|
prerelease: false
|
51
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
52
58
|
requirements:
|
53
59
|
- - ">="
|
54
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 9
|
55
62
|
segments:
|
56
63
|
- 2
|
57
64
|
- 1
|
@@ -63,9 +70,11 @@ dependencies:
|
|
63
70
|
name: mocha
|
64
71
|
prerelease: false
|
65
72
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
66
74
|
requirements:
|
67
75
|
- - ">="
|
68
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 49
|
69
78
|
segments:
|
70
79
|
- 0
|
71
80
|
- 9
|
@@ -118,23 +127,27 @@ rdoc_options:
|
|
118
127
|
require_paths:
|
119
128
|
- lib
|
120
129
|
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
121
131
|
requirements:
|
122
132
|
- - ">="
|
123
133
|
- !ruby/object:Gem::Version
|
134
|
+
hash: 3
|
124
135
|
segments:
|
125
136
|
- 0
|
126
137
|
version: "0"
|
127
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
128
140
|
requirements:
|
129
141
|
- - ">="
|
130
142
|
- !ruby/object:Gem::Version
|
143
|
+
hash: 3
|
131
144
|
segments:
|
132
145
|
- 0
|
133
146
|
version: "0"
|
134
147
|
requirements: []
|
135
148
|
|
136
149
|
rubyforge_project:
|
137
|
-
rubygems_version: 1.3.
|
150
|
+
rubygems_version: 1.3.7
|
138
151
|
signing_key:
|
139
152
|
specification_version: 3
|
140
153
|
summary: Clean ruby syntax for defining and deploying messy cron jobs.
|