redis-rack 1.3.6 → 1.4.0.rc

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source "http://rubygems.org"
2
2
  gemspec
3
3
 
4
- gem 'redis-store', '~> 1.1.0', :path => File.expand_path('../../redis-store', __FILE__)
5
- gem 'SystemTimer', :platform => :mri_18
4
+ gem 'redis-store', '1.1.0.rc', :path => File.expand_path('../../redis-store', __FILE__)
data/Rakefile CHANGED
@@ -3,6 +3,12 @@ Bundler.setup
3
3
  require 'rake'
4
4
  require 'bundler/gem_tasks'
5
5
 
6
+ begin
7
+ require 'rdoc/task'
8
+ rescue LoadError
9
+ require 'rake/rdoctask'
10
+ end
11
+
6
12
  load 'tasks/redis.tasks.rb'
7
13
  task :default => 'redis:test:suite'
8
14
 
@@ -1,6 +1,5 @@
1
1
  require 'rack/session/abstract/id'
2
2
  require 'redis-store'
3
- require 'thread'
4
3
 
5
4
  module Rack
6
5
  module Session
@@ -8,13 +7,15 @@ module Rack
8
7
  attr_reader :mutex, :pool
9
8
 
10
9
  DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge \
11
- :redis_server => 'redis://127.0.0.1:6379/0/rack:session'
10
+ :namespace => 'rack:session',
11
+ :redis_server => 'redis://127.0.0.1:6379/0'
12
12
 
13
13
  def initialize(app, options = {})
14
14
  super
15
15
 
16
16
  @mutex = Mutex.new
17
- @pool = ::Redis::Factory.create @default_options[:redis_server]
17
+ options[:redis_server] ||= @default_options[:redis_server]
18
+ @pool = ::Redis::Factory.create options[:redis_server]
18
19
  end
19
20
 
20
21
  def generate_sid
@@ -37,8 +38,14 @@ module Rack
37
38
  end
38
39
 
39
40
  def set_session(env, session_id, new_session, options)
41
+ expiry = options[:expire_after].to_i
40
42
  with_lock(env, false) do
41
- @pool.set session_id, new_session, options
43
+ if expiry.zero?
44
+ @pool.set session_id, new_session
45
+ else
46
+ @pool.setex session_id, (expiry + 1), new_session
47
+ end
48
+
42
49
  session_id
43
50
  end
44
51
  end
@@ -1,3 +1,3 @@
1
1
  require 'redis-store'
2
- require 'redis/rack/version'
3
- require 'rack/session/redis'
2
+ require 'redis-rack/version'
3
+ require 'rack/session/redis'
@@ -1,6 +1,6 @@
1
1
  class Redis
2
2
  module Rack
3
- VERSION = '1.3.6'
3
+ VERSION = '1.4.0.rc'
4
4
  end
5
5
  end
6
6
 
@@ -1,25 +1,25 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
3
- require 'redis/rack/version'
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "redis/rack/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = 'redis-rack'
6
+ s.name = "redis-rack"
7
7
  s.version = Redis::Rack::VERSION
8
- s.authors = ['Luca Guidi', 'Matthew Horan']
9
- s.email = ['guidi.luca@gmail.com', 'matt@matthoran.com']
10
- s.homepage = 'http://jodosha.github.com/redis-store'
8
+ s.authors = ["Luca Guidi"]
9
+ s.email = ["guidi.luca@gmail.com"]
10
+ s.homepage = "http://jodosha.github.com/redis-store"
11
11
  s.summary = %q{Redis Store for Rack}
12
12
  s.description = %q{Redis Store for Rack}
13
13
 
14
- s.rubyforge_project = 'redis-rack'
14
+ s.rubyforge_project = "redis-rack"
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.require_paths = ['lib']
19
+ s.require_paths = ["lib"]
20
20
 
21
- s.add_runtime_dependency 'redis-store', '~> 1.1.0'
22
- s.add_runtime_dependency 'rack', '1.3.6'
21
+ s.add_runtime_dependency 'redis-store', '1.1.0.rc'
22
+ s.add_runtime_dependency 'rack', '1.4.0'
23
23
 
24
24
  s.add_development_dependency 'rake', '~> 0.9.2.2'
25
25
  s.add_development_dependency 'bundler', '~> 1.1.rc'
@@ -32,19 +32,9 @@ describe Rack::Session::Redis do
32
32
  # }.must_raise(Exception)
33
33
  # end
34
34
 
35
- it "uses the default Redis server and namespace when not provided" do
36
- pool = Rack::Session::Redis.new(incrementor)
37
- pool.pool.to_s.must_match(/127\.0\.0\.1:6379 against DB 0 with namespace rack:session$/)
38
- end
39
-
40
- it "uses the specified namespace when provided" do
35
+ it "passes options to Redis" do
41
36
  pool = Rack::Session::Redis.new(incrementor, :redis_server => {:namespace => 'test:rack:session'})
