rufus-scheduler 2.0.14 → 2.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +5 -0
- data/CREDITS.txt +1 -0
- data/README.rdoc +7 -0
- data/lib/rufus/sc/jobs.rb +3 -1
- data/lib/rufus/sc/scheduler.rb +11 -1
- data/lib/rufus/sc/version.rb +1 -1
- data/spec/scheduler_spec.rb +44 -0
- metadata +8 -8
data/CHANGELOG.txt
CHANGED
data/CREDITS.txt
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
|
16
16
|
== Feedback
|
17
17
|
|
18
|
+
- Louis Coilliot - Scheduler#running_jobs
|
18
19
|
- Henrique G. Testa - pause/resume concept
|
19
20
|
- Sam Gibson - https://github.com/samfoo - exception handling hardening
|
20
21
|
- sha1dy - https://github.com/sha1dy - every and overlapping exception issue
|
data/README.rdoc
CHANGED
@@ -338,6 +338,13 @@ As said, the scheduler has a #pause(job_or_job_id) and a #resume(job_or_job_id)
|
|
338
338
|
scheduler.resume(job_id)
|
339
339
|
|
340
340
|
|
341
|
+
== Scheduler#running_jobs
|
342
|
+
|
343
|
+
One can get a list of the jobs just triggered (actually running) by doing
|
344
|
+
|
345
|
+
jobs = scheduler.running_jobs
|
346
|
+
|
347
|
+
|
341
348
|
== schedulables
|
342
349
|
|
343
350
|
Sometimes passing a block isn't that convenient :
|
data/lib/rufus/sc/jobs.rb
CHANGED
@@ -177,9 +177,11 @@ module Scheduler
|
|
177
177
|
# (Only jobs know about this method of the scheduler)
|
178
178
|
|
179
179
|
job_thread = Thread.current
|
180
|
+
|
180
181
|
job_thread[
|
181
182
|
"rufus_scheduler__trigger_thread__#{@scheduler.object_id}"
|
182
|
-
] =
|
183
|
+
] = self
|
184
|
+
|
183
185
|
@last_job_thread = job_thread
|
184
186
|
|
185
187
|
begin
|
data/lib/rufus/sc/scheduler.rb
CHANGED
@@ -313,10 +313,20 @@ module Rufus::Scheduler
|
|
313
313
|
def trigger_threads
|
314
314
|
|
315
315
|
Thread.list.select { |t|
|
316
|
-
t["rufus_scheduler__trigger_thread__#{self.object_id}"]
|
316
|
+
t["rufus_scheduler__trigger_thread__#{self.object_id}"]
|
317
317
|
}
|
318
318
|
end
|
319
319
|
|
320
|
+
# Returns the list of the currently running jobs (jobs that just got
|
321
|
+
# triggered and are executing).
|
322
|
+
#
|
323
|
+
def running_jobs
|
324
|
+
|
325
|
+
Thread.list.collect { |t|
|
326
|
+
t["rufus_scheduler__trigger_thread__#{self.object_id}"]
|
327
|
+
}.compact
|
328
|
+
end
|
329
|
+
|
320
330
|
protected
|
321
331
|
|
322
332
|
# Returns a job queue instance.
|
data/lib/rufus/sc/version.rb
CHANGED
data/spec/scheduler_spec.rb
CHANGED
@@ -156,6 +156,50 @@ describe SCHEDULER_CLASS do
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
159
|
+
|
160
|
+
context 'trigger threads' do
|
161
|
+
|
162
|
+
before(:each) do
|
163
|
+
@s = start_scheduler
|
164
|
+
end
|
165
|
+
after(:each) do
|
166
|
+
stop_scheduler(@s)
|
167
|
+
end
|
168
|
+
|
169
|
+
describe '#trigger_threads' do
|
170
|
+
|
171
|
+
it 'returns an empty list when no jobs are running' do
|
172
|
+
|
173
|
+
@s.trigger_threads.should == []
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'returns a list of the threads of the running jobs' do
|
177
|
+
|
178
|
+
@s.in('100') { sleep 10 }
|
179
|
+
|
180
|
+
sleep 0.5
|
181
|
+
|
182
|
+
@s.trigger_threads.collect { |e| e.class }.should == [ Thread ]
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe '#running_jobs' do
|
187
|
+
|
188
|
+
it 'returns an empty list when no jobs are running' do
|
189
|
+
|
190
|
+
@s.running_jobs.should == []
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'returns a list of the currently running jobs' do
|
194
|
+
|
195
|
+
job = @s.in('100') { sleep 10 }
|
196
|
+
|
197
|
+
sleep 0.5
|
198
|
+
|
199
|
+
@s.running_jobs.should == [ job ]
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
159
203
|
end
|
160
204
|
|
161
205
|
describe 'Rufus::Scheduler#start_new' do
|
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: 2.0.
|
4
|
+
version: 2.0.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-20 00:00:00.000000000 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: tzinfo
|
17
|
-
requirement: &
|
17
|
+
requirement: &2156163440 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.3.23
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2156163440
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rake
|
28
|
-
requirement: &
|
28
|
+
requirement: &2156163000 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2156163000
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rspec
|
39
|
-
requirement: &
|
39
|
+
requirement: &2156162340 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: 2.7.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2156162340
|
48
48
|
description: job scheduler for Ruby (at, cron, in and every jobs).
|
49
49
|
email:
|
50
50
|
- jmettraux@gmail.com
|