whenever 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### 0.7.2 / December 23rd, 2011
2
+
3
+ * Accept @reboot and friends as raw cron syntax. [Felix Buenemann]
4
+
5
+ * Fix clear_crontab task so it will work both standalone and during deploy. [Justin Giancola]
6
+
7
+
1
8
  ### 0.7.1 / December 19th, 2011
2
9
 
3
10
  * Require thread before active_support for compatibility with Rails < 2.3.11 and RubyGems >= 1.6.0. [Micah Geisel]
@@ -58,7 +58,7 @@ Capistrano::Configuration.instance(:must_exist).load do
58
58
  DESC
59
59
  task :clear_crontab do
60
60
  options = fetch(:whenever_options)
61
- run "cd #{fetch :current_path} && #{fetch :whenever_command} #{fetch :whenever_clear_flags}", options if find_servers(options).any?
61
+ run "cd #{fetch :latest_release} && #{fetch :whenever_command} #{fetch :whenever_clear_flags}", options if find_servers(options).any?
62
62
  end
63
63
  end
64
64
  end
data/lib/whenever/cron.rb CHANGED
@@ -3,7 +3,8 @@ require 'chronic'
3
3
  module Whenever
4
4
  module Output
5
5
  class Cron
6
- REGEX = /^.+ .+ .+ .+ .+.?$/
6
+ KEYWORDS = [:reboot, :yearly, :annually, :monthly, :weekly, :daily, :midnight, :hourly]
7
+ REGEX = /^(@(#{KEYWORDS.join '|'})|.+ .+ .+ .+ .+.?)$/
7
8
 
8
9
  attr_accessor :time, :task
9
10
 
@@ -52,25 +53,18 @@ module Whenever
52
53
 
53
54
  protected
54
55
  def day_given?
55
- months = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
56
+ months = %w(jan feb mar apr may jun jul aug sep oct nov dec)
56
57
  @at_given.is_a?(String) && months.any? { |m| @at_given.downcase.index(m) }
57
58
  end
58
59
 
59
60
  def parse_symbol
60
61
  shortcut = case @time
61
- when :reboot then '@reboot'
62
+ when *KEYWORDS then "@#{@time}" # :reboot => '@reboot'
62
63
  when :year then 12.months
63
- when :yearly,
64
- :annually then '@annually'
65
64
  when :day then 1.day
66
- when :daily then '@daily'
67
- when :midnight then '@midnight'
68
65
  when :month then 1.month
69
- when :monthly then '@monthly'
70
66
  when :week then 1.week
71
- when :weekly then '@weekly'
72
67
  when :hour then 1.hour
73
- when :hourly then '@hourly'
74
68
  end
75
69
 
76
70
  if shortcut.is_a?(Numeric)
@@ -1,3 +1,3 @@
1
1
  module Whenever
2
- VERSION = '0.7.1'
2
+ VERSION = '0.7.2'
3
3
  end
@@ -184,7 +184,7 @@ class CronTest < Test::Unit::TestCase
184
184
  should "parse a :symbol into the correct shortcut" do
185
185
  assert_equal '@reboot', parse_time(:reboot)
186
186
  assert_equal '@annually', parse_time(:annually)
187
- assert_equal '@annually', parse_time(:yearly)
187
+ assert_equal '@yearly', parse_time(:yearly)
188
188
  assert_equal '@daily', parse_time(:daily)
189
189
  assert_equal '@midnight', parse_time(:midnight)
190
190
  assert_equal '@monthly', parse_time(:monthly)
@@ -217,7 +217,9 @@ class CronTest < Test::Unit::TestCase
217
217
 
218
218
  context "When given raw cron sytax" do
219
219
  should "return the same cron sytax" do
220
- crons = ['0 0 27-31 * *', '* * * * *', '2/3 1,9,22 11-26 1-6 *']
220
+ crons = ['0 0 27-31 * *', '* * * * *', '2/3 1,9,22 11-26 1-6 *',
221
+ '@reboot', '@yearly', '@annually', '@monthly', '@weekly',
222
+ '@daily', '@midnight', '@hourly']
221
223
  crons.each do |cron|
222
224
  assert_equal cron, parse_time(cron)
223
225
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whenever
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-20 00:00:00.000000000 Z
12
+ date: 2011-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chronic
16
- requirement: &70096166103200 !ruby/object:Gem::Requirement
16
+ requirement: &70249786924020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.6.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70096166103200
24
+ version_requirements: *70249786924020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70096166102060 !ruby/object:Gem::Requirement
27
+ requirement: &70249786922720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.3.4
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70096166102060
35
+ version_requirements: *70249786922720
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: shoulda
38
- requirement: &70096166100840 !ruby/object:Gem::Requirement
38
+ requirement: &70249786921560 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.1.1
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70096166100840
46
+ version_requirements: *70249786921560
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mocha
49
- requirement: &70096166076460 !ruby/object:Gem::Requirement
49
+ requirement: &70249786898020 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.9.5
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70096166076460
57
+ version_requirements: *70249786898020
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70096166074280 !ruby/object:Gem::Requirement
60
+ requirement: &70249786895900 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70096166074280
68
+ version_requirements: *70249786895900
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: i18n
71
- requirement: &70096166071760 !ruby/object:Gem::Requirement
71
+ requirement: &70249786893560 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70096166071760
79
+ version_requirements: *70249786893560
80
80
  description: Clean ruby syntax for writing and deploying cron jobs.
81
81
  email:
82
82
  - javan@javan.us