rufus-scheduler 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
 
2
- require 'rufus/scheduler'
2
+ require 'rufus/scheduler/scheduler'
3
3
 
data/test/test.rb CHANGED
@@ -1,18 +1,20 @@
1
1
 
2
- require 'time_0_test'
3
- require 'time_1_test'
2
+ dir = File.dirname(__FILE__)
4
3
 
5
- require 'scheduler_name_test'
4
+ require dir + '/time_0_test'
5
+ require dir + '/time_1_test'
6
6
 
7
- require 'scheduler_0_test'
8
- require 'scheduler_1_test'
9
- require 'scheduler_2_test'
10
- require 'scheduler_3_test'
11
- require 'scheduler_4_test'
12
- require 'scheduler_5_test'
13
- require 'scheduler_6_test'
14
- require 'scheduler_7_test'
7
+ require dir + '/scheduler_name_test'
15
8
 
16
- require 'cron_test'
17
- require 'cronline_test'
9
+ require dir + '/scheduler_0_test'
10
+ require dir + '/scheduler_1_test'
11
+ require dir + '/scheduler_2_test'
12
+ require dir + '/scheduler_3_test'
13
+ require dir + '/scheduler_4_test'
14
+ require dir + '/scheduler_5_test'
15
+ require dir + '/scheduler_6_test'
16
+ require dir + '/scheduler_7_test'
17
+
18
+ require dir + '/cron_test'
19
+ require dir + '/cronline_test'
18
20
 
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.12
4
+ version: 1.0.13
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-12-18 00:00:00 +09:00
12
+ date: 2009-02-02 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -24,32 +24,17 @@ extra_rdoc_files:
24
24
  - CHANGELOG.txt
25
25
  - CREDITS.txt
26
26
  files:
27
- - lib/openwfe
28
- - lib/openwfe/util
29
- - lib/openwfe/util/scheduler.rb
30
- - lib/rufus
31
- - lib/rufus/cronline.rb
32
27
  - lib/rufus/otime.rb
28
+ - lib/rufus/scheduler/cronline.rb
29
+ - lib/rufus/scheduler/jobs.rb
30
+ - lib/rufus/scheduler/otime.rb
31
+ - lib/rufus/scheduler/scheduler.rb
33
32
  - lib/rufus/scheduler.rb
34
33
  - lib/rufus-scheduler.rb
35
- - test/cron_test.rb
36
- - test/cronline_test.rb
37
- - test/dev.rb
38
- - test/scheduler_0_test.rb
39
- - test/scheduler_1_test.rb
40
- - test/scheduler_2_test.rb
41
- - test/scheduler_3_test.rb
42
- - test/scheduler_4_test.rb
43
- - test/scheduler_5_test.rb
44
- - test/scheduler_6_test.rb
45
- - test/scheduler_7_test.rb
46
- - test/scheduler_name_test.rb
47
- - test/test.rb
48
- - test/time_0_test.rb
49
- - test/time_1_test.rb
50
- - README.txt
51
34
  - CHANGELOG.txt
52
35
  - CREDITS.txt
36
+ - LICENSE.txt
37
+ - README.txt
53
38
  has_rdoc: true
54
39
  homepage: http://openwferu.rubyforge.org/scheduler.html
55
40
  post_install_message:
@@ -71,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
56
  version:
72
57
  requirements: []
73
58
 
74
- rubyforge_project:
59
+ rubyforge_project: rufus
75
60
  rubygems_version: 1.3.1
76
61
  signing_key:
77
62
  specification_version: 2
@@ -1,41 +0,0 @@
1
- #
2
- #--
3
- # Copyright (c) 2006-2008, John Mettraux, jmettraux@gmail.com
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
22
- #++
23
- #
24
-
25
- require 'rufus/scheduler'
26
-
27
-
28
- #
29
- # An 'alias' to Rufus::Scheduler to keep backward compatibility for
30
- # the users of the gem 'openwferu-scheduler'.
31
- #
32
- module OpenWFE
33
-
34
- class Scheduler < Rufus::Scheduler
35
- end
36
-
37
- module Schedulable
38
- include Rufus::Schedulable
39
- end
40
- end
41
-
data/test/cron_test.rb DELETED
@@ -1,153 +0,0 @@
1
-
2
- #
3
- # Testing Rufus
4
- #
5
- # John Mettraux at openwfe.org
6
- #
7
- # Sun Oct 29 16:18:25 JST 2006
8
- #
9
-
10
- $:.unshift(File.dirname(__FILE__) + '/../lib')
11
-
12
- require 'test/unit'
13
- require 'rufus/scheduler'
14
-
15
-
16
- #
17
- # testing otime and the scheduler (its cron aspect)
18
- #
19
- class CronTest < Test::Unit::TestCase
20
-
21
- #def setup
22
- #end
23
-
24
- #def teardown
25
- #end
26
-
27
- def test_0
28
-
29
- $var = 0
30
-
31
- scheduler = Rufus::Scheduler.new
32
- scheduler.start
33
-
34
- sid = scheduler.schedule(
35
- '* * * * *',
36
- :schedulable => CounterSchedulable.new)
37
-
38
- assert sid, "scheduler did not return a job id"
39
-
40
- sleep 120
41
- scheduler.stop
42
-
43
- #puts ">#{$var}<"
44
-
45
- assert_equal 2, $var
46
- end
47
-
48
- def test_1
49
-
50
- scheduler = Rufus::Scheduler.new
51
- scheduler.start
52
-
53
- sec = nil
54
- has_gone_wrong = false
55
- counter = 0
56
-
57
- scheduler.schedule "* * * * * *" do
58
- t = Time.new
59
- if (t.sec == sec)
60
- has_gone_wrong = true
61
- # print "x"
62
- #else
63
- # print "."
64
- end
65
- #STDOUT.flush
66
- sec = t.sec
67
- counter = counter + 1
68
- end
69
-
70
- sleep 10
71
- scheduler.stop
72
-
73
- #assert_equal 10, counter
74
- assert [ 9, 10 ].include?(counter), "not 9 or 10 but #{counter}"
75
- assert (not has_gone_wrong)
76
- end
77
-
78
- def test_2
79
-
80
- scheduler = Rufus::Scheduler.new
81
- scheduler.start
82
-
83
- counter = 0
84
-
85
- scheduler.schedule "7 * * * * *" do
86
- counter += 1
87
- end
88
-
89
- sleep 61
90
- scheduler.stop
91
-
92
- assert_equal 1, counter
93
- # baby just one ... time
94
- end
95
-
96
- #
97
- # testing cron unschedule
98
- #
99
- def test_3
100
-
101
- scheduler = Rufus::Scheduler.new
102
- scheduler.start
103
-
104
- counter = 0
105
-
106
- job_id = scheduler.schedule "* * * * *" do
107
- counter += 1
108
- end
109
-
110
- sleep 0.300
111
-
112
- #puts "job_id : #{job_id}"
113
-
114
- assert_equal 1, scheduler.cron_job_count
115
- assert_equal 0, scheduler.find_schedulables("nada").size
116
-
117
- scheduler.unschedule job_id
118
-
119
- sleep 0.300
120
-
121
- assert_equal 0, scheduler.cron_job_count
122
-
123
- scheduler.stop
124
- end
125
-
126
- def test_4
127
-
128
- scheduler = Rufus::Scheduler.start_new
129
-
130
- val = nil
131
-
132
- job_id = scheduler.schedule "* * * * * *" do |job_id, cron_line, params|
133
- val = params.inspect
134
- end
135
-
136
- sleep 2
137
-
138
- assert_equal '{}', val
139
-
140
- scheduler.stop
141
- end
142
-
143
- protected
144
-
145
- class CounterSchedulable
146
- include Rufus::Schedulable
147
-
148
- def trigger (params)
149
- $var = $var + 1
150
- end
151
- end
152
-
153
- end
@@ -1,88 +0,0 @@
1
-
2
- #
3
- # Testing rufus-scheduler
4
- #
5
- # John Mettraux at openwfe.org
6
- #
7
- # Sun Oct 29 16:18:25 JST 2006
8
- #
9
-
10
- $:.unshift(File.dirname(__FILE__) + '/../lib')
11
-
12
- require 'test/unit'
13
- require 'rufus/scheduler'
14
-
15
-
16
- #
17
- # testing the Scheduler's CronLine system
18
- #
19
- class CronLineTest < Test::Unit::TestCase
20
-
21
- #def setup
22
- #end
23
-
24
- #def teardown
25
- #end
26
-
27
- def test_0
28
-
29
- dotest "* * * * *", [ [0], nil, nil, nil, nil, nil ]
30
- dotest "10-12 * * * *", [ [0], [10, 11, 12], nil, nil, nil, nil ]
31
- dotest "* * * * sun,mon", [ [0], nil, nil, nil, nil, [0, 1] ]
32
- dotest "* * * * mon-wed", [ [0], nil, nil, nil, nil, [1, 2, 3] ]
33
- dotest "* * * * 7", [ [0], nil, nil, nil, nil, [0] ]
34
- dotest "* * * * 0", [ [0], nil, nil, nil, nil, [0] ]
35
- dotest "* * * * 0,1", [ [0], nil, nil, nil, nil, [0,1] ]
36
- dotest "* * * * 7,1", [ [0], nil, nil, nil, nil, [0,1] ]
37
- dotest "* * * * 7,0", [ [0], nil, nil, nil, nil, [0] ]
38
- dotest "* * * * sun,2-4", [ [0], nil, nil, nil, nil, [0, 2, 3, 4] ]
39
-
40
- dotest "* * * * sun,mon-tue", [ [0], nil, nil, nil, nil, [0, 1, 2] ]
41
- #dotest "* * * * 7-1", [ [0], nil, nil, nil, nil, [0, 1, 2] ]
42
- end
43
-
44
- def test_1
45
-
46
- dotest "* * * * * *", [ nil, nil, nil, nil, nil, nil ]
47
- dotest "1 * * * * *", [ [1], nil, nil, nil, nil, nil ]
48
- dotest "7 10-12 * * * *", [ [7], [10, 11, 12], nil, nil, nil, nil ]
49
- dotest "1-5 * * * * *", [ [1,2,3,4,5], nil, nil, nil, nil, nil ]
50
- end
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
-
74
- protected
75
-
76
- def cl (cronline_string)
77
-
78
- Rufus::CronLine.new(cronline_string)
79
- end
80
-
81
- def dotest (line, array)
82
-
83
- cl = Rufus::CronLine.new(line)
84
-
85
- assert_equal array, cl.to_array
86
- end
87
-
88
- end
data/test/dev.rb DELETED
@@ -1,28 +0,0 @@
1
-
2
- #require 'rubygems'
3
- require 'rufus/scheduler'
4
-
5
- s = Rufus::Scheduler.new
6
- s.precision = 1.250
7
- #s.precision = 0.250
8
- #s.precision = 30
9
- s.start
10
-
11
- def compute_dev (s, t0, t1)
12
-
13
- return 0.0 unless t0
14
- s.precision - (t1 - t0)
15
- end
16
-
17
- tprev = nil
18
- tcurr = nil
19
-
20
- #s.schedule "* * * * * *" do
21
- s.schedule "* * * * *" do
22
- tprev = tcurr
23
- tcurr = Time.new
24
- puts "#{tcurr.to_s} #{tcurr.to_f} (#{compute_dev(s, tprev, tcurr)})"
25
- end
26
-
27
- s.join
28
-