rufus-scheduler 1.0 → 1.0.1
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/lib/rufus/scheduler.rb +9 -4
- data/test/test.rb +2 -0
- data/test/time_test.rb +84 -0
- metadata +2 -1
data/lib/rufus/scheduler.rb
CHANGED
@@ -247,7 +247,7 @@ module Rufus
|
|
247
247
|
#
|
248
248
|
# Starts this scheduler (or restart it if it was previously stopped)
|
249
249
|
#
|
250
|
-
def
|
250
|
+
def start
|
251
251
|
|
252
252
|
@stopped = false
|
253
253
|
|
@@ -276,13 +276,18 @@ module Rufus
|
|
276
276
|
#
|
277
277
|
# The scheduler is stoppable via sstop()
|
278
278
|
#
|
279
|
-
def
|
279
|
+
def stop
|
280
280
|
|
281
281
|
@stopped = true
|
282
282
|
end
|
283
283
|
|
284
|
-
|
285
|
-
|
284
|
+
# (for backward compatibility)
|
285
|
+
#
|
286
|
+
alias :sstart :start
|
287
|
+
|
288
|
+
# (for backward compatibility)
|
289
|
+
#
|
290
|
+
alias :sstop :stop
|
286
291
|
|
287
292
|
#
|
288
293
|
# Joins on the scheduler thread
|
data/test/test.rb
CHANGED
data/test/time_test.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# Testing OpenWFE
|
4
|
+
#
|
5
|
+
# John Mettraux at openwfe.org
|
6
|
+
#
|
7
|
+
# Sun Oct 29 16:18:25 JST 2006
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
require 'rufus/otime'
|
13
|
+
|
14
|
+
#
|
15
|
+
# testing otime and the scheduler
|
16
|
+
#
|
17
|
+
|
18
|
+
class TimeTest < Test::Unit::TestCase
|
19
|
+
|
20
|
+
#def setup
|
21
|
+
#end
|
22
|
+
|
23
|
+
#def teardown
|
24
|
+
#end
|
25
|
+
|
26
|
+
#def test_to_iso_date
|
27
|
+
def XXXX_to_iso_date
|
28
|
+
#
|
29
|
+
# well... this test is not timezone friendly...
|
30
|
+
# commented out thus...
|
31
|
+
|
32
|
+
t = 1169019813.93468
|
33
|
+
|
34
|
+
s = Rufus.to_iso8601_date(t)
|
35
|
+
puts s
|
36
|
+
|
37
|
+
assert \
|
38
|
+
Rufus.to_iso8601_date(t) == "2007-01-17 02:43:33-0500",
|
39
|
+
"conversion to iso8601 date failed"
|
40
|
+
|
41
|
+
d = Rufus.to_ruby_time(s)
|
42
|
+
|
43
|
+
#puts d.to_s
|
44
|
+
|
45
|
+
assert \
|
46
|
+
d.to_s == "2007-01-17T02:43:33-0500",
|
47
|
+
"iso8601 date parsing failed"
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_is_digit
|
51
|
+
|
52
|
+
for i in 0...9
|
53
|
+
si = "#{i}"
|
54
|
+
assert \
|
55
|
+
Rufus::is_digit?(si),
|
56
|
+
"'#{si}' should be a digit"
|
57
|
+
end
|
58
|
+
|
59
|
+
assert \
|
60
|
+
(not Rufus::is_digit?(1)),
|
61
|
+
"the integer 1 is not a character digit"
|
62
|
+
assert \
|
63
|
+
(not Rufus::is_digit?("a")),
|
64
|
+
"the character 'a' is not a character digit"
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_parse_time_string
|
68
|
+
|
69
|
+
pts("500", 0.5)
|
70
|
+
pts("1000", 1.0)
|
71
|
+
pts("1h", 3600.0)
|
72
|
+
pts("1h10s", 3610.0)
|
73
|
+
end
|
74
|
+
|
75
|
+
protected
|
76
|
+
|
77
|
+
def pts (time_string, seconds)
|
78
|
+
|
79
|
+
assert \
|
80
|
+
Rufus::parse_time_string(time_string) == seconds,
|
81
|
+
"'#{time_string}' did not map to #{seconds} seconds"
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
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:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- test/scheduler_3_test.rb
|
38
38
|
- test/scheduler_4_test.rb
|
39
39
|
- test/test.rb
|
40
|
+
- test/time_test.rb
|
40
41
|
- README.txt
|
41
42
|
- CHANGELOG.txt
|
42
43
|
has_rdoc: true
|