redis-session-retrieve 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.8.7"
4
+ - "1.9.2"
5
+ - "1.9.3"
6
+ - jruby-18mode # JRuby in 1.8 mode
7
+ - jruby-19mode # JRuby in 1.9 mode
8
+ - rbx-18mode
9
+ - rbx-19mode
10
+ # uncomment this line if your project needs to run something other than `rake`:
11
+ script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in redis-session-retrieve.gemspec
4
+ gemspec
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ redis-session-retrieve (0.0.1)
5
+ hiredis
6
+ mock_redis
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.1.3)
12
+ hiredis (0.4.5)
13
+ mock_redis (0.5.1)
14
+ rspec (2.11.0)
15
+ rspec-core (~> 2.11.0)
16
+ rspec-expectations (~> 2.11.0)
17
+ rspec-mocks (~> 2.11.0)
18
+ rspec-core (2.11.1)
19
+ rspec-expectations (2.11.3)
20
+ diff-lcs (~> 1.1.3)
21
+ rspec-mocks (2.11.2)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ redis-session-retrieve!
28
+ rspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,16 @@
1
+ require "redis-session-retrieve/version"
2
+ require "redis-session-retrieve/fetcher"
3
+
4
+
5
+ module RedisSessionRetrieve
6
+ class << self
7
+ attr_accessor :connection
8
+
9
+ def find_by_id session_id
10
+ RedisSessionRetrieve::Fetcher.connection = self.connection
11
+ RedisSessionRetrieve::Fetcher.find_by_id session_id
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path('serializer', File.dirname(__FILE__))
2
+
3
+ module RedisSessionRetrieve
4
+
5
+ class Fetcher
6
+
7
+ class << self
8
+ attr_accessor :connection
9
+
10
+ def initialize
11
+ end
12
+
13
+ def find_by_id session_id
14
+ session = @connection.get session_id
15
+
16
+ if session.nil?
17
+ return nil
18
+ else
19
+ return Serializer.deserialize session
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,13 @@
1
+ module RedisSessionRetrieve
2
+
3
+ class Serializer
4
+
5
+ class << self
6
+ def deserialize data
7
+ Marshal.load data
8
+ end
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,3 @@
1
+ module RedisSessionRetrieve
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,17 @@
1
+ #Redis Session Retrieve [![Build Status](https://secure.travis-ci.org/akeem/redis-session-retrieve.png)](http://travis-ci.org/akeem/redis-session-retrieve)
2
+
3
+ ## The itch to scratch.
4
+ A number of applications need to share session information.
5
+
6
+ 1. Application managing session information uses redis-store gem to
7
+ control flow of information related to session.
8
+
9
+ 2. Secondary applications retrieve session data from session store.
10
+
11
+ ## How do I use it.
12
+
13
+ 1. Setup the retrievel library by normal means. (the default should
14
+ default redis configuration, database 0)
15
+
16
+ 2. Find session data via the session id.
17
+
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "redis-session-retrieve/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "redis-session-retrieve"
7
+ s.version = RedisSessionRetrieve::VERSION
8
+ s.authors = ["Akeem Adeniji"]
9
+ s.email = ["akeem.adeniji@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Retrieve sessions stored in redis by redis-store}
12
+ s.description = %q{An easy way to retrieve session data store in redis via the redis-store gem}
13
+
14
+ s.rubyforge_project = "redis-session-retrieve"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency "rspec"
22
+ s.add_runtime_dependency "hiredis"
23
+ s.add_runtime_dependency "mock_redis"
24
+ end
@@ -0,0 +1,39 @@
1
+ require 'mock_redis'
2
+ require File.expand_path("redis-session-retrieve", File.dirname(__FILE__) + "/../lib/")
3
+
4
+ describe RedisSessionRetrieve::Fetcher do
5
+
6
+ let(:bootstrap_redis){
7
+ mr = MockRedis.new
8
+ mr.set("12345", Marshal.dump({:user_id => "the_one_handed_man"}))
9
+ RedisSessionRetrieve::Fetcher.connection = mr
10
+ }
11
+
12
+ let(:existing_session){RedisSessionRetrieve::Fetcher.find_by_id('12345')}
13
+ let(:missing_session){RedisSessionRetrieve::Fetcher.find_by_id('3333')}
14
+
15
+ before(:all) do
16
+ bootstrap_redis
17
+ end
18
+
19
+ describe ".find_by_id" do
20
+ context "when a matching session exists in the store" do
21
+
22
+ it "should not be empty" do
23
+ existing_session.should_not be_empty
24
+ end
25
+
26
+ it "should return the session data" do
27
+ existing_session.should_not be_nil
28
+ end
29
+ end
30
+
31
+ context "when a matching session does not exist in the store" do
32
+ it "should return nil" do
33
+ missing_session.should be_nil
34
+ end
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path("serializer", File.dirname(__FILE__) + "/../lib/redis-session-retrieve/")
2
+
3
+ describe RedisSessionRetrieve::Serializer do
4
+
5
+ describe ".deserialize" do
6
+ it "should deserialize the data passed" do
7
+ RedisSessionRetrieve::Serializer.deserialize("\x04\b{\x06:\tnameI\"\x0FOj Simpson\x06:\x06ET").should eql({:name => "Oj Simpson"})
8
+ end
9
+ end
10
+
11
+ end
12
+
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redis-session-retrieve
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Akeem Adeniji
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: hiredis
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: mock_redis
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: An easy way to retrieve session data store in redis via the redis-store
63
+ gem
64
+ email:
65
+ - akeem.adeniji@gmail.com
66
+ executables: []
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .travis.yml
71
+ - Gemfile
72
+ - Gemfile.lock
73
+ - Rakefile
74
+ - lib/redis-session-retrieve.rb
75
+ - lib/redis-session-retrieve/fetcher.rb
76
+ - lib/redis-session-retrieve/serializer.rb
77
+ - lib/redis-session-retrieve/version.rb
78
+ - readme.md
79
+ - redis-session-retrieve.gemspec
80
+ - spec/fetcher_spec.rb
81
+ - spec/serializer_spec.rb
82
+ homepage: ''
83
+ licenses: []
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project: redis-session-retrieve
102
+ rubygems_version: 1.8.24
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Retrieve sessions stored in redis by redis-store
106
+ test_files:
107
+ - spec/fetcher_spec.rb
108
+ - spec/serializer_spec.rb
109
+ has_rdoc: