onliner 0.0.2 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 549a72121023d07edb4cccebf78707366e9f110f
4
- data.tar.gz: c969b50fdc0042d8adc230bddfd2c412afc764a9
3
+ metadata.gz: 815e5bc8ff9054e693bfc0f452f419dce638055f
4
+ data.tar.gz: d8448f15ce046d696a502078a401dda2ba8955a8
5
5
  SHA512:
6
- metadata.gz: 5ea059561d4cf6466ecab30d234f968b6bd35464e16162b2b34e06cc18e0b81adfd9afe3a0595b181bc5609573005b43b0a3f8049bae80f94f6dd3539f7d4ed0
7
- data.tar.gz: 30f2d4cdd6ea780f680eadb909ec9c3efe9b666eebc394f5bf4c16824c43aeaa4a02b3c77f040fce197d289394462c5540c78dc6c121a12b1b83393e476931ca
6
+ metadata.gz: 9431a99ececb41636ec4596f5d44dbd9abbbc30a80967b16917b05b8661bc8b53a7712797c025a6727a8cd95769d9a7e77274ad489cfa9d33e0a88f62e8b01ed
7
+ data.tar.gz: 9a5726cc5886146746986963a562a8b28cd75282d285ff5720dd990adbb37a71f110578b116c31f62433b152a1ea321f5a9d2e17d9dc8c3550c4b2fb866f3899
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Onliner
2
2
 
3
- Gem for getting list of online users
3
+
4
+ Gem for Rails application - provides you list of online users (for authentication gem 'devise')
4
5
 
5
6
  ## Installation
6
7
 
@@ -20,14 +21,20 @@ For installing gem to your app run:
20
21
 
21
22
  For using functionality add to ApplicationControler:
22
23
 
23
- include Onliner
24
- before_filter { |c| c.track_user current_user unless current_user.nil?}
24
+ before_filter { |c| current_user.track unless current_user.nil?}
25
+
26
+ and In your model, add :lastseenable as such:
27
+
28
+ class User < ActiveRecord::Base
29
+ devise ..., :lastseenable
30
+ end
25
31
 
26
32
  Helper for online users list:
27
33
 
28
- online_users
34
+ Model.online, e.g. User.online, Admin.online
29
35
 
30
36
  ## Requirement
31
37
 
32
- Redis
33
- Devise
38
+ * Redis;
39
+
40
+ * Devise;
data/lib/onliner.rb CHANGED
@@ -1,21 +1,13 @@
1
1
  require "onliner/version"
2
- require "devise"
3
2
 
4
- module Onliner
5
- def online_users
6
- array_ids = []
7
- online_array = REDIS.hgetall "online"
3
+ unless defined?(Devise)
4
+ require 'devise'
5
+ end
8
6
 
9
- online_array.each do |k, v|
10
- if (Time.now - v.to_time <= 300)
11
- array_ids << k.to_i
12
- end
13
- end
7
+ require 'onliner'
14
8
 
15
- User.find( array_ids )
16
- end
9
+ Devise.add_module :onliner, :model => 'onliner/model'
17
10
 
18
- def track_user user
19
- REDIS.mapped_hmset "online", { user.id.to_s => "#{Time.now}" }
20
- end
11
+ module Onliner
21
12
  end
13
+
@@ -0,0 +1,26 @@
1
+ module Devise
2
+ module Models
3
+ module Onliner
4
+ extend ActiveSupport::Concern
5
+
6
+ module ClassMethods
7
+ def online
8
+ array_ids = []
9
+ online_array = REDIS.hgetall "o_#{self.to_s.downcase.pluralize}"
10
+
11
+ online_array.each do |k, v|
12
+ if (Time.now - v.to_time <= 300)
13
+ array_ids << k.to_i
14
+ end
15
+ end
16
+
17
+ self.find( array_ids )
18
+ end
19
+ end
20
+
21
+ def track
22
+ REDIS.mapped_hmset "o_#{self.class.to_s.downcase.pluralize}", { id.to_s => "#{Time.now}" }
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Onliner
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
data/onliner.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.version = Onliner::VERSION
10
10
  spec.authors = ["kbokhonko"]
11
11
  spec.email = ["kolya.bokhonko@gmail.com"]
12
- spec.description = "Who's online"
13
- spec.summary = %q{Who's online}
12
+ spec.description = "Gem for Rails application - provides you list of online users (for authentication gem 'devise')"
13
+ spec.summary = %q{Gem for Rails application - provides you list of online users (for authentication gem 'devise')}
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onliner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kbokhonko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-21 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,8 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.3.0
69
- description: Who's online
69
+ description: Gem for Rails application - provides you list of online users (for authentication
70
+ gem 'devise')
70
71
  email:
71
72
  - kolya.bokhonko@gmail.com
72
73
  executables: []
@@ -81,6 +82,7 @@ files:
81
82
  - lib/generators/onliner/install_generator.rb
82
83
  - lib/generators/templates/onliner.rb
83
84
  - lib/onliner.rb
85
+ - lib/onliner/model.rb
84
86
  - lib/onliner/version.rb
85
87
  - onliner.gemspec
86
88
  homepage:
@@ -106,5 +108,6 @@ rubyforge_project:
106
108
  rubygems_version: 2.0.3
107
109
  signing_key:
108
110
  specification_version: 4
109
- summary: Who's online
111
+ summary: Gem for Rails application - provides you list of online users (for authentication
112
+ gem 'devise')
110
113
  test_files: []