42
- pool.pool.to_s.must_match(/namespace test:rack:session$/)
43
- end
44
-
45
- it "uses the specified Redis server when provided" do
46
- pool = Rack::Session::Redis.new(incrementor, :redis_server => 'redis://127.0.0.1:6380/1')
47
- pool.pool.to_s.must_match(/127\.0\.0\.1:6380 against DB 1$/)
37
+ pool.pool.to_s.must_match('namespace test:rack:session')
48
38
  end
49
39
 
50
40
  it "creates a new cookie" do
@@ -102,15 +92,14 @@ describe Rack::Session::Redis do
102
92
  res = Rack::MockRequest.new(pool).get('/')
103
93
  res.body.must_include('"counter"=>1')
104
94
  cookie = res["Set-Cookie"]
105
- sid = cookie[session_match, 1]
106
95
  res = Rack::MockRequest.new(pool).get('/', "HTTP_COOKIE" => cookie)
107
- res["Set-Cookie"][session_match, 1].must_equal(sid)
96
+ res["Set-Cookie"].must_equal(cookie)
108
97
  res.body.must_include('"counter"=>2')
109
98
  puts 'Sleeping to expire session' if $DEBUG
110
99
  sleep 4
111
100
  res = Rack::MockRequest.new(pool).get('/', "HTTP_COOKIE" => cookie)
112
- res["Set-Cookie"][session_match, 1].wont_equal(sid)
113
- res.body.must_include('"counter"=>1')
101
+ res["Set-Cookie"].wont_equal(cookie)
102
+ res.body.must_include('"counter"=>3')
114
103
  end
115
104
 
116
105
  it "does not send the same session id if it did not change" do
@@ -118,7 +107,7 @@ describe Rack::Session::Redis do
118
107
  req = Rack::MockRequest.new(pool)
119
108
 
120
109
  res0 = req.get("/")
121
- cookie = res0["Set-Cookie"]
110
+ cookie = res0["Set-Cookie"][session_match]
122
111
  res0.body.must_equal('{"counter"=>1}')
123
112
 
124
113
  res1 = req.get("/", "HTTP_COOKIE" => cookie)
@@ -286,4 +275,4 @@ describe Rack::Session::Redis do
286
275
  session['counter'].must_be_nil
287
276
  session['foo'].must_equal('bar')
288
277
  end
289
- end
278
+ end
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  describe Redis::Rack::VERSION do
4
- it "must be equal to 1.3.6" do
5
- Redis::Rack::VERSION.must_equal '1.3.6'
4
+ it "must be equal to 1.4.0.rc" do
5
+ Redis::Rack::VERSION.must_equal '1.4.0.rc'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,102 +1,147 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: redis-rack
3
- version: !ruby/object:Gem::Version
4
- version: 1.3.6
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: 7712042
5
+ prerelease: 6
6
+ segments:
7
+ - 1
8
+ - 4
9
+ - 0
10
+ - rc
11
+ version: 1.4.0.rc
6
12
  platform: ruby
7
- authors:
13
+ authors:
8
14
  - Luca Guidi
9
- - Matthew Horan
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2012-03-02 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
18
+
19
+ date: 2011-12-30 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
16
22
  name: redis-store
17
- requirement: &70242081366740 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
18
25
  none: false
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: 1.1.0
26
+ requirements:
27
+ - - "="
28
+ - !ruby/object:Gem::Version
29
+ hash: 7712002
30
+ segments:
31
+ - 1
32
+ - 1
33
+ - 0
34
+ - rc
35
+ version: 1.1.0.rc
23
36
  type: :runtime
24
- prerelease: false
25
- version_requirements: *70242081366740
26
- - !ruby/object:Gem::Dependency
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
27
39
  name: rack
28
- requirement: &70242081366180 !ruby/object:Gem::Requirement
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
29
42
  none: false
30
- requirements:
31
- - - =
32
- - !ruby/object:Gem::Version
33
- version: 1.3.6
43
+ requirements:
44
+ - - "="
45
+ - !ruby/object:Gem::Version
46
+ hash: 7
47
+ segments:
48
+ - 1
49
+ - 4
50
+ - 0
51
+ version: 1.4.0
34
52
  type: :runtime
35
- prerelease: false
36
- version_requirements: *70242081366180
37
- - !ruby/object:Gem::Dependency
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
38
55
  name: rake
39
- requirement: &70242081365680 !ruby/object:Gem::Requirement
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
40
58
  none: false
41
- requirements:
59
+ requirements:
42
60
  - - ~>
43
- - !ruby/object:Gem::Version
61
+ - !ruby/object:Gem::Version
62
+ hash: 11
63
+ segments:
64
+ - 0
65
+ - 9
66
+ - 2
67
+ - 2
44
68
  version: 0.9.2.2
45
69
  type: :development
46
- prerelease: false
47
- version_requirements: *70242081365680
48
- - !ruby/object:Gem::Dependency
70
+ version_requirements: *id003
71
+ - !ruby/object:Gem::Dependency
49
72
  name: bundler
50
- requirement: &70242081365180 !ruby/object:Gem::Requirement
73
+ prerelease: false
74
+ requirement: &id004 !ruby/object:Gem::Requirement
51
75
  none: false
52
- requirements:
76
+ requirements:
53
77
  - - ~>
54
- - !ruby/object:Gem::Version
78
+ - !ruby/object:Gem::Version
79
+ hash: 7712070
80
+ segments:
81
+ - 1
82
+ - 1
83
+ - rc
55
84
  version: 1.1.rc
56
85
  type: :development
57
- prerelease: false
58
- version_requirements: *70242081365180
59
- - !ruby/object:Gem::Dependency
86
+ version_requirements: *id004
87
+ - !ruby/object:Gem::Dependency
60
88
  name: mocha
61
- requirement: &70242081364720 !ruby/object:Gem::Requirement
89
+ prerelease: false
90
+ requirement: &id005 !ruby/object:Gem::Requirement
62
91
  none: false
63
- requirements:
92
+ requirements:
64
93
  - - ~>
65
- - !ruby/object:Gem::Version
94
+ - !ruby/object:Gem::Version
95
+ hash: 55
96
+ segments:
97
+ - 0
98
+ - 10
99
+ - 0
66
100
  version: 0.10.0
67
101
  type: :development
68
- prerelease: false
69
- version_requirements: *70242081364720
70
- - !ruby/object:Gem::Dependency
102
+ version_requirements: *id005
103
+ - !ruby/object:Gem::Dependency
71
104
  name: minitest
72
- requirement: &70242081364200 !ruby/object:Gem::Requirement
105
+ prerelease: false
106
+ requirement: &id006 !ruby/object:Gem::Requirement
73
107
  none: false
74
- requirements:
108
+ requirements:
75
109
  - - ~>
76
- - !ruby/object:Gem::Version
110
+ - !ruby/object:Gem::Version
111
+ hash: 47
112
+ segments:
113
+ - 2
114
+ - 8
115
+ - 0
77
116
  version: 2.8.0
78
117
  type: :development
79
- prerelease: false
80
- version_requirements: *70242081364200
81
- - !ruby/object:Gem::Dependency
118
+ version_requirements: *id006
119
+ - !ruby/object:Gem::Dependency
82
120
  name: purdytest
83
- requirement: &70242081363280 !ruby/object:Gem::Requirement
121
+ prerelease: false
122
+ requirement: &id007 !ruby/object:Gem::Requirement
84
123
  none: false
85
- requirements:
124
+ requirements:
86
125
  - - ~>
87
- - !ruby/object:Gem::Version
126
+ - !ruby/object:Gem::Version
127
+ hash: 23
128
+ segments:
129
+ - 1
130
+ - 0
131
+ - 0
88
132
  version: 1.0.0
89
133
  type: :development
90
- prerelease: false
91
- version_requirements: *70242081363280
134
+ version_requirements: *id007
92
135
  description: Redis Store for Rack
93
- email:
136
+ email:
94
137
  - guidi.luca@gmail.com
95
- - matt@matthoran.com
96
138
  executables: []
139
+
97
140
  extensions: []
141
+
98
142
  extra_rdoc_files: []
99
- files:
143
+
144
+ files:
100
145
  - .gitignore
101
146
  - Gemfile
102
147
  - MIT-LICENSE
@@ -111,29 +156,41 @@ files:
111
156
  - test/test_helper.rb
112
157
  homepage: http://jodosha.github.com/redis-store
113
158
  licenses: []
159
+
114
160
  post_install_message:
115
161
  rdoc_options: []
116
- require_paths:
162
+
163
+ require_paths:
117
164
  - lib
118
- required_ruby_version: !ruby/object:Gem::Requirement
165
+ required_ruby_version: !ruby/object:Gem::Requirement
119
166
  none: false
120
- requirements:
121
- - - ! '>='
122
- - !ruby/object:Gem::Version
123
- version: '0'
124
- required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ hash: 3
171
+ segments:
172
+ - 0
173
+ version: "0"
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
175
  none: false
126
- requirements:
127
- - - ! '>='
128
- - !ruby/object:Gem::Version
129
- version: '0'
176
+ requirements:
177
+ - - ">"
178
+ - !ruby/object:Gem::Version
179
+ hash: 25
180
+ segments:
181
+ - 1
182
+ - 3
183
+ - 1
184
+ version: 1.3.1
130
185
  requirements: []
186
+
131
187
  rubyforge_project: redis-rack
132
- rubygems_version: 1.8.15
188
+ rubygems_version: 1.8.6
133
189
  signing_key:
134
190
  specification_version: 3
135
191
  summary: Redis Store for Rack
136
- test_files:
192
+ test_files:
137
193
  - test/rack/session/redis_test.rb
138
194
  - test/redis/rack/version_test.rb
139
195
  - test/test_helper.rb
196
+ has_rdoc: