polling 0.0.5 → 0.0.7
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/polling.rb +1 -0
- data/lib/polling/confirm.rb +10 -5
- data/lib/polling/version.rb +1 -1
- data/test/test_confirm.rb +7 -0
- data/test/test_run.rb +2 -1
- data/test/test_target.rb +3 -0
- metadata +2 -2
data/lib/polling.rb
CHANGED
data/lib/polling/confirm.rb
CHANGED
@@ -10,7 +10,8 @@ module Polling
|
|
10
10
|
def check_arr(arr)
|
11
11
|
if arr.count == 1
|
12
12
|
time = convert(arr[0])
|
13
|
-
arr = time < 60 ? create_arr(time) : [time]
|
13
|
+
#arr = time < 60 ? create_arr(time) : [time]
|
14
|
+
arr = create_arr(time)
|
14
15
|
raise TypeError, "Please set a value that is divisible by 60." if (60 % time != 0) && time < 60
|
15
16
|
end
|
16
17
|
return arr
|
@@ -34,11 +35,15 @@ module Polling
|
|
34
35
|
|
35
36
|
def create_arr(time)
|
36
37
|
arr = Array.new
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
if time < 60
|
39
|
+
arr << 0 if time != 0
|
40
|
+
result = time
|
41
|
+
while time < 60
|
42
|
+
arr << time
|
43
|
+
time += result
|
44
|
+
end
|
45
|
+
else
|
40
46
|
arr << time
|
41
|
-
time += result
|
42
47
|
end
|
43
48
|
return arr
|
44
49
|
end
|
data/lib/polling/version.rb
CHANGED
data/test/test_confirm.rb
CHANGED
@@ -6,16 +6,23 @@ class PollingTest < Test::Unit::TestCase
|
|
6
6
|
assert_equal 0, Polling::Confirm::check_value("0")
|
7
7
|
assert_equal 60, Polling::Confirm::check_value(60)
|
8
8
|
assert_equal 5, Polling::Confirm::check_value("5")
|
9
|
+
end
|
9
10
|
|
11
|
+
def test_convert
|
10
12
|
assert_equal 5, Polling::Confirm::convert(5)
|
11
13
|
assert_equal 5, Polling::Confirm::convert("5")
|
12
14
|
assert_equal 5, Polling::Confirm::convert("5s")
|
13
15
|
assert_equal 300, Polling::Confirm::convert("5m")
|
14
16
|
assert_equal 18000, Polling::Confirm::convert("5h")
|
17
|
+
end
|
15
18
|
|
19
|
+
def test_check_arr
|
16
20
|
assert_equal ["0","10","20","30","40","50"], Polling::Confirm::check_arr(["0","10","20","30","40","50"])
|
17
21
|
assert_equal [0,10,20,30,40,50], Polling::Confirm::check_arr([0,10,20,30,40,50])
|
18
22
|
assert_equal [0,10,20,30,40,50], Polling::Confirm::check_arr(["10s"])
|
23
|
+
assert_equal [60], Polling::Confirm::check_arr(["1m"])
|
24
|
+
assert_equal [120], Polling::Confirm::check_arr(["2m"])
|
25
|
+
assert_equal [1800], Polling::Confirm::check_arr(["30m"])
|
19
26
|
assert_equal [0,10,20,30,40,50], Polling::Confirm::check_arr(["10"])
|
20
27
|
assert_equal [0,10,20,30,40,50], Polling::Confirm::check_arr([10])
|
21
28
|
assert_equal [0,30], Polling::Confirm::check_arr([30])
|
data/test/test_run.rb
CHANGED
data/test/test_target.rb
CHANGED
@@ -23,6 +23,9 @@ class PollingTest < Test::Unit::TestCase
|
|
23
23
|
assert_equal 300, Polling::Target::interval(300,debug)
|
24
24
|
assert_equal 300, Polling::Target::interval(300,debug)
|
25
25
|
assert_equal 3600, Polling::Target::interval(3600,debug)
|
26
|
+
|
27
|
+
Time.stubs(:now).returns(Time.parse "2012/11/19 10:16:00")
|
28
|
+
assert_equal 300, Polling::Target::interval(300,debug)
|
26
29
|
end
|
27
30
|
|
28
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: polling
|
15
15
|
email:
|