rufus-scheduler 2.0.6 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,7 +26,7 @@
26
26
  module Rufus
27
27
  module Scheduler
28
28
 
29
- VERSION = '2.0.6'
29
+ VERSION = '2.0.7'
30
30
  end
31
31
  end
32
32
 
@@ -36,7 +36,7 @@ module Rufus::Scheduler
36
36
  # If EventMachine is present and running will create an EmScheduler, else
37
37
  # it will create a PlainScheduler instance.
38
38
  #
39
- def self.start_new (opts={})
39
+ def self.start_new(opts={})
40
40
 
41
41
  if defined?(EM) and EM.reactor_running?
42
42
  EmScheduler.start_new(opts)
@@ -47,7 +47,7 @@ module Rufus::Scheduler
47
47
 
48
48
  # Returns true if the given string seems to be a cron string.
49
49
  #
50
- def self.is_cron_string (s)
50
+ def self.is_cron_string(s)
51
51
 
52
52
  s.match(/.+ .+ .+ .+ .+/) # well...
53
53
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rufus-scheduler}
8
- s.version = "2.0.6"
8
+ s.version = "2.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Mettraux"]
12
- s.date = %q{2010-05-01}
12
+ s.date = %q{2010-11-09}
13
13
  s.description = %q{
14
14
  job scheduler for Ruby (at, cron, in and every jobs).
15
15
 
@@ -21,7 +21,9 @@ Gem::Specification.new do |s|
21
21
  "README.rdoc"
22
22
  ]
