session_tracker 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,8 +18,12 @@ class SessionTracker
18
18
  # so we don't want to raise errors just because redis is down for a few seconds.
19
19
  end
20
20
 
21
+ def active_users_data(timespan_in_minutes, time)
22
+ @redis.sunion(*keys_within(timespan_in_minutes, time))
23
+ end
24
+
21
25
  def active_users(timespan_in_minutes = 5, time = Time.now)
22
- @redis.sunion(*keys_within(timespan_in_minutes, time)).size
26
+ active_users_data(timespan_in_minutes, time).size
23
27
  end
24
28
 
25
29
  private
@@ -1,3 +1,3 @@
1
1
  class SessionTracker
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -44,7 +44,7 @@ describe SessionTracker, "active_users" do
44
44
 
45
45
  let(:redis) { mock.as_null_object }
46
46
 
47
- it "should do a union on the last 5 minutes to get a active user count" do
47
+ it "should do a union on the specified timespan to get a active user count" do
48
48
  time = Time.parse("13:09")
49
49
  redis.should_receive(:sunion).with("active_customer_sessions_minute_09",
50
50
  "active_customer_sessions_minute_08",
@@ -61,4 +61,9 @@ describe SessionTracker, "active_users" do
61
61
  SessionTracker.new("customer", redis).active_users.should == 2
62
62
  end
63
63
 
64
+ it "should be possible to access the data" do
65
+ redis.should_receive(:sunion).and_return([ :d1, :d2 ])
66
+ SessionTracker.new("customer", redis).active_users_data(3, Time.now).should == [ :d1, :d2 ]
67
+ end
68
+
64
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: session_tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-11 00:00:00.000000000 Z
12
+ date: 2012-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &2156132780 !ruby/object:Gem::Requirement
16
+ requirement: &2160331160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2156132780
24
+ version_requirements: *2160331160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2156132280 !ruby/object:Gem::Requirement
27
+ requirement: &2160330740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2156132280
35
+ version_requirements: *2160330740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: guard
38
- requirement: &2156131740 !ruby/object:Gem::Requirement
38
+ requirement: &2160330280 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2156131740
46
+ version_requirements: *2160330280
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard-rspec
49
- requirement: &2156131260 !ruby/object:Gem::Requirement
49
+ requirement: &2160329700 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2156131260
57
+ version_requirements: *2160329700
58
58
  description: Track active user sessions in redis
59
59
  email:
60
60
  - joakim.kolsjo@gmail.com