session_countdown 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -5
- data/VERSION +1 -1
- data/created.rid +1 -1
- data/lib/session_countdown.rb +5 -3
- data/session_countdown.gemspec +1 -1
- data/test/common/test_controller_test.rb +25 -20
- data/test/rails2x_root/test/functional/test_controller_test.rb +25 -20
- data/test/rails3x_root/Gemfile.lock +1 -1
- data/test/rails3x_root/test/functional/test_controller_test.rb +25 -20
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -5,13 +5,18 @@
|
|
5
5
|
A Ruby on Rails plugin that puts a countdown timer on the session
|
6
6
|
object.
|
7
7
|
|
8
|
-
session.countdown_start(
|
8
|
+
session.countdown_start(1.hour)
|
9
|
+
session.countdown_count #=> 3600
|
9
10
|
session.countdown_running? # => true
|
10
|
-
|
11
|
+
# 60 minutes pass
|
12
|
+
session.countdown_count #=> 0
|
11
13
|
session.countdown_running? # => false
|
12
14
|
session.countdown_expired? # => true
|
13
15
|
session.countdown_restart
|
14
16
|
session.countdown_running? # => true
|
17
|
+
session.countdown_abort
|
18
|
+
session.countdown_running? # => false
|
19
|
+
session.countdown_expired? # => false
|
15
20
|
|
16
21
|
=== But why?!?
|
17
22
|
|
@@ -26,7 +31,7 @@ authentication stuff, so why not combine the two?
|
|
26
31
|
== API
|
27
32
|
|
28
33
|
|
29
|
-
<i>Note that
|
34
|
+
<i>Note that countdown_abort(), countdown_restart() and
|
30
35
|
countdown_count() will throw a NoCountdown exception if called on a
|
31
36
|
non-existent countdown timer.</i>
|
32
37
|
|
@@ -43,7 +48,7 @@ Check if a countdown timer exists and is currently running
|
|
43
48
|
|
44
49
|
Expire early (i.e. logout)
|
45
50
|
|
46
|
-
session.
|
51
|
+
session.countdown_abort(name = :default)
|
47
52
|
|
48
53
|
Restart, using the duration supplied to countdown_start
|
49
54
|
|
@@ -101,7 +106,7 @@ Understanding timer running, expired, and never started
|
|
101
106
|
end
|
102
107
|
|
103
108
|
def logout
|
104
|
-
session.
|
109
|
+
session.countdown_abort
|
105
110
|
flash[:notice] = "You are now logged out"
|
106
111
|
redirect_to :index
|
107
112
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Fri, 06 Aug 2010
|
1
|
+
Fri, 06 Aug 2010 10:45:22 -0400
|
data/lib/session_countdown.rb
CHANGED
@@ -39,8 +39,8 @@ module SessionCountdown
|
|
39
39
|
|
40
40
|
## these methods all require a sanity check for existing countdown
|
41
41
|
|
42
|
-
def
|
43
|
-
self[get_zero_key(name)] =
|
42
|
+
def _countdown_abort(name = @@default_name)
|
43
|
+
self[get_zero_key(name)] = nil
|
44
44
|
end
|
45
45
|
|
46
46
|
def _countdown_restart(name = @@default_name)
|
@@ -65,7 +65,9 @@ module SessionCountdown
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def insist_countdown_exists(name = @@default_name)
|
68
|
-
|
68
|
+
# We use delta_key here because timer might have been nil'd by
|
69
|
+
# aborting, but it still should be restartable.
|
70
|
+
unless self[get_zero_delta_key(name)]
|
69
71
|
raise NoCountdown, "no session countdown named '#{name}'"
|
70
72
|
end
|
71
73
|
end
|
data/session_countdown.gemspec
CHANGED
@@ -21,10 +21,10 @@ class TestControllerTest < ActionController::TestCase
|
|
21
21
|
assert session.countdown_running?
|
22
22
|
assert ! session.countdown_expired?
|
23
23
|
|
24
|
-
session.
|
24
|
+
session.countdown_abort
|
25
25
|
|
26
26
|
assert ! session.countdown_running?
|
27
|
-
assert session.countdown_expired?
|
27
|
+
assert ! session.countdown_expired?
|
28
28
|
|
29
29
|
session.countdown_restart
|
30
30
|
assert ! session.countdown_expired?
|
@@ -45,9 +45,9 @@ class TestControllerTest < ActionController::TestCase
|
|
45
45
|
assert ! session.countdown_expired?
|
46
46
|
|
47
47
|
# with countdown expired
|
48
|
-
session.
|
48
|
+
session.countdown_abort
|
49
49
|
assert ! session.countdown_running?
|
50
|
-
assert session.countdown_expired?
|
50
|
+
assert ! session.countdown_expired?
|
51
51
|
|
52
52
|
end
|
53
53
|
|
@@ -59,27 +59,27 @@ class TestControllerTest < ActionController::TestCase
|
|
59
59
|
session.countdown_start(1.minute)
|
60
60
|
session.countdown_start(1.minute, :admin)
|
61
61
|
|
62
|
-
##
|
62
|
+
## abort default counter
|
63
63
|
|
64
64
|
assert session.countdown_running?
|
65
|
-
session.
|
65
|
+
session.countdown_abort
|
66
66
|
assert ! session.countdown_running?
|
67
|
-
assert session.countdown_expired?
|
67
|
+
assert ! session.countdown_expired?
|
68
68
|
|
69
|
-
##
|
69
|
+
## abort admin counter
|
70
70
|
|
71
71
|
assert session.countdown_running?(:admin)
|
72
|
-
session.
|
72
|
+
session.countdown_abort(:admin)
|
73
73
|
assert ! session.countdown_running?(:admin)
|
74
|
-
assert session.countdown_expired?(:admin)
|
74
|
+
assert ! session.countdown_expired?(:admin)
|
75
75
|
|
76
76
|
## mixing calls to both timers
|
77
77
|
|
78
78
|
session.countdown_start(1.minute)
|
79
79
|
assert session.countdown_running?()
|
80
80
|
assert ! session.countdown_running?(:admin)
|
81
|
-
session.
|
82
|
-
assert session.countdown_expired?(:admin)
|
81
|
+
session.countdown_abort
|
82
|
+
assert ! session.countdown_expired?(:admin)
|
83
83
|
session.countdown_restart(:admin)
|
84
84
|
assert session.countdown_running?(:admin)
|
85
85
|
assert ! session.countdown_expired?(:admin)
|
@@ -129,13 +129,13 @@ class TestControllerTest < ActionController::TestCase
|
|
129
129
|
# restart, expire and count require an existing countdown, should
|
130
130
|
# throw exception if there isn't one
|
131
131
|
|
132
|
-
assert_raise(NoCountdown) { session.
|
132
|
+
assert_raise(NoCountdown) { session.countdown_abort }
|
133
133
|
assert_raise(NoCountdown) { session.countdown_restart }
|
134
134
|
assert_raise(NoCountdown) { session.countdown_count }
|
135
135
|
|
136
136
|
## try with named countdown
|
137
137
|
|
138
|
-
assert_raise(NoCountdown) { session.
|
138
|
+
assert_raise(NoCountdown) { session.countdown_abort(:admin) }
|
139
139
|
assert_raise(NoCountdown) { session.countdown_restart(:admin) }
|
140
140
|
assert_raise(NoCountdown) { session.countdown_count(:admin) }
|
141
141
|
|
@@ -163,13 +163,18 @@ class TestControllerTest < ActionController::TestCase
|
|
163
163
|
# copied from README, mostly checking spelling
|
164
164
|
test "rdoc example" do
|
165
165
|
|
166
|
-
session.countdown_start(
|
167
|
-
|
168
|
-
session.
|
169
|
-
|
170
|
-
session.
|
166
|
+
session.countdown_start(1.hour)
|
167
|
+
assert (3599 < session.countdown_count)
|
168
|
+
assert session.countdown_running?
|
169
|
+
Timecop.travel(60.minute)
|
170
|
+
assert_equal 0, session.countdown_count
|
171
|
+
assert ! session.countdown_running?
|
172
|
+
assert session.countdown_expired?
|
171
173
|
session.countdown_restart
|
172
|
-
session.countdown_running?
|
174
|
+
assert session.countdown_running?
|
175
|
+
session.countdown_abort
|
176
|
+
assert ! session.countdown_running?
|
177
|
+
assert ! session.countdown_expired?
|
173
178
|
|
174
179
|
end
|
175
180
|
|
@@ -21,10 +21,10 @@ class TestControllerTest < ActionController::TestCase
|
|
21
21
|
assert session.countdown_running?
|
22
22
|
assert ! session.countdown_expired?
|
23
23
|
|
24
|
-
session.
|
24
|
+
session.countdown_abort
|
25
25
|
|
26
26
|
assert ! session.countdown_running?
|
27
|
-
assert session.countdown_expired?
|
27
|
+
assert ! session.countdown_expired?
|
28
28
|
|
29
29
|
session.countdown_restart
|
30
30
|
assert ! session.countdown_expired?
|
@@ -45,9 +45,9 @@ class TestControllerTest < ActionController::TestCase
|
|
45
45
|
assert ! session.countdown_expired?
|
46
46
|
|
47
47
|
# with countdown expired
|
48
|
-
session.
|
48
|
+
session.countdown_abort
|
49
49
|
assert ! session.countdown_running?
|
50
|
-
assert session.countdown_expired?
|
50
|
+
assert ! session.countdown_expired?
|
51
51
|
|
52
52
|
end
|
53
53
|
|
@@ -59,27 +59,27 @@ class TestControllerTest < ActionController::TestCase
|
|
59
59
|
session.countdown_start(1.minute)
|
60
60
|
session.countdown_start(1.minute, :admin)
|
61
61
|
|
62
|
-
##
|
62
|
+
## abort default counter
|
63
63
|
|
64
64
|
assert session.countdown_running?
|
65
|
-
session.
|
65
|
+
session.countdown_abort
|
66
66
|
assert ! session.countdown_running?
|
67
|
-
assert session.countdown_expired?
|
67
|
+
assert ! session.countdown_expired?
|
68
68
|
|
69
|
-
##
|
69
|
+
## abort admin counter
|
70
70
|
|
71
71
|
assert session.countdown_running?(:admin)
|
72
|
-
session.
|
72
|
+
session.countdown_abort(:admin)
|
73
73
|
assert ! session.countdown_running?(:admin)
|
74
|
-
assert session.countdown_expired?(:admin)
|
74
|
+
assert ! session.countdown_expired?(:admin)
|
75
75
|
|
76
76
|
## mixing calls to both timers
|
77
77
|
|
78
78
|
session.countdown_start(1.minute)
|
79
79
|
assert session.countdown_running?()
|
80
80
|
assert ! session.countdown_running?(:admin)
|
81
|
-
session.
|
82
|
-
assert session.countdown_expired?(:admin)
|
81
|
+
session.countdown_abort
|
82
|
+
assert ! session.countdown_expired?(:admin)
|
83
83
|
session.countdown_restart(:admin)
|
84
84
|
assert session.countdown_running?(:admin)
|
85
85
|
assert ! session.countdown_expired?(:admin)
|
@@ -129,13 +129,13 @@ class TestControllerTest < ActionController::TestCase
|
|
129
129
|
# restart, expire and count require an existing countdown, should
|
130
130
|
# throw exception if there isn't one
|
131
131
|
|
132
|
-
assert_raise(NoCountdown) { session.
|
132
|
+
assert_raise(NoCountdown) { session.countdown_abort }
|
133
133
|
assert_raise(NoCountdown) { session.countdown_restart }
|
134
134
|
assert_raise(NoCountdown) { session.countdown_count }
|
135
135
|
|
136
136
|
## try with named countdown
|
137
137
|
|
138
|
-
assert_raise(NoCountdown) { session.
|
138
|
+
assert_raise(NoCountdown) { session.countdown_abort(:admin) }
|
139
139
|
assert_raise(NoCountdown) { session.countdown_restart(:admin) }
|
140
140
|
assert_raise(NoCountdown) { session.countdown_count(:admin) }
|
141
141
|
|
@@ -163,13 +163,18 @@ class TestControllerTest < ActionController::TestCase
|
|
163
163
|
# copied from README, mostly checking spelling
|
164
164
|
test "rdoc example" do
|
165
165
|
|
166
|
-
session.countdown_start(
|
167
|
-
|
168
|
-
session.
|
169
|
-
|
170
|
-
session.
|
166
|
+
session.countdown_start(1.hour)
|
167
|
+
assert (3599 < session.countdown_count)
|
168
|
+
assert session.countdown_running?
|
169
|
+
Timecop.travel(60.minute)
|
170
|
+
assert_equal 0, session.countdown_count
|
171
|
+
assert ! session.countdown_running?
|
172
|
+
assert session.countdown_expired?
|
171
173
|
session.countdown_restart
|
172
|
-
session.countdown_running?
|
174
|
+
assert session.countdown_running?
|
175
|
+
session.countdown_abort
|
176
|
+
assert ! session.countdown_running?
|
177
|
+
assert ! session.countdown_expired?
|
173
178
|
|
174
179
|
end
|
175
180
|
|
@@ -21,10 +21,10 @@ class TestControllerTest < ActionController::TestCase
|
|
21
21
|
assert session.countdown_running?
|
22
22
|
assert ! session.countdown_expired?
|
23
23
|
|
24
|
-
session.
|
24
|
+
session.countdown_abort
|
25
25
|
|
26
26
|
assert ! session.countdown_running?
|
27
|
-
assert session.countdown_expired?
|
27
|
+
assert ! session.countdown_expired?
|
28
28
|
|
29
29
|
session.countdown_restart
|
30
30
|
assert ! session.countdown_expired?
|
@@ -45,9 +45,9 @@ class TestControllerTest < ActionController::TestCase
|
|
45
45
|
assert ! session.countdown_expired?
|
46
46
|
|
47
47
|
# with countdown expired
|
48
|
-
session.
|
48
|
+
session.countdown_abort
|
49
49
|
assert ! session.countdown_running?
|
50
|
-
assert session.countdown_expired?
|
50
|
+
assert ! session.countdown_expired?
|
51
51
|
|
52
52
|
end
|
53
53
|
|
@@ -59,27 +59,27 @@ class TestControllerTest < ActionController::TestCase
|
|
59
59
|
session.countdown_start(1.minute)
|
60
60
|
session.countdown_start(1.minute, :admin)
|
61
61
|
|
62
|
-
##
|
62
|
+
## abort default counter
|
63
63
|
|
64
64
|
assert session.countdown_running?
|
65
|
-
session.
|
65
|
+
session.countdown_abort
|
66
66
|
assert ! session.countdown_running?
|
67
|
-
assert session.countdown_expired?
|
67
|
+
assert ! session.countdown_expired?
|
68
68
|
|
69
|
-
##
|
69
|
+
## abort admin counter
|
70
70
|
|
71
71
|
assert session.countdown_running?(:admin)
|
72
|
-
session.
|
72
|
+
session.countdown_abort(:admin)
|
73
73
|
assert ! session.countdown_running?(:admin)
|
74
|
-
assert session.countdown_expired?(:admin)
|
74
|
+
assert ! session.countdown_expired?(:admin)
|
75
75
|
|
76
76
|
## mixing calls to both timers
|
77
77
|
|
78
78
|
session.countdown_start(1.minute)
|
79
79
|
assert session.countdown_running?()
|
80
80
|
assert ! session.countdown_running?(:admin)
|
81
|
-
session.
|
82
|
-
assert session.countdown_expired?(:admin)
|
81
|
+
session.countdown_abort
|
82
|
+
assert ! session.countdown_expired?(:admin)
|
83
83
|
session.countdown_restart(:admin)
|
84
84
|
assert session.countdown_running?(:admin)
|
85
85
|
assert ! session.countdown_expired?(:admin)
|
@@ -129,13 +129,13 @@ class TestControllerTest < ActionController::TestCase
|
|
129
129
|
# restart, expire and count require an existing countdown, should
|
130
130
|
# throw exception if there isn't one
|
131
131
|
|
132
|
-
assert_raise(NoCountdown) { session.
|
132
|
+
assert_raise(NoCountdown) { session.countdown_abort }
|
133
133
|
assert_raise(NoCountdown) { session.countdown_restart }
|
134
134
|
assert_raise(NoCountdown) { session.countdown_count }
|
135
135
|
|
136
136
|
## try with named countdown
|
137
137
|
|
138
|
-
assert_raise(NoCountdown) { session.
|
138
|
+
assert_raise(NoCountdown) { session.countdown_abort(:admin) }
|
139
139
|
assert_raise(NoCountdown) { session.countdown_restart(:admin) }
|
140
140
|
assert_raise(NoCountdown) { session.countdown_count(:admin) }
|
141
141
|
|
@@ -163,13 +163,18 @@ class TestControllerTest < ActionController::TestCase
|
|
163
163
|
# copied from README, mostly checking spelling
|
164
164
|
test "rdoc example" do
|
165
165
|
|
166
|
-
session.countdown_start(
|
167
|
-
|
168
|
-
session.
|
169
|
-
|
170
|
-
session.
|
166
|
+
session.countdown_start(1.hour)
|
167
|
+
assert (3599 < session.countdown_count)
|
168
|
+
assert session.countdown_running?
|
169
|
+
Timecop.travel(60.minute)
|
170
|
+
assert_equal 0, session.countdown_count
|
171
|
+
assert ! session.countdown_running?
|
172
|
+
assert session.countdown_expired?
|
171
173
|
session.countdown_restart
|
172
|
-
session.countdown_running?
|
174
|
+
assert session.countdown_running?
|
175
|
+
session.countdown_abort
|
176
|
+
assert ! session.countdown_running?
|
177
|
+
assert ! session.countdown_expired?
|
173
178
|
|
174
179
|
end
|
175
180
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: session_countdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kevin Swope
|