periodic-scheduler 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/periodic-scheduler.rb +12 -6
- data/periodic-scheduler.gemspec +3 -3
- data/spec/periodic-scheduler_spec.rb +26 -3
- metadata +69 -108
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/periodic-scheduler.rb
CHANGED
@@ -90,12 +90,10 @@ class PeriodicScheduler
|
|
90
90
|
@event_groups_to_unschedule << group
|
91
91
|
end
|
92
92
|
|
93
|
-
def run!
|
93
|
+
def run!(&block)
|
94
94
|
begin
|
95
95
|
loop do
|
96
|
-
run
|
97
|
-
yield error if block_given?
|
98
|
-
end
|
96
|
+
run(&block)
|
99
97
|
end
|
100
98
|
rescue EmptyScheduleError
|
101
99
|
end
|
@@ -130,12 +128,14 @@ class PeriodicScheduler
|
|
130
128
|
return run
|
131
129
|
end
|
132
130
|
|
131
|
+
objects = []
|
132
|
+
|
133
133
|
quants.each do |q|
|
134
134
|
events = @events[q]
|
135
135
|
@events.delete(q)
|
136
136
|
events.each do |e|
|
137
137
|
begin
|
138
|
-
e.call
|
138
|
+
objects << e.call
|
139
139
|
rescue StandardError => ex
|
140
140
|
errors << ex
|
141
141
|
end
|
@@ -143,7 +143,13 @@ class PeriodicScheduler
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
-
|
146
|
+
if block_given?
|
147
|
+
errors.each do |error|
|
148
|
+
yield error
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
objects
|
147
153
|
end
|
148
154
|
|
149
155
|
def empty?
|
data/periodic-scheduler.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "periodic-scheduler"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jakub Pastuszek"]
|
12
|
-
s.date = "2012-02-
|
12
|
+
s.date = "2012-02-08"
|
13
13
|
s.description = "Controls execution of periodic scheduled tasks."
|
14
14
|
s.email = "jpastuszek@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.homepage = "http://github.com/jpastuszek/periodic-scheduler"
|
35
35
|
s.licenses = ["MIT"]
|
36
36
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = "1.8.
|
37
|
+
s.rubygems_version = "1.8.15"
|
38
38
|
s.summary = "Scheduler for periodic tasks."
|
39
39
|
|
40
40
|
if s.respond_to? :specification_version then
|
@@ -326,7 +326,11 @@ describe PeriodicScheduler do
|
|
326
326
|
|
327
327
|
@options[:wait_function].call(35)
|
328
328
|
|
329
|
-
|
329
|
+
errors = []
|
330
|
+
s.run do |error|
|
331
|
+
errors << error
|
332
|
+
end
|
333
|
+
|
330
334
|
errors.should_not be_empty
|
331
335
|
errors[0].class.should == PeriodicScheduler::MissedScheduleError
|
332
336
|
@got_events.should == [1, 2]
|
@@ -340,10 +344,12 @@ describe PeriodicScheduler do
|
|
340
344
|
fail "test"
|
341
345
|
end
|
342
346
|
|
343
|
-
errors =
|
347
|
+
errors = []
|
344
348
|
|
345
349
|
lambda {
|
346
|
-
|
350
|
+
s.run do |error|
|
351
|
+
errors << error
|
352
|
+
end
|
347
353
|
}.should_not raise_exception
|
348
354
|
|
349
355
|
errors.should have(1).error
|
@@ -364,6 +370,23 @@ describe PeriodicScheduler do
|
|
364
370
|
s.run
|
365
371
|
}.should raise_error PeriodicScheduler::EmptyScheduleError
|
366
372
|
end
|
373
|
+
|
374
|
+
it "should provide array of objects returned by called shedule blocks" do
|
375
|
+
s = PeriodicScheduler.new(5.0, @options)
|
376
|
+
|
377
|
+
test = 0
|
378
|
+
|
379
|
+
s.schedule(11, true) do
|
380
|
+
test += 1
|
381
|
+
end
|
382
|
+
|
383
|
+
s.schedule(12) do
|
384
|
+
test += 1
|
385
|
+
end
|
386
|
+
|
387
|
+
s.run.should == [1, 2]
|
388
|
+
s.run.should == [3]
|
389
|
+
end
|
367
390
|
end
|
368
391
|
|
369
392
|
describe "#run!" do
|
metadata
CHANGED
@@ -1,123 +1,90 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: periodic-scheduler
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 0.2.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jakub Pastuszek
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-02-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &22600720 !ruby/object:Gem::Requirement
|
23
17
|
none: false
|
24
|
-
requirements:
|
18
|
+
requirements:
|
25
19
|
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 47
|
28
|
-
segments:
|
29
|
-
- 2
|
30
|
-
- 8
|
31
|
-
- 0
|
20
|
+
- !ruby/object:Gem::Version
|
32
21
|
version: 2.8.0
|
33
|
-
prerelease: false
|
34
|
-
name: rspec
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
22
|
type: :development
|
38
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
hash: 31
|
44
|
-
segments:
|
45
|
-
- 3
|
46
|
-
- 12
|
47
|
-
version: "3.12"
|
48
23
|
prerelease: false
|
24
|
+
version_requirements: *22600720
|
25
|
+
- !ruby/object:Gem::Dependency
|
49
26
|
name: rdoc
|
50
|
-
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
type: :development
|
53
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
27
|
+
requirement: &22598880 !ruby/object:Gem::Requirement
|
54
28
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
|
60
|
-
- 0
|
61
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.12'
|
33
|
+
type: :development
|
62
34
|
prerelease: false
|
35
|
+
version_requirements: *22598880
|
36
|
+
- !ruby/object:Gem::Dependency
|
63
37
|
name: cucumber
|
64
|
-
|
65
|
-
|
38
|
+
requirement: &22595540 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
66
44
|
type: :development
|
67
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *22595540
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: &22594720 !ruby/object:Gem::Requirement
|
68
50
|
none: false
|
69
|
-
requirements:
|
51
|
+
requirements:
|
70
52
|
- - ~>
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
hash: 23
|
73
|
-
segments:
|
74
|
-
- 1
|
75
|
-
- 0
|
76
|
-
- 0
|
53
|
+
- !ruby/object:Gem::Version
|
77
54
|
version: 1.0.0
|
78
|
-
prerelease: false
|
79
|
-
name: bundler
|
80
|
-
version_requirements: *id004
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
55
|
type: :development
|
83
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *22594720
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: jeweler
|
60
|
+
requirement: &22593900 !ruby/object:Gem::Requirement
|
84
61
|
none: false
|
85
|
-
requirements:
|
62
|
+
requirements:
|
86
63
|
- - ~>
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
hash: 49
|
89
|
-
segments:
|
90
|
-
- 1
|
91
|
-
- 8
|
92
|
-
- 3
|
64
|
+
- !ruby/object:Gem::Version
|
93
65
|
version: 1.8.3
|
94
|
-
prerelease: false
|
95
|
-
name: jeweler
|
96
|
-
version_requirements: *id005
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
66
|
type: :development
|
99
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
100
|
-
none: false
|
101
|
-
requirements:
|
102
|
-
- - ">="
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
hash: 3
|
105
|
-
segments:
|
106
|
-
- 0
|
107
|
-
version: "0"
|
108
67
|
prerelease: false
|
68
|
+
version_requirements: *22593900
|
69
|
+
- !ruby/object:Gem::Dependency
|
109
70
|
name: rcov
|
110
|
-
|
71
|
+
requirement: &22679440 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *22679440
|
111
80
|
description: Controls execution of periodic scheduled tasks.
|
112
81
|
email: jpastuszek@gmail.com
|
113
82
|
executables: []
|
114
|
-
|
115
83
|
extensions: []
|
116
|
-
|
117
|
-
extra_rdoc_files:
|
84
|
+
extra_rdoc_files:
|
118
85
|
- LICENSE.txt
|
119
86
|
- README.rdoc
|
120
|
-
files:
|
87
|
+
files:
|
121
88
|
- .document
|
122
89
|
- .rspec
|
123
90
|
- Gemfile
|
@@ -132,37 +99,31 @@ files:
|
|
132
99
|
- spec/periodic-scheduler_spec.rb
|
133
100
|
- spec/spec_helper.rb
|
134
101
|
homepage: http://github.com/jpastuszek/periodic-scheduler
|
135
|
-
licenses:
|
102
|
+
licenses:
|
136
103
|
- MIT
|
137
104
|
post_install_message:
|
138
105
|
rdoc_options: []
|
139
|
-
|
140
|
-
require_paths:
|
106
|
+
require_paths:
|
141
107
|
- lib
|
142
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
109
|
none: false
|
144
|
-
requirements:
|
145
|
-
- -
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
|
148
|
-
segments:
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
segments:
|
149
115
|
- 0
|
150
|
-
|
151
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
hash: -208021006100365845
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
118
|
none: false
|
153
|
-
requirements:
|
154
|
-
- -
|
155
|
-
- !ruby/object:Gem::Version
|
156
|
-
|
157
|
-
segments:
|
158
|
-
- 0
|
159
|
-
version: "0"
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
160
123
|
requirements: []
|
161
|
-
|
162
124
|
rubyforge_project:
|
163
|
-
rubygems_version: 1.8.
|
125
|
+
rubygems_version: 1.8.15
|
164
126
|
signing_key:
|
165
127
|
specification_version: 3
|
166
128
|
summary: Scheduler for periodic tasks.
|
167
129
|
test_files: []
|
168
|
-
|