23
23
  s.files = [
24
- "CHANGELOG.txt",
24
+ ".gitignore",
25
+ ".rspec",
26
+ "CHANGELOG.txt",
25
27
  "CREDITS.txt",
26
28
  "LICENSE.txt",
27
29
  "README.rdoc",
@@ -49,7 +51,6 @@ Gem::Specification.new do |s|
49
51
  "spec/rtime_spec.rb",
50
52
  "spec/schedulable_spec.rb",
51
53
  "spec/scheduler_spec.rb",
52
- "spec/spec.rb",
53
54
  "spec/spec_base.rb",
54
55
  "spec/stress_schedule_unschedule_spec.rb",
55
56
  "spec/timeout_spec.rb",
@@ -60,31 +61,46 @@ Gem::Specification.new do |s|
60
61
  s.rdoc_options = ["--charset=UTF-8"]
61
62
  s.require_paths = ["lib"]
62
63
  s.rubyforge_project = %q{rufus}
63
- s.rubygems_version = %q{1.3.6}
64
+ s.rubygems_version = %q{1.3.7}
64
65
  s.summary = %q{job scheduler for Ruby (at, cron, in and every jobs)}
65
66
  s.test_files = [
66
- "spec/spec.rb"
67
+ "spec/at_in_spec.rb",
68
+ "spec/at_spec.rb",
69
+ "spec/blocking_spec.rb",
70
+ "spec/cron_spec.rb",
71
+ "spec/cronline_spec.rb",
72
+ "spec/every_spec.rb",
73
+ "spec/exception_spec.rb",
74
+ "spec/in_spec.rb",
75
+ "spec/rtime_spec.rb",
76
+ "spec/schedulable_spec.rb",
77
+ "spec/scheduler_spec.rb",
78
+ "spec/spec_base.rb",
79
+ "spec/stress_schedule_unschedule_spec.rb",
80
+ "spec/timeout_spec.rb",
81
+ "test/kjw.rb",
82
+ "test/t.rb"
67
83
  ]
68
84
 
69
85
  if s.respond_to? :specification_version then
70
86
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
71
87
  s.specification_version = 3
72
88
 
73
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
89
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
90
+ s.add_runtime_dependency(%q<tzinfo>, [">= 0"])
74
91
  s.add_development_dependency(%q<rake>, [">= 0"])
75
- s.add_development_dependency(%q<yard>, [">= 0"])
76
- s.add_development_dependency(%q<bacon>, [">= 0"])
92
+ s.add_development_dependency(%q<rspec>, [">= 0"])
77
93
  s.add_development_dependency(%q<jeweler>, [">= 0"])
78
94
  else
95
+ s.add_dependency(%q<tzinfo>, [">= 0"])
79
96
  s.add_dependency(%q<rake>, [">= 0"])
80
- s.add_dependency(%q<yard>, [">= 0"])
81
- s.add_dependency(%q<bacon>, [">= 0"])
97
+ s.add_dependency(%q<rspec>, [">= 0"])
82
98
  s.add_dependency(%q<jeweler>, [">= 0"])
83
99
  end
84
100
  else
101
+ s.add_dependency(%q<tzinfo>, [">= 0"])
85
102
  s.add_dependency(%q<rake>, [">= 0"])
86
- s.add_dependency(%q<yard>, [">= 0"])
87
- s.add_dependency(%q<bacon>, [">= 0"])
103
+ s.add_dependency(%q<rspec>, [">= 0"])
88
104
  s.add_dependency(%q<jeweler>, [">= 0"])
89
105
  end
90
106
  end
@@ -5,20 +5,20 @@
5
5
  # Sun Mar 22 16:47:28 JST 2009
6
6
  #
7
7
 
8
- require File.dirname(__FILE__) + '/spec_base'
8
+ require File.join(File.dirname(__FILE__), 'spec_base')
9
9
 
10
10
 
11
11
  describe SCHEDULER_CLASS do
12
12
 
13
- before do
13
+ before(:each) do
14
14
  @s = start_scheduler
15
15
  end
16
- after do
16
+ after(:each) do
17
17
  stop_scheduler(@s)
18
18
  end
19
19
 
20
20
 
21
- it 'should override jobs with the same id' do
21
+ it 'overrides jobs with the same id' do
22
22
 
23
23
  hits = []
24
24
 
@@ -33,16 +33,15 @@ describe SCHEDULER_CLASS do
33
33
  end
34
34
 
35
35
  wait_next_tick
36
- @s.jobs.size.should.equal(1)
36
+ @s.jobs.size.should == 1
37
37
 
38
- hits.should.be.empty
38
+ hits.should == []
39
39
 
40
40
  sleep 1.5
41
41
 
42
- hits.should.equal([ 1 ])
42
+ hits.should == [ 1 ]
43
43
 
44
- @s.jobs.size.should.equal(0)
44
+ @s.jobs.size.should == 0
45
45
  end
46
-
47
46
  end
48
47
 
@@ -5,30 +5,30 @@
5
5
  # Sat Mar 21 20:19:30 JST 2009
6
6
  #
7
7
 
8
- require File.dirname(__FILE__) + '/spec_base'
8
+ require File.join(File.dirname(__FILE__), 'spec_base')
9
9
 
10
10
 
11
11
  describe "#{SCHEDULER_CLASS}#schedule_at" do
12
12
 
13
- before do
13
+ before(:each) do
14
14
  @s = start_scheduler
15
15
  end
16
- after do
16
+ after(:each) do
17
17
  stop_scheduler(@s)
18
18
  end
19
19
 
20
- it 'should have job ids with the class name in it' do
20
+ it 'has job ids with the class name in it' do
21
21
 
22
22
  j0 = @s.at(Time.now + 1) {}
23
- j0.job_id.should.match(/Rufus::Scheduler::AtJob/)
23
+ j0.job_id.should match(/Rufus::Scheduler::AtJob/)
24
24
  end
25
25
 
26
- it "should accept integers as 'at'" do
26
+ it "accepts integers as 'at'" do
27
27
 
28
- lambda { @s.at(1) {} }.should.not.raise
28
+ lambda { @s.at(1) {} }.should_not raise_error
29
29
  end
30
30
 
31
- it "should schedule at 'top + 1'" do
31
+ it "schedules at 'top + 1'" do
32
32
 
33
33
  var = nil
34
34
 
@@ -36,14 +36,14 @@ describe "#{SCHEDULER_CLASS}#schedule_at" do
36
36
  var = true
37
37
  end
38
38
 
39
- var.should.be.nil
39
+ var.should == nil
40
40
  sleep 1.5
41
41
 
42
- var.should.be.true
43
- @s.jobs.should.be.empty
42
+ var.should == true
43
+ @s.jobs.should == {}
44
44
  end
45
45
 
46
- it 'should trigger immediately jobs in the past' do
46
+ it 'triggers immediately jobs in the past' do
47
47
 
48
48
  var = nil
49
49
 
@@ -51,40 +51,39 @@ describe "#{SCHEDULER_CLASS}#schedule_at" do
51
51
  var = true
52
52
  end
53
53
 
54
- j.should.not.be.nil
54
+ j.should_not == nil
55
55
 
56
56
  #wait_next_tick
57
57
  sleep 0.500
58
58
 
59
- var.should.be.true
60
- @s.jobs.should.be.empty
59
+ var.should == true
60
+ @s.jobs.should == {}
61
61
  end
62
62
 
63
- it 'should unschedule' do
63
+ it 'unschedules' do
64
64
 
65
65
  job = @s.at Time.now + 3 * 3600 do
66
66
  end
67
67
 
68
68
  wait_next_tick
69
69
 
70
- @s.jobs.size.should.equal(1)
70
+ @s.jobs.size.should == 1
71
71
 
72
72
  @s.unschedule(job.job_id)
73
73
 
74
- @s.jobs.size.should.equal(0)
74
+ @s.jobs.size.should == 0
75
75
  end
76
76
 
77
- it 'should accept tags for jobs' do
77
+ it 'accepts tags for jobs' do
78
78
 
79
79
  job = @s.at Time.now + 3 * 3600, :tags => 'spec' do
80
80
  end
81
81
 
82
82
  wait_next_tick
83
83
 
84
- @s.find_by_tag('spec').size.should.equal(1)
85
- @s.find_by_tag('spec').first.job_id.should.equal(job.job_id)
84
+ @s.find_by_tag('spec').size.should == 1
85
+ @s.find_by_tag('spec').first.job_id.should == job.job_id
86
86
  end
87
-
88
87
  end
89
88
 
90
89
  describe Rufus::Scheduler::AtJob do
@@ -96,7 +95,7 @@ describe Rufus::Scheduler::AtJob do
96
95
  stop_scheduler(@s)
97
96
  end
98
97
 
99
- it 'should unschedule itself' do
98
+ it 'unschedules itself' do
100
99
 
101
100
  job = @s.at Time.now + 3 * 3600 do
102
101
  end
@@ -105,17 +104,17 @@ describe Rufus::Scheduler::AtJob do
105
104
 
106
105
  job.unschedule
107
106
 
108
- @s.jobs.size.should.equal(0)
107
+ @s.jobs.size.should == 0
109
108
  end
110
109
 
111
- it 'should respond to #next_time' do
110
+ it 'responds to #next_time' do
112
111
 
113
112
  t = Time.now + 3 * 3600
114
113
 
115
114
  job = @s.at Time.now + 3 * 3600 do
116
115
  end
117
116
 
118
- job.next_time.to_i.should.equal(t.to_i)
117
+ job.next_time.to_i.should == t.to_i
119
118
  end
120
119
  end
121
120
 
@@ -5,15 +5,15 @@
5
5
  # Sat Mar 21 17:36:36 JST 2009
6
6
  #
7
7
 
8
- require File.dirname(__FILE__) + '/spec_base'
8
+ require File.join(File.dirname(__FILE__), 'spec_base')
9
9
 
10
10
 
11
11
  describe SCHEDULER_CLASS do
12
12
 
13
- before do
13
+ before(:each) do
14
14
  @s = start_scheduler
15
15
  end
16
- after do
16
+ after(:each) do
17
17
  stop_scheduler(@s)
18
18
  end
19
19
 
@@ -29,7 +29,7 @@ describe SCHEDULER_CLASS do
29
29
  end
30
30
  end
31
31
 
32
- it 'should not block when :blocking => nil' do
32
+ it "doesn't block when :blocking => nil" do
33
33
 
34
34
  $var = []
35
35
  @s.in('1s') { JOB.call(1) }
@@ -37,10 +37,10 @@ describe SCHEDULER_CLASS do
37
37
 
38
38
  sleep 5.0
39
39
 
40
- [ %w{ a1 a2 b1 b2 }, %w{ a1 a2 b2 b1 } ].should.include($var)
40
+ [ %w{ a1 a2 b1 b2 }, %w{ a1 a2 b2 b1 } ].should include($var)
41
41
  end
42
42
 
43
- it 'should block when :blocking => true' do
43
+ it 'blocks when :blocking => true' do
44
44
 
45
45
  $var = []
46
46
  @s.in('1s', :blocking => true) { JOB.call(8) }
@@ -48,7 +48,7 @@ describe SCHEDULER_CLASS do
48
48
 
49
49
  sleep 4.5
50
50
 
51
- $var.should.equal(%w{ a8 b8 a9 b9 })
51
+ $var.should == %w[ a8 b8 a9 b9 ]
52
52
  end
53
53
  end
54
54
 
@@ -5,25 +5,25 @@
5
5
  # Sun Mar 22 19:59:12 JST 2009
6
6
  #
7
7
 
8
- require File.dirname(__FILE__) + '/spec_base'
8
+ require File.join(File.dirname(__FILE__), 'spec_base')
9
9
 
10
10
 
11
11
  describe "#{SCHEDULER_CLASS}#cron" do
12
12
 
13
- before do
13
+ before(:each) do
14
14
  @s = start_scheduler
15
15
  end
16
- after do
16
+ after(:each) do
17
17
  stop_scheduler(@s)
18
18
  end
19
19
 
20
- it 'should have job ids with the class name in it' do
20
+ it 'has job ids with the class name in it' do
21
21
 
22
22
  j0 = @s.cron('7 10-12 * * * *') {}
23
- j0.job_id.should.match(/Rufus::Scheduler::CronJob/)
23
+ j0.job_id.should match(/Rufus::Scheduler::CronJob/)
24
24
  end
25
25
 
26
- it 'should cron every second' do
26
+ it 'crons every second' do
27
27
 
28
28
  seconds = []
29
29
 
@@ -34,10 +34,10 @@ describe "#{SCHEDULER_CLASS}#cron" do
34
34
 
35
35
  job.unschedule
36
36
 
37
- seconds.uniq.size.should.equal(seconds.size)
37
+ seconds.uniq.size.should == seconds.size
38
38
  end
39
39
 
40
- it 'should unschedule' do
40
+ it 'unschedules' do
41
41
 
42
42
  second = nil
43
43
 
@@ -45,11 +45,11 @@ describe "#{SCHEDULER_CLASS}#cron" do
45
45
  second = job.last.sec
46
46
  end
47
47
 
48
- second.should.be.nil
48
+ second.should == nil
49
49
 
50
50
  sleep 2
51
51
 
52
- second.should.not.be.nil
52
+ second.should_not == nil
53
53
 
54
54
  job.unschedule
55
55
 
@@ -57,31 +57,31 @@ describe "#{SCHEDULER_CLASS}#cron" do
57
57
 
58
58
  sleep 2
59
59
 
60
- second.should.equal(after)
60
+ second.should == after
61
61
  end
62
62
 
63
- it 'should keep track of cron jobs' do
63
+ it 'keeps track of cron jobs' do
64
64
 
65
65
  j0 = @s.cron '7 10-12 * * * *' do
66
66
  end
67
67
  j1 = @s.cron '7 10-12 * * * *' do
68
68
  end
69
69
 
70
- @s.cron_jobs.keys.sort.should.equal([ j0.job_id, j1.job_id ].sort)
70
+ @s.cron_jobs.keys.sort.should == [ j0.job_id, j1.job_id ].sort
71
71
  end
72
72
 
73
- it 'should accept tags for jobs' do
73
+ it 'accepts tags for jobs' do
74
74
 
75
75
  job = @s.cron '* * * * * *', :tags => 'spec' do
76
76
  end
77
77
 
78
78
  wait_next_tick
79
79
 
80
- @s.find_by_tag('spec').size.should.equal(1)
81
- @s.find_by_tag('spec').first.job_id.should.equal(job.job_id)
80
+ @s.find_by_tag('spec').size.should == 1
81
+ @s.find_by_tag('spec').first.job_id.should == job.job_id
82
82
  end
83
83
 
84
- it 'should accept job.unschedule within the job' do
84
+ it 'accepts job.unschedule within the job' do
85
85
 
86
86
  stack = []
87
87
 
@@ -96,27 +96,27 @@ describe "#{SCHEDULER_CLASS}#cron" do
96
96
 
97
97
  sleep 4
98
98
 
99
- @s.jobs.size.should.equal(0)
100
- stack.should.equal(%w[ ok ok ok done ])
99
+ @s.jobs.size.should == 0
100
+ stack.should == %w[ ok ok ok done ]
101
101
  end
102
102
 
103
103
  end
104
104
 
105
105
  describe Rufus::Scheduler::CronJob do
106
106
 
107
- before do
107
+ before(:each) do
108
108
  @s = start_scheduler
109
109
  end
110
- after do
110
+ after(:each) do
111
111
  stop_scheduler(@s)
112
112
  end
113
113
 
114
- it 'should respond to #next_time' do
114
+ it 'responds to #next_time' do
115
115
 
116
116
  job = @s.cron '* * * * *' do
117
117
  end
118
118
 
119
- (job.next_time.to_i - Time.now.to_i).should.satisfy { |v| v < 60 }
119
+ (job.next_time.to_i - Time.now.to_i).should satisfy { |v| v < 60 }
120
120
  end
121
121
  end
122
122