redis-rack 1.4.0.rc → 1.4.0.rc2

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