rufus-scheduler 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +8 -1
- data/README.txt +5 -0
- data/lib/openwfe/util/scheduler.rb +8 -8
- data/lib/rufus/scheduler.rb +137 -30
- data/test/cron_test.rb +24 -6
- data/test/cronline_test.rb +27 -0
- data/test/scheduler_0_test.rb +16 -18
- data/test/scheduler_1_test.rb +7 -7
- data/test/scheduler_2_test.rb +9 -9
- data/test/scheduler_3_test.rb +2 -2
- data/test/scheduler_name_test.rb +5 -5
- data/test/time_0_test.rb +1 -1
- data/test/time_1_test.rb +1 -1
- metadata +2 -2
data/CHANGELOG.txt
CHANGED
@@ -2,7 +2,14 @@
|
|
2
2
|
= rufus-scheduler CHANGELOG.txt
|
3
3
|
|
4
4
|
|
5
|
-
== rufus-scheduler - 1.0.
|
5
|
+
== rufus-scheduler - 1.0.7 released 2008/06/16
|
6
|
+
|
7
|
+
- todo #20669 : implemented CronJob.next_time()
|
8
|
+
- todo #20667 : now passing params to schedule() blocks as well.
|
9
|
+
- bug #20648 : find_schedulable(tag) broken. Fixed.
|
10
|
+
|
11
|
+
|
12
|
+
== rufus-scheduler - 1.0.6 released 2008/05/02
|
6
13
|
|
7
14
|
- bug #20476 : no cron jobs on sundays (wday == 0). Fixed.
|
8
15
|
(thanks to Manfred Usselmann)
|
data/README.txt
CHANGED
@@ -8,10 +8,10 @@
|
|
8
8
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
9
|
# copies of the Software, and to permit persons to whom the Software is
|
10
10
|
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# The above copyright notice and this permission notice shall be included in
|
13
13
|
# all copies or substantial portions of the Software.
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
16
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
17
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
@@ -26,16 +26,16 @@ require 'rufus/scheduler'
|
|
26
26
|
|
27
27
|
|
28
28
|
#
|
29
|
-
# An 'alias' to Rufus::Scheduler to keep backward compatibility for
|
29
|
+
# An 'alias' to Rufus::Scheduler to keep backward compatibility for
|
30
30
|
# the users of the gem 'openwferu-scheduler'.
|
31
31
|
#
|
32
32
|
module OpenWFE
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
class Scheduler < Rufus::Scheduler
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
module Schedulable
|
38
|
+
include Rufus::Schedulable
|
39
|
+
end
|
40
40
|
end
|
41
41
|
|
data/lib/rufus/scheduler.rb
CHANGED
@@ -64,6 +64,7 @@ module Rufus
|
|
64
64
|
# require 'rubygems'
|
65
65
|
# require 'rufus/scheduler'
|
66
66
|
#
|
67
|
+
# scheduler = Rufus::Scheduler.start_new
|
67
68
|
#
|
68
69
|
# scheduler.schedule_in("3d") do
|
69
70
|
# regenerate_monthly_report()
|
@@ -180,6 +181,26 @@ module Rufus
|
|
180
181
|
# scheduling. This column can, like for the other columns, specify a
|
181
182
|
# value ("7"), a list of values ("7,8,9,27") or a range ("7-12").
|
182
183
|
#
|
184
|
+
#
|
185
|
+
# == information passed to schedule blocks
|
186
|
+
#
|
187
|
+
# When calling schedule_every(), schedule_in() or schedule_at(), the block
|
188
|
+
# expects zero or 3 parameters like in
|
189
|
+
#
|
190
|
+
# scheduler.schedule_every("1h20m") do |job_id, at, params|
|
191
|
+
# puts "my job_id is #{job_id}"
|
192
|
+
# end
|
193
|
+
#
|
194
|
+
# For schedule(), zero or two parameters can get passed
|
195
|
+
#
|
196
|
+
# scheduler.schedule "7 * * * * *" do |job_id, cron_line, params|
|
197
|
+
# puts "my job_id is #{job_id}"
|
198
|
+
# end
|
199
|
+
#
|
200
|
+
# In both cases, params corresponds to the params passed to the schedule
|
201
|
+
# method (:tags, :first_at, :first_in, :dont_reschedule, ...)
|
202
|
+
#
|
203
|
+
#
|
183
204
|
# == Exceptions
|
184
205
|
#
|
185
206
|
# The rufus scheduler will output a stacktrace to the STDOUT in
|
@@ -242,6 +263,23 @@ module Rufus
|
|
242
263
|
# # schedule something every two days, start in 5 hours...
|
243
264
|
# end
|
244
265
|
#
|
266
|
+
# == job.next_time()
|
267
|
+
#
|
268
|
+
# Jobs, be they at, every or cron have a next_time() method, which tells
|
269
|
+
# when the job will be fired next time (for at and in jobs, this is also the
|
270
|
+
# last time).
|
271
|
+
#
|
272
|
+
# For cron jobs, the current implementation is quite brutal. It takes three
|
273
|
+
# seconds on my 2006 macbook to reach a cron schedule 1 year away.
|
274
|
+
#
|
275
|
+
# When is the next friday 13th ?
|
276
|
+
#
|
277
|
+
# require 'rubygems'
|
278
|
+
# require 'rufus/scheduler'
|
279
|
+
#
|
280
|
+
# puts Rufus::CronLine.new("* * 13 * fri").next_time
|
281
|
+
#
|
282
|
+
#
|
245
283
|
# == :thread_name option
|
246
284
|
#
|
247
285
|
# You can specify the name of the scheduler's thread. Should make
|
@@ -348,6 +386,16 @@ module Rufus
|
|
348
386
|
end
|
349
387
|
end
|
350
388
|
|
389
|
+
#
|
390
|
+
# Instantiates a new Rufus::Scheduler instance, starts it and returns it
|
391
|
+
#
|
392
|
+
def self.start_new
|
393
|
+
|
394
|
+
s = self.new
|
395
|
+
s.start
|
396
|
+
s
|
397
|
+
end
|
398
|
+
|
351
399
|
#
|
352
400
|
# The scheduler is stoppable via sstop()
|
353
401
|
#
|
@@ -612,12 +660,7 @@ module Rufus
|
|
612
660
|
#
|
613
661
|
def get_job (job_id)
|
614
662
|
|
615
|
-
|
616
|
-
return job if job
|
617
|
-
|
618
|
-
@pending_jobs.find do |job|
|
619
|
-
job.job_id == job_id
|
620
|
-
end
|
663
|
+
@cron_jobs[job_id] || @pending_jobs.find { |job| job.job_id == job_id }
|
621
664
|
end
|
622
665
|
|
623
666
|
#
|
@@ -640,13 +683,8 @@ module Rufus
|
|
640
683
|
#
|
641
684
|
def find_jobs (tag)
|
642
685
|
|
643
|
-
|
644
|
-
|
645
|
-
end
|
646
|
-
|
647
|
-
result + @pending_jobs.find_all do |job|
|
648
|
-
job.has_tag?(tag)
|
649
|
-
end
|
686
|
+
@cron_jobs.values.find_all { |job| job.has_tag?(tag) } +
|
687
|
+
@pending_jobs.find_all { |job| job.has_tag?(tag) }
|
650
688
|
end
|
651
689
|
|
652
690
|
#
|
@@ -657,18 +695,7 @@ module Rufus
|
|
657
695
|
#
|
658
696
|
def find_schedulables (tag)
|
659
697
|
|
660
|
-
|
661
|
-
#result = []
|
662
|
-
#jobs.each do |job|
|
663
|
-
# result.push(job.schedulable) if job.respond_to?(:schedulable)
|
664
|
-
#end
|
665
|
-
#result
|
666
|
-
|
667
|
-
find_jobs(tags).inject([]) do |result, job|
|
668
|
-
|
669
|
-
result.push(job.schedulable) if job.respond_to?(:schedulable)
|
670
|
-
result
|
671
|
-
end
|
698
|
+
find_jobs(tag).find_all { |job| job.respond_to?(:schedulable) }
|
672
699
|
end
|
673
700
|
|
674
701
|
#
|
@@ -709,10 +736,9 @@ module Rufus
|
|
709
736
|
#
|
710
737
|
def Scheduler.is_cron_string (s)
|
711
738
|
|
712
|
-
s.match ".+ .+ .+ .+ .+"
|
739
|
+
s.match ".+ .+ .+ .+ .+" # well...
|
713
740
|
end
|
714
741
|
|
715
|
-
#protected
|
716
742
|
private
|
717
743
|
|
718
744
|
def do_unschedule (job_id)
|
@@ -1158,6 +1184,15 @@ module Rufus
|
|
1158
1184
|
|
1159
1185
|
Time.at(@at)
|
1160
1186
|
end
|
1187
|
+
|
1188
|
+
#
|
1189
|
+
# next_time is last_time (except for EveryJob instances). Returns
|
1190
|
+
# a Time instance.
|
1191
|
+
#
|
1192
|
+
def next_time
|
1193
|
+
|
1194
|
+
schedule_info
|
1195
|
+
end
|
1161
1196
|
end
|
1162
1197
|
|
1163
1198
|
#
|
@@ -1222,7 +1257,7 @@ module Rufus
|
|
1222
1257
|
#
|
1223
1258
|
def trigger
|
1224
1259
|
|
1225
|
-
@block.call @job_id, @cron_line
|
1260
|
+
@block.call @job_id, @cron_line, @params
|
1226
1261
|
end
|
1227
1262
|
|
1228
1263
|
#
|
@@ -1233,6 +1268,18 @@ module Rufus
|
|
1233
1268
|
|
1234
1269
|
@cron_line.original
|
1235
1270
|
end
|
1271
|
+
|
1272
|
+
#
|
1273
|
+
# Returns a Time instance : the next time this cron job is
|
1274
|
+
# supposed to "fire".
|
1275
|
+
#
|
1276
|
+
# 'from' is used to specify the starting point for determining
|
1277
|
+
# what will be the next time. Defaults to now.
|
1278
|
+
#
|
1279
|
+
def next_time (from=Time.now)
|
1280
|
+
|
1281
|
+
@cron_line.next_time(from)
|
1282
|
+
end
|
1236
1283
|
end
|
1237
1284
|
|
1238
1285
|
#
|
@@ -1293,8 +1340,7 @@ module Rufus
|
|
1293
1340
|
def matches? (time)
|
1294
1341
|
#def matches? (time, precision)
|
1295
1342
|
|
1296
|
-
time = Time.at(time)
|
1297
|
-
if time.kind_of?(Float) or time.kind_of?(Integer)
|
1343
|
+
time = Time.at(time) unless time.kind_of?(Time)
|
1298
1344
|
|
1299
1345
|
return false \
|
1300
1346
|
if no_match?(time.sec, @seconds)
|
@@ -1320,9 +1366,70 @@ module Rufus
|
|
1320
1366
|
# This method is used by the cronline unit tests.
|
1321
1367
|
#
|
1322
1368
|
def to_array
|
1369
|
+
|
1323
1370
|
[ @seconds, @minutes, @hours, @days, @months, @weekdays ]
|
1324
1371
|
end
|
1325
1372
|
|
1373
|
+
#
|
1374
|
+
# Returns the next time that this cron line is supposed to 'fire'
|
1375
|
+
#
|
1376
|
+
# This is raw, 3 secs to iterate over 1 year on my macbook :( brutal.
|
1377
|
+
#
|
1378
|
+
def next_time (now = Time.now)
|
1379
|
+
|
1380
|
+
#
|
1381
|
+
# position now to the next cron second
|
1382
|
+
|
1383
|
+
if @seconds
|
1384
|
+
next_sec = @seconds.find { |s| s > now.sec } || 60 + @seconds.first
|
1385
|
+
now += next_sec - now.sec
|
1386
|
+
else
|
1387
|
+
now += 1
|
1388
|
+
end
|
1389
|
+
|
1390
|
+
#
|
1391
|
+
# prepare sec jump array
|
1392
|
+
|
1393
|
+
sjarray = nil
|
1394
|
+
|
1395
|
+
if @seconds
|
1396
|
+
|
1397
|
+
sjarray = []
|
1398
|
+
|
1399
|
+
i = @seconds.index(now.sec)
|
1400
|
+
ii = i
|
1401
|
+
|
1402
|
+
loop do
|
1403
|
+
cur = @seconds[ii]
|
1404
|
+
ii += 1
|
1405
|
+
ii = 0 if ii == @seconds.size
|
1406
|
+
nxt = @seconds[ii]
|
1407
|
+
nxt += 60 if ii == 0
|
1408
|
+
sjarray << (nxt - cur)
|
1409
|
+
break if ii == i
|
1410
|
+
end
|
1411
|
+
|
1412
|
+
else
|
1413
|
+
|
1414
|
+
sjarray = [ 1 ]
|
1415
|
+
end
|
1416
|
+
|
1417
|
+
#
|
1418
|
+
# ok, seek...
|
1419
|
+
|
1420
|
+
i = 0
|
1421
|
+
|
1422
|
+
loop do
|
1423
|
+
return now if matches?(now)
|
1424
|
+
now += sjarray[i]
|
1425
|
+
i += 1
|
1426
|
+
i = 0 if i == sjarray.size
|
1427
|
+
# danger... potentially no exit...
|
1428
|
+
end
|
1429
|
+
|
1430
|
+
nil
|
1431
|
+
end
|
1432
|
+
|
1326
1433
|
private
|
1327
1434
|
|
1328
1435
|
#--
|
data/test/cron_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
#
|
3
|
-
# Testing
|
3
|
+
# Testing Rufus
|
4
4
|
#
|
5
5
|
# John Mettraux at openwfe.org
|
6
6
|
#
|
@@ -27,7 +27,7 @@ class CronTest < Test::Unit::TestCase
|
|
27
27
|
|
28
28
|
$var = 0
|
29
29
|
|
30
|
-
scheduler =
|
30
|
+
scheduler = Rufus::Scheduler.new
|
31
31
|
scheduler.start
|
32
32
|
|
33
33
|
sid = scheduler.schedule(
|
@@ -46,7 +46,7 @@ class CronTest < Test::Unit::TestCase
|
|
46
46
|
|
47
47
|
def test_1
|
48
48
|
|
49
|
-
scheduler =
|
49
|
+
scheduler = Rufus::Scheduler.new
|
50
50
|
scheduler.start
|
51
51
|
|
52
52
|
sec = nil
|
@@ -76,7 +76,7 @@ class CronTest < Test::Unit::TestCase
|
|
76
76
|
|
77
77
|
def test_2
|
78
78
|
|
79
|
-
scheduler =
|
79
|
+
scheduler = Rufus::Scheduler.new
|
80
80
|
scheduler.start
|
81
81
|
|
82
82
|
counter = 0
|
@@ -97,7 +97,7 @@ class CronTest < Test::Unit::TestCase
|
|
97
97
|
#
|
98
98
|
def test_3
|
99
99
|
|
100
|
-
scheduler =
|
100
|
+
scheduler = Rufus::Scheduler.new
|
101
101
|
scheduler.start
|
102
102
|
|
103
103
|
counter = 0
|
@@ -111,6 +111,7 @@ class CronTest < Test::Unit::TestCase
|
|
111
111
|
#puts "job_id : #{job_id}"
|
112
112
|
|
113
113
|
assert_equal 1, scheduler.cron_job_count
|
114
|
+
assert_equal 0, scheduler.find_schedulables("nada").size
|
114
115
|
|
115
116
|
scheduler.unschedule job_id
|
116
117
|
|
@@ -121,10 +122,27 @@ class CronTest < Test::Unit::TestCase
|
|
121
122
|
scheduler.stop
|
122
123
|
end
|
123
124
|
|
125
|
+
def test_4
|
126
|
+
|
127
|
+
scheduler = Rufus::Scheduler.start_new
|
128
|
+
|
129
|
+
val = nil
|
130
|
+
|
131
|
+
job_id = scheduler.schedule "* * * * * *" do |job_id, cron_line, params|
|
132
|
+
val = params.inspect
|
133
|
+
end
|
134
|
+
|
135
|
+
sleep 2
|
136
|
+
|
137
|
+
assert_equal '{}', val
|
138
|
+
|
139
|
+
scheduler.stop
|
140
|
+
end
|
141
|
+
|
124
142
|
protected
|
125
143
|
|
126
144
|
class CounterSchedulable
|
127
|
-
include
|
145
|
+
include Rufus::Schedulable
|
128
146
|
|
129
147
|
def trigger (params)
|
130
148
|
$var = $var + 1
|
data/test/cronline_test.rb
CHANGED
@@ -49,8 +49,35 @@ class CronLineTest < Test::Unit::TestCase
|
|
49
49
|
dotest "1-5 * * * * *", [ [1,2,3,4,5], nil, nil, nil, nil, nil ]
|
50
50
|
end
|
51
51
|
|
52
|
+
def test_2
|
53
|
+
|
54
|
+
now = Time.at(0) # something like 'Thu Jan 01 09:00:00 +0900 1970'
|
55
|
+
|
56
|
+
assert_equal now + 60, cl("* * * * *").next_time(now)
|
57
|
+
assert_equal now + 226800, cl("* * * * sun").next_time(now)
|
58
|
+
assert_equal now + 1, cl("* * * * * *").next_time(now)
|
59
|
+
assert_equal now + 3682800, cl("* * 13 * fri").next_time(now)
|
60
|
+
|
61
|
+
assert_equal now + 29905800, cl("10 12 13 12 *").next_time(now)
|
62
|
+
# this one is slow (1 year == 3 seconds)
|
63
|
+
|
64
|
+
assert_equal now + 601200, cl("* 8 * * thu").next_time(now)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_3
|
68
|
+
|
69
|
+
now = Time.local(2008, 12, 31, 23, 59, 59, 0)
|
70
|
+
|
71
|
+
assert_equal now + 1, cl("* * * * *").next_time(now)
|
72
|
+
end
|
73
|
+
|
52
74
|
protected
|
53
75
|
|
76
|
+
def cl (cronline_string)
|
77
|
+
|
78
|
+
Rufus::CronLine.new(cronline_string)
|
79
|
+
end
|
80
|
+
|
54
81
|
def dotest (line, array)
|
55
82
|
|
56
83
|
cl = Rufus::CronLine.new(line)
|
data/test/scheduler_0_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
#
|
3
|
-
# Testing
|
3
|
+
# Testing Rufus
|
4
4
|
#
|
5
5
|
# John Mettraux at openwfe.org
|
6
6
|
#
|
@@ -29,8 +29,7 @@ class Scheduler0Test < Test::Unit::TestCase
|
|
29
29
|
|
30
30
|
$var = nil
|
31
31
|
|
32
|
-
scheduler =
|
33
|
-
scheduler.sstart
|
32
|
+
scheduler = Rufus::Scheduler.start_new
|
34
33
|
|
35
34
|
sid = scheduler.schedule_in('2s', :schedulable => TestSchedulable.new)
|
36
35
|
|
@@ -60,8 +59,8 @@ class Scheduler0Test < Test::Unit::TestCase
|
|
60
59
|
|
61
60
|
$var = nil
|
62
61
|
|
63
|
-
scheduler =
|
64
|
-
scheduler.
|
62
|
+
scheduler = Rufus::Scheduler.new
|
63
|
+
scheduler.start
|
65
64
|
|
66
65
|
sid = scheduler.schedule_in('1s') do
|
67
66
|
$var = "ok..1"
|
@@ -90,8 +89,8 @@ class Scheduler0Test < Test::Unit::TestCase
|
|
90
89
|
|
91
90
|
text = ""
|
92
91
|
|
93
|
-
scheduler =
|
94
|
-
scheduler.
|
92
|
+
scheduler = Rufus::Scheduler.new()
|
93
|
+
scheduler.start
|
95
94
|
|
96
95
|
scheduler.schedule_in("1s") do
|
97
96
|
text << "one"
|
@@ -117,8 +116,7 @@ class Scheduler0Test < Test::Unit::TestCase
|
|
117
116
|
|
118
117
|
Thread.abort_on_exception = true
|
119
118
|
|
120
|
-
scheduler =
|
121
|
-
scheduler.sstart
|
119
|
+
scheduler = Rufus::Scheduler.start_new
|
122
120
|
|
123
121
|
#
|
124
122
|
# phase 0
|
@@ -149,7 +147,7 @@ class Scheduler0Test < Test::Unit::TestCase
|
|
149
147
|
job_id = scheduler.schedule_every "500", es
|
150
148
|
|
151
149
|
#puts "1 job_id : " + job_id.to_s
|
152
|
-
|
150
|
+
|
153
151
|
#sleep(3.4) # was a bit soonish for JRuby...
|
154
152
|
sleep 3.5
|
155
153
|
|
@@ -174,8 +172,8 @@ class Scheduler0Test < Test::Unit::TestCase
|
|
174
172
|
#
|
175
173
|
def test_scheduler_5
|
176
174
|
|
177
|
-
scheduler =
|
178
|
-
scheduler.
|
175
|
+
scheduler = Rufus::Scheduler.new
|
176
|
+
scheduler.start
|
179
177
|
|
180
178
|
touched = false
|
181
179
|
|
@@ -193,7 +191,7 @@ class Scheduler0Test < Test::Unit::TestCase
|
|
193
191
|
#
|
194
192
|
def test_scheduler_6
|
195
193
|
|
196
|
-
scheduler =
|
194
|
+
scheduler = Rufus::Scheduler.new
|
197
195
|
scheduler.start
|
198
196
|
|
199
197
|
#class << scheduler
|
@@ -267,7 +265,7 @@ class Scheduler0Test < Test::Unit::TestCase
|
|
267
265
|
#
|
268
266
|
def test_8b
|
269
267
|
|
270
|
-
scheduler =
|
268
|
+
scheduler = Rufus::Scheduler.new
|
271
269
|
scheduler.start
|
272
270
|
|
273
271
|
var = nil
|
@@ -287,7 +285,7 @@ class Scheduler0Test < Test::Unit::TestCase
|
|
287
285
|
#
|
288
286
|
def test_9
|
289
287
|
|
290
|
-
scheduler =
|
288
|
+
scheduler = Rufus::Scheduler.new
|
291
289
|
scheduler.start
|
292
290
|
|
293
291
|
value = nil
|
@@ -317,7 +315,7 @@ class Scheduler0Test < Test::Unit::TestCase
|
|
317
315
|
|
318
316
|
e = nil
|
319
317
|
begin
|
320
|
-
|
318
|
+
Rufus::Scheduler.new.precision = 10
|
321
319
|
rescue Exception => e
|
322
320
|
end
|
323
321
|
|
@@ -327,7 +325,7 @@ class Scheduler0Test < Test::Unit::TestCase
|
|
327
325
|
protected
|
328
326
|
|
329
327
|
class TestSchedulable
|
330
|
-
include
|
328
|
+
include Rufus::Schedulable
|
331
329
|
|
332
330
|
def trigger (params)
|
333
331
|
$var = "ok"
|
@@ -335,7 +333,7 @@ class Scheduler0Test < Test::Unit::TestCase
|
|
335
333
|
end
|
336
334
|
|
337
335
|
class EverySchedulable
|
338
|
-
include
|
336
|
+
include Rufus::Schedulable
|
339
337
|
|
340
338
|
attr_accessor :job_id, :count
|
341
339
|
|
data/test/scheduler_1_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
#
|
3
|
-
# Testing
|
3
|
+
# Testing Rufus
|
4
4
|
#
|
5
5
|
# John Mettraux at openwfe.org
|
6
6
|
#
|
@@ -24,8 +24,8 @@ class Scheduler1Test < Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
def test_0
|
26
26
|
|
27
|
-
scheduler =
|
28
|
-
scheduler.
|
27
|
+
scheduler = Rufus::Scheduler.new
|
28
|
+
scheduler.start
|
29
29
|
|
30
30
|
job_id = scheduler.schedule_every "500", :tags => "Avery" do
|
31
31
|
# don't do a thing
|
@@ -47,8 +47,8 @@ class Scheduler1Test < Test::Unit::TestCase
|
|
47
47
|
|
48
48
|
def test_1
|
49
49
|
|
50
|
-
scheduler =
|
51
|
-
scheduler.
|
50
|
+
scheduler = Rufus::Scheduler.new
|
51
|
+
scheduler.start
|
52
52
|
|
53
53
|
job_id = scheduler.schedule_every "500", :tags => "Avery" do
|
54
54
|
# don't do a thing
|
@@ -74,8 +74,8 @@ class Scheduler1Test < Test::Unit::TestCase
|
|
74
74
|
#
|
75
75
|
def _test_2
|
76
76
|
|
77
|
-
scheduler =
|
78
|
-
scheduler.
|
77
|
+
scheduler = Rufus::Scheduler.new
|
78
|
+
scheduler.start
|
79
79
|
last = nil
|
80
80
|
job_id = scheduler.schedule_every "1s" do
|
81
81
|
t = Time.now
|
data/test/scheduler_2_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
#
|
3
|
-
# Testing
|
3
|
+
# Testing Rufus
|
4
4
|
#
|
5
5
|
# John Mettraux at openwfe.org
|
6
6
|
#
|
@@ -24,8 +24,8 @@ class Scheduler2Test < Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
def test_0
|
26
26
|
|
27
|
-
scheduler =
|
28
|
-
scheduler.
|
27
|
+
scheduler = Rufus::Scheduler.new
|
28
|
+
scheduler.start
|
29
29
|
|
30
30
|
counter = 0
|
31
31
|
$error_counter = 0
|
@@ -52,8 +52,8 @@ class Scheduler2Test < Test::Unit::TestCase
|
|
52
52
|
|
53
53
|
# repeating myself
|
54
54
|
|
55
|
-
scheduler =
|
56
|
-
scheduler.
|
55
|
+
scheduler = Rufus::Scheduler.new
|
56
|
+
scheduler.start
|
57
57
|
|
58
58
|
counter = 0
|
59
59
|
$error_counter = 0
|
@@ -78,8 +78,8 @@ class Scheduler2Test < Test::Unit::TestCase
|
|
78
78
|
|
79
79
|
def test_2
|
80
80
|
|
81
|
-
scheduler =
|
82
|
-
scheduler.
|
81
|
+
scheduler = Rufus::Scheduler.new
|
82
|
+
scheduler.start
|
83
83
|
|
84
84
|
def scheduler.lwarn (&block)
|
85
85
|
puts block.call
|
@@ -101,8 +101,8 @@ class Scheduler2Test < Test::Unit::TestCase
|
|
101
101
|
|
102
102
|
# repeating myself ...
|
103
103
|
|
104
|
-
scheduler =
|
105
|
-
scheduler.
|
104
|
+
scheduler = Rufus::Scheduler.new
|
105
|
+
scheduler.start
|
106
106
|
|
107
107
|
def scheduler.lwarn (&block)
|
108
108
|
puts block.call
|
data/test/scheduler_3_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
#
|
3
|
-
# Testing
|
3
|
+
# Testing Rufus
|
4
4
|
#
|
5
5
|
# John Mettraux at openwfe.org
|
6
6
|
#
|
@@ -24,7 +24,7 @@ class Scheduler3Test < Test::Unit::TestCase
|
|
24
24
|
#
|
25
25
|
def test_0
|
26
26
|
|
27
|
-
scheduler =
|
27
|
+
scheduler = Rufus::Scheduler.new
|
28
28
|
scheduler.start
|
29
29
|
|
30
30
|
value = nil
|
data/test/scheduler_name_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
#
|
3
|
-
# Testing
|
3
|
+
# Testing Rufus
|
4
4
|
#
|
5
5
|
# John Mettraux at openwfe.org
|
6
6
|
#
|
@@ -25,8 +25,8 @@ class SchedulerNameTest < Test::Unit::TestCase
|
|
25
25
|
|
26
26
|
def test_0
|
27
27
|
|
28
|
-
scheduler =
|
29
|
-
scheduler.
|
28
|
+
scheduler = Rufus::Scheduler.new
|
29
|
+
scheduler.start
|
30
30
|
|
31
31
|
sleep 0.350 if defined?(JRUBY_VERSION)
|
32
32
|
|
@@ -39,8 +39,8 @@ class SchedulerNameTest < Test::Unit::TestCase
|
|
39
39
|
|
40
40
|
def test_1
|
41
41
|
|
42
|
-
scheduler =
|
43
|
-
scheduler.
|
42
|
+
scheduler = Rufus::Scheduler.new :thread_name => "genjiguruma"
|
43
|
+
scheduler.start
|
44
44
|
|
45
45
|
sleep 0.350 if defined?(JRUBY_VERSION)
|
46
46
|
|
data/test/time_0_test.rb
CHANGED
data/test/time_1_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rufus-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-06-
|
12
|
+
date: 2008-06-17 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|