javan-whenever 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +8 -0
- data/README.rdoc +10 -2
- data/Rakefile +1 -1
- data/lib/outputs/cron.rb +4 -4
- data/lib/version.rb +1 -1
- data/lib/whenever.rb +12 -2
- data/test/cron_test.rb +18 -18
- data/whenever.gemspec +2 -5
- metadata +2 -12
data/CHANGELOG.rdoc
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
+
== 0.3.1 / June 25th, 2009
|
2
|
+
|
3
|
+
* Removed activesupport gem dependency. #1 [Javan Makhmali]
|
4
|
+
|
5
|
+
* Switched to numeric days of the week for Solaris support (and probably others). #8 [Roger Ertesvåg]
|
6
|
+
|
7
|
+
|
1
8
|
== 0.3.0 / June 2nd, 2009
|
2
9
|
|
3
10
|
* Added ability to set variables on the fly from the command line (ex: whenever --set environment=staging). [Javan Makhmali]
|
4
11
|
|
12
|
+
|
5
13
|
== 0.2.2 / April 30th, 2009
|
6
14
|
|
7
15
|
* Days of week jobs can now accept an :at directive (ex: every :monday, :at => '5pm'). [David Eisinger]
|
data/README.rdoc
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Whenever is a Ruby gem that provides a clear syntax for defining cron jobs. It outputs valid cron syntax and can even write your crontab file for you. It is designed to work well with Rails applications and can be deployed with Capistrano. Whenever works fine independently as well.
|
4
4
|
|
5
|
+
Ryan Bates created a great Railscast about Whenever: http://railscasts.com/episodes/164-cron-in-ruby
|
6
|
+
|
7
|
+
Discussion: http://groups.google.com/group/whenever-gem
|
8
|
+
|
5
9
|
== Installation
|
6
10
|
|
7
11
|
Regular (non-Rails) install:
|
@@ -89,15 +93,19 @@ If you wish to simply overwrite your crontab file each time you deploy, use the
|
|
89
93
|
|
90
94
|
By mixing and matching the <code>--load-file</code> and <code>--user</code> options with your various :roles in Capistrano it is entirely possible to deploy different crontab schedules under different users to all your various servers. Get creative!
|
91
95
|
|
96
|
+
If you want to override a variable (like your environment) at the time of deployment you can do so with the <code>--set</code> option: http://wiki.github.com/javan/whenever/setting-variables-on-the-fly
|
97
|
+
|
92
98
|
== Credit
|
93
99
|
|
94
100
|
Whenever was created for use at Inkling (http://inklingmarkets.com) where I work. Their take on it: http://blog.inklingmarkets.com/2009/02/whenever-easy-way-to-do-cron-jobs-from.html
|
95
101
|
|
96
102
|
While building Whenever, I learned a lot by digging through the source code of Capistrano - http://github.com/jamis/capistrano
|
97
103
|
|
98
|
-
== Feedback
|
104
|
+
== Discussion / Feedback / Issues / Bugs
|
105
|
+
|
106
|
+
For general discussion and questions, please use the google group: http://groups.google.com/group/whenever-gem
|
99
107
|
|
100
|
-
|
108
|
+
If you've found a genuine bug or issue, please use the Issues section on github: http://github.com/javan/whenever/issues
|
101
109
|
|
102
110
|
== License
|
103
111
|
|
data/Rakefile
CHANGED
@@ -9,5 +9,5 @@ Echoe.new('whenever', Whenever::VERSION::STRING) do |p|
|
|
9
9
|
p.url = "http://github.com/javan/whenever"
|
10
10
|
p.author = "Javan Makhmali"
|
11
11
|
p.email = "javan@javan.us"
|
12
|
-
p.dependencies = ["chronic >=0.2.3"
|
12
|
+
p.dependencies = ["chronic >=0.2.3"]
|
13
13
|
end
|
data/lib/outputs/cron.rb
CHANGED
@@ -85,11 +85,11 @@ module Whenever
|
|
85
85
|
timing[0] = @at.is_a?(Time) ? @at.min : 0
|
86
86
|
timing[1] = @at.is_a?(Time) ? @at.hour : 0
|
87
87
|
|
88
|
-
return (timing << '
|
89
|
-
return (timing << '
|
88
|
+
return (timing << '1-5') * " " if string.downcase.index('weekday')
|
89
|
+
return (timing << '6,0') * " " if string.downcase.index('weekend')
|
90
90
|
|
91
|
-
%w(sun mon tue wed thu fri sat).
|
92
|
-
return (timing <<
|
91
|
+
%w(sun mon tue wed thu fri sat).each_with_index do |day, i|
|
92
|
+
return (timing << i) * " " if string.downcase.index(day)
|
93
93
|
end
|
94
94
|
|
95
95
|
raise ArgumentError, "Couldn't parse: #{@time}"
|
data/lib/version.rb
CHANGED
data/lib/whenever.rb
CHANGED
@@ -9,10 +9,20 @@ unless defined?(Whenever)
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
# Dependencies
|
13
|
-
require 'activesupport'
|
14
12
|
require 'chronic'
|
15
13
|
|
14
|
+
# If Rails' rakefile was loaded than so was activesupport, but
|
15
|
+
# if this is being used in a non-rails enviroment we need to require it.
|
16
|
+
# It was previously defined as a dependency of this gem, but that became
|
17
|
+
# problematic. See: http://github.com/javan/whenever/issues#issue/1
|
18
|
+
begin
|
19
|
+
require 'activesupport'
|
20
|
+
rescue LoadError => e
|
21
|
+
warn 'To user Whenever you need the activesupport gem:'
|
22
|
+
warn '$ sudo gem install activesupport'
|
23
|
+
exit(1)
|
24
|
+
end
|
25
|
+
|
16
26
|
# Whenever files
|
17
27
|
%w{
|
18
28
|
base
|
data/test/cron_test.rb
CHANGED
@@ -136,13 +136,13 @@ class CronTest < Test::Unit::TestCase
|
|
136
136
|
context "When parsing time in days (of week)" do
|
137
137
|
should "parse days of the week correctly" do
|
138
138
|
{
|
139
|
-
'
|
140
|
-
'
|
141
|
-
'
|
142
|
-
'
|
143
|
-
'
|
144
|
-
'
|
145
|
-
'
|
139
|
+
'0' => %w(sun Sunday SUNDAY SUN),
|
140
|
+
'1' => %w(mon Monday MONDAY MON),
|
141
|
+
'2' => %w(tue tues Tuesday TUESDAY TUE),
|
142
|
+
'3' => %w(wed Wednesday WEDNESDAY WED),
|
143
|
+
'4' => %w(thu thurs thur Thursday THURSDAY THU),
|
144
|
+
'5' => %w(fri Friday FRIDAY FRI),
|
145
|
+
'6' => %w(sat Saturday SATURDAY SAT)
|
146
146
|
}.each do |day, day_tests|
|
147
147
|
day_tests.each do |day_test|
|
148
148
|
assert_equal "0 0 * * #{day}", parse_time(day_test)
|
@@ -151,23 +151,23 @@ class CronTest < Test::Unit::TestCase
|
|
151
151
|
end
|
152
152
|
|
153
153
|
should "allow additional directives" do
|
154
|
-
assert_equal '30 13 * *
|
155
|
-
assert_equal '22 2 * *
|
156
|
-
assert_equal '55 17 * *
|
154
|
+
assert_equal '30 13 * * 5', parse_time('friday', nil, "1:30 pm")
|
155
|
+
assert_equal '22 2 * * 1', parse_time('Monday', nil, "2:22am")
|
156
|
+
assert_equal '55 17 * * 4', parse_time('THU', nil, "5:55PM")
|
157
157
|
end
|
158
158
|
|
159
159
|
should "parse weekday correctly" do
|
160
|
-
assert_equal '0 0 * *
|
161
|
-
assert_equal '0 0 * *
|
162
|
-
assert_equal '0 1 * *
|
163
|
-
assert_equal '59 5 * *
|
160
|
+
assert_equal '0 0 * * 1-5', parse_time('weekday')
|
161
|
+
assert_equal '0 0 * * 1-5', parse_time('Weekdays')
|
162
|
+
assert_equal '0 1 * * 1-5', parse_time('Weekdays', nil, "1:00 am")
|
163
|
+
assert_equal '59 5 * * 1-5', parse_time('Weekdays', nil, "5:59 am")
|
164
164
|
end
|
165
165
|
|
166
166
|
should "parse weekend correctly" do
|
167
|
-
assert_equal '0 0 * *
|
168
|
-
assert_equal '0 0 * *
|
169
|
-
assert_equal '0 7 * *
|
170
|
-
assert_equal '2 18 * *
|
167
|
+
assert_equal '0 0 * * 6,0', parse_time('weekend')
|
168
|
+
assert_equal '0 0 * * 6,0', parse_time('Weekends')
|
169
|
+
assert_equal '0 7 * * 6,0', parse_time('Weekends', nil, "7am")
|
170
|
+
assert_equal '2 18 * * 6,0', parse_time('Weekends', nil, "6:02PM")
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
data/whenever.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{whenever}
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Javan Makhmali"]
|
9
|
-
s.date = %q{2009-06-
|
9
|
+
s.date = %q{2009-06-25}
|
10
10
|
s.description = %q{Provides clean ruby syntax for defining messy cron jobs and running them Whenever.}
|
11
11
|
s.email = %q{javan@javan.us}
|
12
12
|
s.executables = ["whenever", "wheneverize"]
|
@@ -27,13 +27,10 @@ Gem::Specification.new do |s|
|
|
27
27
|
|
28
28
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
29
|
s.add_runtime_dependency(%q<chronic>, [">= 0.2.3"])
|
30
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 1.3.0"])
|
31
30
|
else
|
32
31
|
s.add_dependency(%q<chronic>, [">= 0.2.3"])
|
33
|
-
s.add_dependency(%q<activesupport>, [">= 1.3.0"])
|
34
32
|
end
|
35
33
|
else
|
36
34
|
s.add_dependency(%q<chronic>, [">= 0.2.3"])
|
37
|
-
s.add_dependency(%q<activesupport>, [">= 1.3.0"])
|
38
35
|
end
|
39
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: javan-whenever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javan Makhmali
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-25 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,16 +22,6 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 0.2.3
|
24
24
|
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: activesupport
|
27
|
-
type: :runtime
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.3.0
|
34
|
-
version:
|
35
25
|
description: Provides clean ruby syntax for defining messy cron jobs and running them Whenever.
|
36
26
|
email: javan@javan.us
|
37
27
|
executables:
|