rufus-scheduler 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +6 -0
- data/CREDITS.txt +5 -0
- data/README.md +33 -1
- data/lib/rufus/scheduler.rb +1 -1
- data/lib/rufus/scheduler/cronline.rb +3 -3
- data/lib/rufus/scheduler/util.rb +31 -21
- data/rufus-scheduler.gemspec +1 -1
- data/spec/cronline_spec.rb +9 -2
- data/spec/parse_spec.rb +16 -0
- data/spec/threads_spec.rb +21 -0
- metadata +38 -38
data/CHANGELOG.txt
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
= rufus-scheduler CHANGELOG.txt
|
3
3
|
|
4
4
|
|
5
|
+
== rufus-scheduler - 3.0.1 not yet released
|
6
|
+
|
7
|
+
- fix post_install_message, thanks Ted Pennings
|
8
|
+
- bring back .parse_time_string and .parse_duration_string
|
9
|
+
|
10
|
+
|
5
11
|
== rufus-scheduler - 3.0.0 released 2013/10/02
|
6
12
|
|
7
13
|
- complete rewrite.
|
data/CREDITS.txt
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
== Contributors
|
6
6
|
|
7
|
+
- Ted Pennings (https://github.com/tedpennings) typo in post_install_message
|
7
8
|
- Tobias Kraze (https://github.com/kratob) timeout vs mutex fix
|
8
9
|
- Patrick Farrell (https://github.com/pfarrell) pointing at deprecated start_new
|
9
10
|
- Thomas Sevestre (https://github.com/thomassevestre) :exception option
|
@@ -27,6 +28,9 @@
|
|
27
28
|
|
28
29
|
== Feedback
|
29
30
|
|
31
|
+
- Gatis Tomsons - https://github.io/gacha - heavy duty work threads
|
32
|
+
- https://github.com/joast - missing .to_time_string alias (code and doc)
|
33
|
+
- Tamir Duberstein - https://github.com/tamird - rdoc inaccuracies
|
30
34
|
- Kevin Bouwkamp - https://github.com/bmxpert1 - first_at issues
|
31
35
|
- Daniel Beauchamp - https://github.com/pushmatrix - pre/post trigger callbacks
|
32
36
|
- Arthur Maltson - https://github.com/amaltson - readme fixes
|
@@ -60,5 +64,6 @@
|
|
60
64
|
|
61
65
|
== and finally
|
62
66
|
|
67
|
+
- many thanks to the author and contributors of the tzinfo gem (http://tzinfo.github.io/)
|
63
68
|
- many thanks to the EventMachine team (especially Aman Gupta)
|
64
69
|
|
data/README.md
CHANGED
@@ -78,7 +78,7 @@ There is no EventMachine-based scheduler anymore.
|
|
78
78
|
* The scheduler isn't catching the whole of Exception anymore, only StandardError
|
79
79
|
* The error_handler is #on_error (instead of #on_exception), by default it now prints the details of the error to $stderr (used to be $stdout)
|
80
80
|
* Rufus::Scheduler::TimeOutError renamed to Rufus::Scheduler::TimeoutError
|
81
|
-
* Introduction of "interval" jobs. Whereas "every" jobs are like "every 10
|
81
|
+
* Introduction of "interval" jobs. Whereas "every" jobs are like "every 10 minutes, do this", interval jobs are like "do that, then wait for 10 minutes, then do that again, and so on"
|
82
82
|
* Introduction of a :lockfile => true/filename mechanism to prevent multiple schedulers from executing
|
83
83
|
* "discard_past" is on by default. If the scheduler (its host) sleeps for 1 hour and a ```every '10m'``` job is on, it will trigger once at wakeup, not 6 times (discard_past was false by default in rufus-scheduler 2.x). No intention to re-introduce ```:discard_past => false``` in 3.0 for now.
|
84
84
|
* Introduction of Scheduler #on_pre_trigger and #on_post_trigger callback points
|
@@ -1052,6 +1052,38 @@ Rufus::Scheduler.to_duration_hash(62.127, :drop_seconds => true)
|
|
1052
1052
|
# => { :m => 1 }
|
1053
1053
|
```
|
1054
1054
|
|
1055
|
+
## a note about timezones
|
1056
|
+
|
1057
|
+
Cron schedules and at schedules support the specification of a timezone.
|
1058
|
+
|
1059
|
+
```ruby
|
1060
|
+
scheduler.cron '0 22 * * 1-5 America/Chicago' do
|
1061
|
+
# the job...
|
1062
|
+
end
|
1063
|
+
|
1064
|
+
scheduler.at '2013-12-12 14:00 Pacific/Samoa' do
|
1065
|
+
puts "it's tea time!"
|
1066
|
+
end
|
1067
|
+
|
1068
|
+
# or even
|
1069
|
+
|
1070
|
+
Rufus::Scheduler.parse("2013-12-12 14:00 Pacific/Saipan")
|
1071
|
+
# => 2013-12-12 04:00:00 UTC
|
1072
|
+
```
|
1073
|
+
|
1074
|
+
Behind the scenes, rufus-scheduler uses [tzinfo](http://tzinfo.github.io/) to deal with timezones.
|
1075
|
+
|
1076
|
+
Here is a [list of timezones](misc/tz_all.txt) known to my Debian GNU/Linux 7. It was generated with this script:
|
1077
|
+
|
1078
|
+
```ruby
|
1079
|
+
require 'tzinfo'
|
1080
|
+
TZInfo::Timezone.all.each { |tz| puts tz.name }
|
1081
|
+
```
|
1082
|
+
|
1083
|
+
Unknown timezones, typos, will be rejected by tzinfo thus rufus-scheduler.
|
1084
|
+
|
1085
|
+
On its own tzinfo derives the timezones from the system's information. On some system it needs some help, one can install the 'tzinfo-data' gem to provide the missing information.
|
1086
|
+
|
1055
1087
|
|
1056
1088
|
## support
|
1057
1089
|
|
data/lib/rufus/scheduler.rb
CHANGED
@@ -106,15 +106,15 @@ class Rufus::Scheduler
|
|
106
106
|
# be passed if no start time is specified (search start time set to
|
107
107
|
# Time.now))
|
108
108
|
#
|
109
|
-
# Rufus::CronLine.new('30 7 * * *').next_time(
|
109
|
+
# Rufus::Scheduler::CronLine.new('30 7 * * *').next_time(
|
110
110
|
# Time.mktime(2008, 10, 24, 7, 29))
|
111
111
|
# #=> Fri Oct 24 07:30:00 -0500 2008
|
112
112
|
#
|
113
|
-
# Rufus::CronLine.new('30 7 * * *').next_time(
|
113
|
+
# Rufus::Scheduler::CronLine.new('30 7 * * *').next_time(
|
114
114
|
# Time.utc(2008, 10, 24, 7, 29))
|
115
115
|
# #=> Fri Oct 24 07:30:00 UTC 2008
|
116
116
|
#
|
117
|
-
# Rufus::CronLine.new('30 7 * * *').next_time(
|
117
|
+
# Rufus::Scheduler::CronLine.new('30 7 * * *').next_time(
|
118
118
|
# Time.utc(2008, 10, 24, 7, 29)).localtime
|
119
119
|
# #=> Fri Oct 24 02:30:00 -0500 2008
|
120
120
|
#
|
data/lib/rufus/scheduler/util.rb
CHANGED
@@ -133,17 +133,17 @@ module Rufus
|
|
133
133
|
#
|
134
134
|
# Some examples:
|
135
135
|
#
|
136
|
-
# Rufus::Scheduler.
|
137
|
-
# Rufus::Scheduler.
|
138
|
-
# Rufus::Scheduler.
|
139
|
-
# Rufus::Scheduler.
|
140
|
-
# Rufus::Scheduler.
|
141
|
-
# Rufus::Scheduler.
|
136
|
+
# Rufus::Scheduler.parse_duration "0.5" # => 0.5
|
137
|
+
# Rufus::Scheduler.parse_duration "500" # => 0.5
|
138
|
+
# Rufus::Scheduler.parse_duration "1000" # => 1.0
|
139
|
+
# Rufus::Scheduler.parse_duration "1h" # => 3600.0
|
140
|
+
# Rufus::Scheduler.parse_duration "1h10s" # => 3610.0
|
141
|
+
# Rufus::Scheduler.parse_duration "1w2d" # => 777600.0
|
142
142
|
#
|
143
143
|
# Negative time strings are OK (Thanks Danny Fullerton):
|
144
144
|
#
|
145
|
-
# Rufus::Scheduler.
|
146
|
-
# Rufus::Scheduler.
|
145
|
+
# Rufus::Scheduler.parse_duration "-0.5" # => -0.5
|
146
|
+
# Rufus::Scheduler.parse_duration "-1h" # => -3600.0
|
147
147
|
#
|
148
148
|
def self.parse_duration(string, opts={})
|
149
149
|
|
@@ -183,13 +183,22 @@ module Rufus
|
|
183
183
|
mod * val
|
184
184
|
end
|
185
185
|
|
186
|
+
class << self
|
187
|
+
#-
|
188
|
+
# for compatibility with rufus-scheduler 2.x
|
189
|
+
#+
|
190
|
+
alias parse_duration_string parse_duration
|
191
|
+
alias parse_time_string parse_duration
|
192
|
+
end
|
193
|
+
|
194
|
+
|
186
195
|
# Turns a number of seconds into a a time string
|
187
196
|
#
|
188
|
-
# Rufus.
|
189
|
-
# Rufus.
|
190
|
-
# Rufus.
|
191
|
-
# Rufus.
|
192
|
-
# Rufus.
|
197
|
+
# Rufus.to_duration 0 # => '0s'
|
198
|
+
# Rufus.to_duration 60 # => '1m'
|
199
|
+
# Rufus.to_duration 3661 # => '1h1m1s'
|
200
|
+
# Rufus.to_duration 7 * 24 * 3600 # => '1w'
|
201
|
+
# Rufus.to_duration 30 * 24 * 3600 + 1 # => "4w2d1s"
|
193
202
|
#
|
194
203
|
# It goes from seconds to the year. Months are not counted (as they
|
195
204
|
# are of variable length). Weeks are counted.
|
@@ -197,16 +206,14 @@ module Rufus
|
|
197
206
|
# For 30 days months to be counted, the second parameter of this
|
198
207
|
# method can be set to true.
|
199
208
|
#
|
200
|
-
# Rufus.
|
201
|
-
#
|
202
|
-
# (to_time_string is an alias for to_duration_string)
|
209
|
+
# Rufus.to_duration 30 * 24 * 3600 + 1, true # => "1M1s"
|
203
210
|
#
|
204
211
|
# If a Float value is passed, milliseconds will be displayed without
|
205
212
|
# 'marker'
|
206
213
|
#
|
207
|
-
# Rufus.
|
208
|
-
# Rufus.
|
209
|
-
# Rufus.
|
214
|
+
# Rufus.to_duration 0.051 # => "51"
|
215
|
+
# Rufus.to_duration 7.051 # => "7s51"
|
216
|
+
# Rufus.to_duration 0.120 + 30 * 24 * 3600 + 1 # => "4w2d1s120"
|
210
217
|
#
|
211
218
|
# (this behaviour mirrors the one found for parse_time_string()).
|
212
219
|
#
|
@@ -238,7 +245,11 @@ module Rufus
|
|
238
245
|
end
|
239
246
|
|
240
247
|
class << self
|
248
|
+
#-
|
249
|
+
# for compatibility with rufus-scheduler 2.x
|
250
|
+
#+
|
241
251
|
alias to_duration_string to_duration
|
252
|
+
alias to_time_string to_duration
|
242
253
|
end
|
243
254
|
|
244
255
|
# Turns a number of seconds (integer or Float) into a hash like in :
|
@@ -250,8 +261,7 @@ module Rufus
|
|
250
261
|
# Rufus.to_duration_hash 0.120 + 30 * 24 * 3600 + 1
|
251
262
|
# # => { :w => 4, :d => 2, :s => 1, :ms => "120" }
|
252
263
|
#
|
253
|
-
# This method is used by
|
254
|
-
# the scene.
|
264
|
+
# This method is used by to_duration behind the scenes.
|
255
265
|
#
|
256
266
|
# Options are :
|
257
267
|
#
|
data/rufus-scheduler.gemspec
CHANGED
@@ -49,7 +49,7 @@ A) Forget it and peg your Gemfile to rufus-scheduler 2.0.24
|
|
49
49
|
and / or
|
50
50
|
|
51
51
|
B) Take some time to carefully report the issue at
|
52
|
-
https://github.com/jmettraux/rufus-scheduler/
|
52
|
+
https://github.com/jmettraux/rufus-scheduler/issues
|
53
53
|
|
54
54
|
For general help about rufus-scheduler, ask via:
|
55
55
|
http://stackoverflow.com/questions/ask?tags=rufus-scheduler+ruby
|
data/spec/cronline_spec.rb
CHANGED
@@ -74,8 +74,15 @@ describe Rufus::Scheduler::CronLine do
|
|
74
74
|
|
75
75
|
it 'interprets cron strings with TZ correctly' do
|
76
76
|
|
77
|
-
to_a
|
78
|
-
to_a
|
77
|
+
to_a('* * * * * EST', [ [0], nil, nil, nil, nil, nil, nil, 'EST' ])
|
78
|
+
to_a('* * * * * * EST', [ nil, nil, nil, nil, nil, nil, nil, 'EST' ])
|
79
|
+
|
80
|
+
to_a(
|
81
|
+
'* * * * * * America/Chicago',
|
82
|
+
[ nil, nil, nil, nil, nil, nil, nil, 'America/Chicago' ])
|
83
|
+
to_a(
|
84
|
+
'* * * * * * America/New_York',
|
85
|
+
[ nil, nil, nil, nil, nil, nil, nil, 'America/New_York' ])
|
79
86
|
|
80
87
|
lambda { cl '* * * * * NotATimeZone' }.should raise_error
|
81
88
|
lambda { cl '* * * * * * NotATimeZone' }.should raise_error
|
data/spec/parse_spec.rb
CHANGED
@@ -138,6 +138,22 @@ describe Rufus::Scheduler do
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
+
describe '.parse_time_string -> .parse_duration' do
|
142
|
+
|
143
|
+
it 'is still around for libs using it out there' do
|
144
|
+
|
145
|
+
Rufus::Scheduler.parse_time_string('1d1w1d').should == 777600.0
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe '.parse_duration_string -> .parse_duration' do
|
150
|
+
|
151
|
+
it 'is still around for libs using it out there' do
|
152
|
+
|
153
|
+
Rufus::Scheduler.parse_duration_string('1d1w1d').should == 777600.0
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
141
157
|
describe '.to_duration' do
|
142
158
|
|
143
159
|
def td(o, opts={})
|
data/spec/threads_spec.rb
CHANGED
@@ -45,6 +45,27 @@ describe Rufus::Scheduler do
|
|
45
45
|
@scheduler.work_threads.size.should == 5
|
46
46
|
end
|
47
47
|
|
48
|
+
it 'does not cross the max_work_threads threshold (overlap: false)' do
|
49
|
+
|
50
|
+
#@scheduler.min_work_threads = 2
|
51
|
+
@scheduler.max_work_threads = 5
|
52
|
+
|
53
|
+
10.times do
|
54
|
+
@scheduler.in '0s', :overlap => false do
|
55
|
+
sleep 5
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
sleep 0.5
|
60
|
+
|
61
|
+
#@scheduler.job_threads.each do |t|
|
62
|
+
# p t.keys
|
63
|
+
# p t[:rufus_scheduler_job].class
|
64
|
+
#end
|
65
|
+
|
66
|
+
@scheduler.work_threads.size.should == 5
|
67
|
+
end
|
68
|
+
|
48
69
|
it 'does not execute unscheduled jobs' do
|
49
70
|
|
50
71
|
@scheduler.max_work_threads = 1
|
metadata
CHANGED
@@ -1,64 +1,64 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rufus-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
version: 3.0.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John Mettraux
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tzinfo
|
16
|
-
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
17
18
|
requirements:
|
18
|
-
- - '>='
|
19
|
+
- - ! '>='
|
19
20
|
- !ruby/object:Gem::Version
|
20
21
|
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
25
|
none: false
|
22
|
-
requirement: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
|
-
none: false
|
28
|
-
prerelease: false
|
29
|
-
type: :runtime
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rake
|
32
|
-
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
33
34
|
requirements:
|
34
|
-
- - '>='
|
35
|
+
- - ! '>='
|
35
36
|
- !ruby/object:Gem::Version
|
36
37
|
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
41
|
none: false
|
38
|
-
requirement: !ruby/object:Gem::Requirement
|
39
42
|
requirements:
|
40
|
-
- - '>='
|
43
|
+
- - ! '>='
|
41
44
|
- !ruby/object:Gem::Version
|
42
45
|
version: '0'
|
43
|
-
none: false
|
44
|
-
prerelease: false
|
45
|
-
type: :development
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rspec
|
48
|
-
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
49
50
|
requirements:
|
50
|
-
- - '>='
|
51
|
+
- - ! '>='
|
51
52
|
- !ruby/object:Gem::Version
|
52
53
|
version: 2.13.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
57
|
none: false
|
54
|
-
requirement: !ruby/object:Gem::Requirement
|
55
58
|
requirements:
|
56
|
-
- - '>='
|
59
|
+
- - ! '>='
|
57
60
|
- !ruby/object:Gem::Version
|
58
61
|
version: 2.13.0
|
59
|
-
none: false
|
60
|
-
prerelease: false
|
61
|
-
type: :development
|
62
62
|
description: job scheduler for Ruby (at, cron, in and every jobs).
|
63
63
|
email:
|
64
64
|
- jmettraux@gmail.com
|
@@ -102,32 +102,32 @@ files:
|
|
102
102
|
homepage: http://github.com/jmettraux/rufus-scheduler
|
103
103
|
licenses:
|
104
104
|
- MIT
|
105
|
-
post_install_message: "\n***\n\nThanks for installing rufus-scheduler 3.0.
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
\
|
105
|
+
post_install_message: ! "\n***\n\nThanks for installing rufus-scheduler 3.0.1\n\nIt
|
106
|
+
might not be 100% compatible with rufus-scheduler 2.x.\n\nIf you encounter issues
|
107
|
+
with this new rufus-scheduler, especially\nif your app worked fine with previous
|
108
|
+
versions of it, you can\n\nA) Forget it and peg your Gemfile to rufus-scheduler
|
109
|
+
2.0.24\n\nand / or\n\nB) Take some time to carefully report the issue at\n https://github.com/jmettraux/rufus-scheduler/issues\n\nFor
|
110
|
+
general help about rufus-scheduler, ask via:\nhttp://stackoverflow.com/questions/ask?tags=rufus-scheduler+ruby\n\nCheers.\n\n***\n
|
111
|
+
\ "
|
112
112
|
rdoc_options: []
|
113
113
|
require_paths:
|
114
114
|
- lib
|
115
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
116
117
|
requirements:
|
117
|
-
- - '>='
|
118
|
+
- - ! '>='
|
118
119
|
- !ruby/object:Gem::Version
|
119
120
|
version: '0'
|
120
|
-
none: false
|
121
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
122
123
|
requirements:
|
123
|
-
- - '>='
|
124
|
+
- - ! '>='
|
124
125
|
- !ruby/object:Gem::Version
|
125
126
|
version: '0'
|
126
|
-
none: false
|
127
127
|
requirements: []
|
128
128
|
rubyforge_project: rufus
|
129
|
-
rubygems_version: 1.8.
|
130
|
-
signing_key:
|
129
|
+
rubygems_version: 1.8.23
|
130
|
+
signing_key:
|
131
131
|
specification_version: 3
|
132
132
|
summary: job scheduler for Ruby (at, cron, in and every jobs)
|
133
133
|
test_files: []
|