jlw-whenever 0.3.1.1 → 0.3.1.2
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 +5 -0
- data/lib/outputs/cron.rb +1 -1
- data/test/cron_test.rb +10 -6
- data/test/output_rake_test.rb +4 -4
- data/test/test_helper.rb +1 -1
- data/whenever.gemspec +1 -1
- metadata +1 -1
data/CHANGELOG.rdoc
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
== 0.3.1.2 / June 19, 2009
|
|
2
|
+
|
|
3
|
+
* Limited */5 syntax to minutes and hours. [Jeremy Weathers]
|
|
4
|
+
* Updated tests to pass with my changes. [Jeremy Weathers]
|
|
5
|
+
|
|
1
6
|
== 0.3.1 / June 19, 2009
|
|
2
7
|
|
|
3
8
|
* Added --silent flag to rake tasks so cron output emails aren't generated if the task doesn't have any output. [Jeremy Weathers]
|
data/lib/outputs/cron.rb
CHANGED
|
@@ -100,7 +100,7 @@ module Whenever
|
|
|
100
100
|
return '*' if frequency == 1
|
|
101
101
|
return frequency if frequency > (max * 0.5).ceil
|
|
102
102
|
|
|
103
|
-
return "*/#{frequency}" if 0 ==
|
|
103
|
+
return "*/#{frequency}" if 0 == start && 0 == (max + 1) % frequency # only for hours & minutes
|
|
104
104
|
|
|
105
105
|
original_start = start
|
|
106
106
|
|
data/test/cron_test.rb
CHANGED
|
@@ -16,9 +16,9 @@ class CronTest < Test::Unit::TestCase
|
|
|
16
16
|
# For santity, do some tests on straight String
|
|
17
17
|
should "parse correctly" do
|
|
18
18
|
assert_equal '* * * * *', parse_time(1.minute)
|
|
19
|
-
assert_equal '
|
|
19
|
+
assert_equal '*/5 * * * *', parse_time(5.minutes)
|
|
20
20
|
assert_equal '7,14,21,28,35,42,49,56 * * * *', parse_time(7.minutes)
|
|
21
|
-
assert_equal '
|
|
21
|
+
assert_equal '*/30 * * * *', parse_time(30.minutes)
|
|
22
22
|
assert_equal '32 * * * *', parse_time(32.minutes)
|
|
23
23
|
assert_not_equal '60 * * * *', parse_time(60.minutes) # 60 minutes bumps up into the hour range
|
|
24
24
|
end
|
|
@@ -30,7 +30,9 @@ class CronTest < Test::Unit::TestCase
|
|
|
30
30
|
start += num unless 60.modulo(num).zero?
|
|
31
31
|
minutes = (start..59).step(num).to_a
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
expected = [2,3,4,5,6,10,12,15,20,30].include?(num) ? "*/#{num} * * * *" : "#{minutes.join(',')} * * * *"
|
|
34
|
+
|
|
35
|
+
assert_equal expected, parse_time(num.minutes)
|
|
34
36
|
end
|
|
35
37
|
end
|
|
36
38
|
end
|
|
@@ -38,8 +40,8 @@ class CronTest < Test::Unit::TestCase
|
|
|
38
40
|
context "When parsing time in hours" do
|
|
39
41
|
should "parse correctly" do
|
|
40
42
|
assert_equal '0 * * * *', parse_time(1.hour)
|
|
41
|
-
assert_equal '0
|
|
42
|
-
assert_equal '0
|
|
43
|
+
assert_equal '0 */2 * * *', parse_time(2.hours)
|
|
44
|
+
assert_equal '0 */3 * * *', parse_time(3.hours)
|
|
43
45
|
assert_equal '0 5,10,15,20 * * *', parse_time(5.hours)
|
|
44
46
|
assert_equal '0 17 * * *', parse_time(17.hours)
|
|
45
47
|
assert_not_equal '0 24 * * *', parse_time(24.hours) # 24 hours bumps up into the day range
|
|
@@ -51,7 +53,9 @@ class CronTest < Test::Unit::TestCase
|
|
|
51
53
|
start += num unless 24.modulo(num).zero?
|
|
52
54
|
hours = (start..23).step(num).to_a
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
expected = [2,3,4,6,8,12].include?(num) ? "0 */#{num} * * *" : "0 #{hours.join(',')} * * *"
|
|
57
|
+
|
|
58
|
+
assert_equal expected, parse_time(num.hours)
|
|
55
59
|
end
|
|
56
60
|
end
|
|
57
61
|
|
data/test/output_rake_test.rb
CHANGED
|
@@ -17,7 +17,7 @@ class OutputRakeTest < Test::Unit::TestCase
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
should "output the rake command using that path" do
|
|
20
|
-
assert_match two_hours + ' cd /my/path && RAILS_ENV=production /usr/bin/env rake blahblah', @output
|
|
20
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=production /usr/bin/env rake --silent blahblah', @output
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -33,7 +33,7 @@ class OutputRakeTest < Test::Unit::TestCase
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
should "output the rake command using that path" do
|
|
36
|
-
assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production /usr/bin/env rake blahblah', @output
|
|
36
|
+
assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production /usr/bin/env rake --silent blahblah', @output
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -50,7 +50,7 @@ class OutputRakeTest < Test::Unit::TestCase
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
should "output the rake command using that environment" do
|
|
53
|
-
assert_match two_hours + ' cd /my/path && RAILS_ENV=silly /usr/bin/env rake blahblah', @output
|
|
53
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=silly /usr/bin/env rake --silent blahblah', @output
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -67,7 +67,7 @@ class OutputRakeTest < Test::Unit::TestCase
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
should "output the rake command using that environment" do
|
|
70
|
-
assert_match two_hours + ' cd /my/path && RAILS_ENV=serious /usr/bin/env rake blahblah', @output
|
|
70
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=serious /usr/bin/env rake --silent blahblah', @output
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
data/test/test_helper.rb
CHANGED
data/whenever.gemspec
CHANGED