rufus-scheduler 2.0.16 → 2.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.txt +6 -0
- data/CREDITS.txt +2 -0
- data/LICENSE.txt +1 -1
- data/README.rdoc +4 -0
- data/lib/rufus/sc/cronline.rb +1 -1
- data/lib/rufus/sc/jobqueues.rb +1 -1
- data/lib/rufus/sc/jobs.rb +49 -4
- data/lib/rufus/sc/scheduler.rb +1 -1
- data/lib/rufus/sc/version.rb +2 -2
- data/lib/rufus/scheduler.rb +1 -1
- data/out.txt +4 -0
- data/spec/at_spec.rb +8 -0
- data/spec/cron_spec.rb +8 -0
- data/spec/every_spec.rb +8 -0
- data/spec/in_spec.rb +8 -0
- data/spec/schedulable_spec.rb +18 -0
- metadata +10 -11
data/CHANGELOG.txt
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
= rufus-scheduler CHANGELOG.txt
|
3
3
|
|
4
4
|
|
5
|
+
== rufus-scheduler - 2.0.17 released 2012/06/14
|
6
|
+
|
7
|
+
- @andrehjr patch to make it work on Ruby 1.9.3
|
8
|
+
- raises ArgumentError on unknown/unsupported options (Idea Tero Tilus)
|
9
|
+
|
10
|
+
|
5
11
|
== rufus-scheduler - 2.0.16 released 2011/12/31
|
6
12
|
|
7
13
|
- hardened Rufus.parse_time_string
|
data/CREDITS.txt
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
== Contributors
|
6
6
|
|
7
|
+
- André Luis Leal Cardoso Junior (https://github.com/andrehjr) 1.9.3 patch
|
7
8
|
- Anthony Lewis (https://github.com/anthonylewis) cron lines and 09 issue
|
8
9
|
- concept47 (https://github.com/concept47) every and :discard_past
|
9
10
|
- Chris Kampemeier (http://github.com/chrisk) rspec 2.0 refinements
|
@@ -15,6 +16,7 @@
|
|
15
16
|
|
16
17
|
== Feedback
|
17
18
|
|
19
|
+
- Tero Tilus - raises on unsupported/unknown options
|
18
20
|
- Louis Coilliot - Scheduler#running_jobs
|
19
21
|
- Henrique G. Testa - pause/resume concept
|
20
22
|
- Sam Gibson - https://github.com/samfoo - exception handling hardening
|
data/LICENSE.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
Copyright (c) 2005-
|
2
|
+
Copyright (c) 2005-2012, John Mettraux, jmettraux@gmail.com
|
3
3
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.rdoc
CHANGED
@@ -124,6 +124,10 @@ at then end of it will make the current (main) thread join the scheduler and pre
|
|
124
124
|
|
125
125
|
You shouldn't be exposed to this issue when using EventMachine, since while running EM, your runtime won't exit.
|
126
126
|
|
127
|
+
=== important note about #join
|
128
|
+
|
129
|
+
DO NOT CALL this #join method if you're running rufus-scheduler from Rails or Sinatra or any application that's already some kind of 'daemon'. It's not necessary! #join is meant for small standalone scripts.
|
130
|
+
|
127
131
|
|
128
132
|
== block parameters
|
129
133
|
|
data/lib/rufus/sc/cronline.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2006-
|
2
|
+
# Copyright (c) 2006-2012, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rufus/sc/jobqueues.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2006-
|
2
|
+
# Copyright (c) 2006-2012, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rufus/sc/jobs.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2006-
|
2
|
+
# Copyright (c) 2006-2012, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -30,7 +30,7 @@ module Scheduler
|
|
30
30
|
# The base class for all types of jobs.
|
31
31
|
#
|
32
32
|
class Job
|
33
|
-
|
33
|
+
|
34
34
|
# A reference to the scheduler owning this job
|
35
35
|
#
|
36
36
|
attr_accessor :scheduler
|
@@ -76,6 +76,8 @@ module Scheduler
|
|
76
76
|
@params = params
|
77
77
|
@block = block || params[:schedulable]
|
78
78
|
|
79
|
+
raise_on_unknown_params
|
80
|
+
|
79
81
|
@running = false
|
80
82
|
@paused = false
|
81
83
|
|
@@ -235,6 +237,39 @@ module Scheduler
|
|
235
237
|
|
236
238
|
@scheduler.unschedule(self.job_id)
|
237
239
|
end
|
240
|
+
|
241
|
+
protected
|
242
|
+
|
243
|
+
def known_params
|
244
|
+
|
245
|
+
[ :allow_overlapping,
|
246
|
+
:blocking,
|
247
|
+
:discard_past,
|
248
|
+
:job_id,
|
249
|
+
:mutex,
|
250
|
+
:schedulable,
|
251
|
+
:tags,
|
252
|
+
:timeout ]
|
253
|
+
end
|
254
|
+
|
255
|
+
def self.known_params(*args)
|
256
|
+
|
257
|
+
define_method :known_params do
|
258
|
+
super() + args
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
def raise_on_unknown_params
|
263
|
+
|
264
|
+
rem = @params.keys - known_params
|
265
|
+
|
266
|
+
raise(
|
267
|
+
ArgumentError,
|
268
|
+
"unknown option#{rem.size > 1 ? 's' : '' }: " +
|
269
|
+
"#{rem.map(&:inspect).join(', ')}",
|
270
|
+
caller[3..-1]
|
271
|
+
) if rem.any?
|
272
|
+
end
|
238
273
|
end
|
239
274
|
|
240
275
|
#
|
@@ -246,6 +281,8 @@ module Scheduler
|
|
246
281
|
#
|
247
282
|
attr_reader :at
|
248
283
|
|
284
|
+
# Last time it triggered
|
285
|
+
#
|
249
286
|
attr_reader :last
|
250
287
|
|
251
288
|
def determine_at
|
@@ -266,12 +303,15 @@ module Scheduler
|
|
266
303
|
#
|
267
304
|
class InJob < SimpleJob
|
268
305
|
|
306
|
+
known_params :parent
|
307
|
+
|
269
308
|
# If this InJob is a timeout job, parent points to the job that
|
270
309
|
# is subject to the timeout.
|
271
310
|
#
|
272
311
|
attr_reader :parent
|
273
312
|
|
274
313
|
def initialize(scheduler, t, params)
|
314
|
+
|
275
315
|
@parent = params[:parent]
|
276
316
|
super
|
277
317
|
end
|
@@ -298,6 +338,8 @@ module Scheduler
|
|
298
338
|
#
|
299
339
|
class EveryJob < SimpleJob
|
300
340
|
|
341
|
+
known_params :first_in, :first_at
|
342
|
+
|
301
343
|
# The frequency, in seconds, of this EveryJob
|
302
344
|
#
|
303
345
|
attr_reader :frequency
|
@@ -323,8 +365,11 @@ module Scheduler
|
|
323
365
|
|
324
366
|
def determine_frequency
|
325
367
|
|
326
|
-
@frequency = @t.is_a?(Fixnum) || @t.is_a?(Float)
|
327
|
-
@t
|
368
|
+
@frequency = if @t.is_a?(Fixnum) || @t.is_a?(Float)
|
369
|
+
@t
|
370
|
+
else
|
371
|
+
Rufus.parse_duration_string(@t)
|
372
|
+
end
|
328
373
|
end
|
329
374
|
|
330
375
|
def determine_at
|
data/lib/rufus/sc/scheduler.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2006-
|
2
|
+
# Copyright (c) 2006-2012, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rufus/sc/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2006-
|
2
|
+
# Copyright (c) 2006-2012, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -26,7 +26,7 @@
|
|
26
26
|
module Rufus
|
27
27
|
module Scheduler
|
28
28
|
|
29
|
-
VERSION = '2.0.
|
29
|
+
VERSION = '2.0.17'
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
data/lib/rufus/scheduler.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2006-
|
2
|
+
# Copyright (c) 2006-2012, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
data/out.txt
ADDED
data/spec/at_spec.rb
CHANGED
@@ -113,5 +113,13 @@ describe "#{SCHEDULER_CLASS}#schedule_at" do
|
|
113
113
|
r.size.should == 3
|
114
114
|
r.first.class.should == Rufus::Scheduler::AtJob
|
115
115
|
end
|
116
|
+
|
117
|
+
it 'raises on unknown options' do
|
118
|
+
|
119
|
+
lambda {
|
120
|
+
@s.at Time.now + 3600, :first_at => (Time.now + 3600).to_s do
|
121
|
+
end
|
122
|
+
}.should raise_error(ArgumentError)
|
123
|
+
end
|
116
124
|
end
|
117
125
|
|
data/spec/cron_spec.rb
CHANGED
@@ -122,5 +122,13 @@ describe "#{SCHEDULER_CLASS}#cron" do
|
|
122
122
|
@s.jobs.size.should == 0
|
123
123
|
stack.should == %w[ ok ok ok done ]
|
124
124
|
end
|
125
|
+
|
126
|
+
it 'raises on unknown options' do
|
127
|
+
|
128
|
+
lambda {
|
129
|
+
@s.cron '* * * * *', :pool => :party do
|
130
|
+
end
|
131
|
+
}.should raise_error(ArgumentError)
|
132
|
+
end
|
125
133
|
end
|
126
134
|
|
data/spec/every_spec.rb
CHANGED
@@ -247,5 +247,13 @@ describe "#{SCHEDULER_CLASS}#every" do
|
|
247
247
|
|
248
248
|
$exceptions.size.should be > 1
|
249
249
|
end
|
250
|
+
|
251
|
+
it 'raises on unknown options' do
|
252
|
+
|
253
|
+
lambda {
|
254
|
+
@s.every '1s', :pool => :party do
|
255
|
+
end
|
256
|
+
}.should raise_error(ArgumentError)
|
257
|
+
end
|
250
258
|
end
|
251
259
|
|
data/spec/in_spec.rb
CHANGED
@@ -138,5 +138,13 @@ describe "#{SCHEDULER_CLASS}#in" do
|
|
138
138
|
@s.find_by_tag('spec').size.should == 1
|
139
139
|
@s.find_by_tag('spec').first.job_id.should == job.job_id
|
140
140
|
end
|
141
|
+
|
142
|
+
it 'raises on unknown options' do
|
143
|
+
|
144
|
+
lambda {
|
145
|
+
@s.in '2d', :first_at => (Time.now + 3600).to_s do
|
146
|
+
end
|
147
|
+
}.should raise_error(ArgumentError)
|
148
|
+
end
|
141
149
|
end
|
142
150
|
|
data/spec/schedulable_spec.rb
CHANGED
@@ -75,5 +75,23 @@ describe Rufus::Scheduler::Schedulable do
|
|
75
75
|
|
76
76
|
j.value.class.should == Rufus::Scheduler::InJob
|
77
77
|
end
|
78
|
+
|
79
|
+
class MySchedulable
|
80
|
+
def self.job
|
81
|
+
@@job
|
82
|
+
end
|
83
|
+
def self.call(job)
|
84
|
+
@@job = job
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'accepts schedulable classes as second param' do
|
89
|
+
|
90
|
+
@s.in '1s', MySchedulable
|
91
|
+
|
92
|
+
sleep 1.4
|
93
|
+
|
94
|
+
MySchedulable.job.class.should == Rufus::Scheduler::InJob
|
95
|
+
end
|
78
96
|
end
|
79
97
|
|
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.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
default_executable:
|
12
|
+
date: 2012-06-13 00:00:00.000000000Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: tzinfo
|
17
|
-
requirement: &
|
16
|
+
requirement: &2153074260 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ! '>='
|
@@ -22,10 +21,10 @@ dependencies:
|
|
22
21
|
version: 0.3.23
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153074260
|
26
25
|
- !ruby/object:Gem::Dependency
|
27
26
|
name: rake
|
28
|
-
requirement: &
|
27
|
+
requirement: &2153072940 !ruby/object:Gem::Requirement
|
29
28
|
none: false
|
30
29
|
requirements:
|
31
30
|
- - ! '>='
|
@@ -33,10 +32,10 @@ dependencies:
|
|
33
32
|
version: '0'
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153072940
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
name: rspec
|
39
|
-
requirement: &
|
38
|
+
requirement: &2153072180 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
40
|
requirements:
|
42
41
|
- - ! '>='
|
@@ -44,7 +43,7 @@ dependencies:
|
|
44
43
|
version: 2.7.0
|
45
44
|
type: :development
|
46
45
|
prerelease: false
|
47
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153072180
|
48
47
|
description: job scheduler for Ruby (at, cron, in and every jobs).
|
49
48
|
email:
|
50
49
|
- jmettraux@gmail.com
|
@@ -84,9 +83,9 @@ files:
|
|
84
83
|
- CHANGELOG.txt
|
85
84
|
- CREDITS.txt
|
86
85
|
- LICENSE.txt
|
86
|
+
- out.txt
|
87
87
|
- TODO.txt
|
88
88
|
- README.rdoc
|
89
|
-
has_rdoc: true
|
90
89
|
homepage: http://github.com/jmettraux/rufus-scheduler
|
91
90
|
licenses: []
|
92
91
|
post_install_message:
|
@@ -107,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
106
|
version: '0'
|
108
107
|
requirements: []
|
109
108
|
rubyforge_project: rufus
|
110
|
-
rubygems_version: 1.
|
109
|
+
rubygems_version: 1.8.11
|
111
110
|
signing_key:
|
112
111
|
specification_version: 3
|
113
112
|
summary: job scheduler for Ruby (at, cron, in and every jobs)
|