redis-session-store 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43c209eb4dbc6cc3feedd7138dcc6cfbb6e4be35
4
- data.tar.gz: e29f05d4800a9bf8453ad3f24504295d5fd21408
3
+ metadata.gz: 0158a4d89d8a2848b75766683f7e6e5add9c5d4f
4
+ data.tar.gz: 9551ca90b67dad5c67ab4d028ee5a0bbafe1ef58
5
5
  SHA512:
6
- metadata.gz: 91de3d098790b0d015bb463ecf28a21d5b84ba1eee2d7a2e8b2b6646231e6265b2c1933d99e825aa0ac8fa03945409b5b3ef03429e1d1599d8239f471f2ce1f0
7
- data.tar.gz: 5797ce680e25ccb54e48cb4b5e2720be2287e7facedec7c28940b54a7f8fb1aa1bac91553797a01a02176650058032c3708e89b53b3d8506511472667620f7b7
6
+ metadata.gz: 587a5a53e8df3fd350c95600754737fef57b697db50834e5e8113a41841c186aa6a4a3f918c3755010a49e0ff62abb80a70f2bcf67c6d83990256de343a49649
7
+ data.tar.gz: 6bfe6da52599e3ffabc5dfbbea48aedd36f655b2e5ac33023112fffc6e4907105990d1673b7dca816bd0119a3ed105870522556e517e95b1dcfadf353a64fa5e
data/.rubocop_todo.yml CHANGED
@@ -8,4 +8,4 @@
8
8
  # Offense count: 1
9
9
  # Configuration parameters: CountComments.
10
10
  Metrics/ClassLength:
11
- Max: 101
11
+ Max: 107
data/.travis.yml CHANGED
@@ -1,9 +1,13 @@
1
1
  ---
2
2
  language: ruby
3
+ sudo: false
3
4
  rvm:
4
5
  - 1.9.3
5
- - 2.0.0
6
- - 2.1.0
6
+ - 2.1.3
7
+ - jruby-19mode
8
+ matrix:
9
+ allow_failures:
10
+ - rvm: jruby-19mode
7
11
  notifications:
8
12
  email: false
9
13
  deploy:
@@ -14,5 +18,4 @@ deploy:
14
18
  on:
15
19
  tags: true
16
20
  repo: roidrage/redis-session-store
17
- branch: master
18
- rvm: 2.0.0
21
+ rvm: 2.1.3
data/AUTHORS.md CHANGED
@@ -14,3 +14,4 @@ Redis Session Store authors
14
14
  - Michael Xavier
15
15
  - Olek Poplavsky
16
16
  - Tim Lossen
17
+ - Todd Bealmear
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  redis-session-store history
2
2
  ===========================
3
3
 
4
+ ## v0.8.1 (2016-01-25)
5
+
6
+ * Support for Rails 5 and Rack 2
7
+ * Expand error support for redis-rb v3 gem
8
+
4
9
  ## v0.8.0 (2014-08-28)
5
10
 
6
11
  * Allow for injection of custom redis client
@@ -4,10 +4,14 @@ require 'redis'
4
4
  # Redis session storage for Rails, and for Rails only. Derived from
5
5
  # the MemCacheStore code, simply dropping in Redis instead.
6
6
  class RedisSessionStore < ActionDispatch::Session::AbstractStore
7
- VERSION = '0.8.0'
7
+ VERSION = '0.8.1'
8
8
  # Rails 3.1 and beyond defines the constant elsewhere
9
9
  unless defined?(ENV_SESSION_OPTIONS_KEY)
10
- ENV_SESSION_OPTIONS_KEY = Rack::Session::Abstract::ENV_SESSION_OPTIONS_KEY
10
+ if Rack.release.split('.').first.to_i > 1
11
+ ENV_SESSION_OPTIONS_KEY = Rack::RACK_SESSION_OPTIONS
12
+ else
13
+ ENV_SESSION_OPTIONS_KEY = Rack::Session::Abstract::ENV_SESSION_OPTIONS_KEY
14
+ end
11
15
  end
12
16
 
13
17
  # ==== Options
@@ -69,7 +73,7 @@ class RedisSessionStore < ActionDispatch::Session::AbstractStore
69
73
  value && !value.empty? &&
70
74
  redis.exists(prefixed(value))
71
75
  )
72
- rescue Errno::ECONNREFUSED => e
76
+ rescue Errno::ECONNREFUSED, Redis::CannotConnectError => e
73
77
  on_redis_down.call(e, env, value) if on_redis_down
74
78
 
75
79
  true
@@ -94,10 +98,11 @@ class RedisSessionStore < ActionDispatch::Session::AbstractStore
94
98
  end
95
99
 
96
100
  [sid, session]
97
- rescue Errno::ECONNREFUSED => e
101
+ rescue Errno::ECONNREFUSED, Redis::CannotConnectError => e
98
102
  on_redis_down.call(e, env, sid) if on_redis_down
99
103
  [generate_sid, {}]
100
104
  end
105
+ alias_method :find_session, :get_session
101
106
 
102
107
  def load_session_from_redis(sid)
103
108
  data = redis.get(prefixed(sid))
@@ -114,7 +119,7 @@ class RedisSessionStore < ActionDispatch::Session::AbstractStore
114
119
  serializer.load(data)
115
120
  end
116
121
 
117
- def set_session(env, sid, session_data, options = nil) # rubocop: disable MethodLength, LineLength
122
+ def set_session(env, sid, session_data, options = nil)
118
123
  expiry = (options || env.fetch(ENV_SESSION_OPTIONS_KEY))[:expire_after]
119
124
  if expiry
120
125
  redis.setex(prefixed(sid), expiry, encode(session_data))
@@ -122,10 +127,11 @@ class RedisSessionStore < ActionDispatch::Session::AbstractStore
122
127
  redis.set(prefixed(sid), encode(session_data))
123
128
  end
124
129
  return sid
125
- rescue Errno::ECONNREFUSED => e
130
+ rescue Errno::ECONNREFUSED, Redis::CannotConnectError => e
126
131
  on_redis_down.call(e, env, sid) if on_redis_down
127
132
  return false
128
133
  end
134
+ alias_method :write_session, :set_session
129
135
 
130
136
  def encode(session_data)
131
137
  serializer.dump(session_data)
@@ -137,7 +143,7 @@ class RedisSessionStore < ActionDispatch::Session::AbstractStore
137
143
 
138
144
  def destroy(env)
139
145
  if env['rack.request.cookie_hash'] &&
140
- (sid = env['rack.request.cookie_hash'][key])
146
+ (sid = env['rack.request.cookie_hash'][key])
141
147
  destroy_session_from_sid(sid, drop: true, env: env)
142
148
  end
143
149
  false
@@ -146,7 +152,7 @@ class RedisSessionStore < ActionDispatch::Session::AbstractStore
146
152
  def destroy_session_from_sid(sid, options = {})
147
153
  redis.del(prefixed(sid))
148
154
  (options || {})[:drop] ? nil : generate_sid
149
- rescue Errno::ECONNREFUSED => e
155
+ rescue Errno::ECONNREFUSED, Redis::CannotConnectError => e
150
156
  on_redis_down.call(e, options[:env] || {}, sid) if on_redis_down
151
157
  end
152
158
 
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
19
19
  .match(/^ VERSION = '(.*)'/)[1]
20
20
 
21
21
  gem.add_runtime_dependency 'redis'
22
- gem.add_runtime_dependency 'actionpack', '>= 3', '< 5'
22
+ gem.add_runtime_dependency 'actionpack', '>= 3', '< 5.1'
23
23
 
24
24
  gem.add_development_dependency 'fakeredis'
25
25
  gem.add_development_dependency 'rake'
@@ -149,7 +149,7 @@ describe RedisSessionStore do
149
149
 
150
150
  context 'when unsuccessfully persisting the session' do
151
151
  before do
152
- allow(store).to receive(:redis).and_raise(Errno::ECONNREFUSED)
152
+ allow(store).to receive(:redis).and_raise(Redis::CannotConnectError)
153
153
  end
154
154
 
155
155
  it 'returns false' do
@@ -169,7 +169,7 @@ describe RedisSessionStore do
169
169
 
170
170
  context 'when redis is down' do
171
171
  before do
172
- allow(store).to receive(:redis).and_raise(Errno::ECONNREFUSED)
172
+ allow(store).to receive(:redis).and_raise(Redis::CannotConnectError)
173
173
  store.on_redis_down = ->(*_a) { @redis_down_handled = true }
174
174
  end
175
175
 
@@ -189,7 +189,7 @@ describe RedisSessionStore do
189
189
  it 'explodes' do
190
190
  expect do
191
191
  store.send(:set_session, env, session_id, session_data, options)
192
- end.to raise_error(Errno::ECONNREFUSED)
192
+ end.to raise_error(Redis::CannotConnectError)
193
193
  end
194
194
  end
195
195
  end
@@ -243,7 +243,7 @@ describe RedisSessionStore do
243
243
 
244
244
  context 'when redis is down' do
245
245
  it 'returns true (fallback to old behavior)' do
246
- allow(store).to receive(:redis).and_raise(Errno::ECONNREFUSED)
246
+ allow(store).to receive(:redis).and_raise(Redis::CannotConnectError)
247
247
  expect(store.send(:session_exists?, :env)).to eq(true)
248
248
  end
249
249
  end
@@ -270,7 +270,7 @@ describe RedisSessionStore do
270
270
 
271
271
  context 'when redis is down' do
272
272
  before do
273
- allow(store).to receive(:redis).and_raise(Errno::ECONNREFUSED)
273
+ allow(store).to receive(:redis).and_raise(Redis::CannotConnectError)
274
274
  allow(store).to receive(:generate_sid).and_return('foop')
275
275
  end
276
276
 
@@ -290,7 +290,7 @@ describe RedisSessionStore do
290
290
  it 'explodes' do
291
291
  expect do
292
292
  store.send(:get_session, double('env'), fake_key)
293
- end.to raise_error(Errno::ECONNREFUSED)
293
+ end.to raise_error(Redis::CannotConnectError)
294
294
  end
295
295
  end
296
296
  end
@@ -317,7 +317,7 @@ describe RedisSessionStore do
317
317
 
318
318
  context 'when redis is down' do
319
319
  before do
320
- allow(store).to receive(:redis).and_raise(Errno::ECONNREFUSED)
320
+ allow(store).to receive(:redis).and_raise(Redis::CannotConnectError)
321
321
  end
322
322
 
323
323
  it 'returns false' do
@@ -330,7 +330,7 @@ describe RedisSessionStore do
330
330
  it 'explodes' do
331
331
  expect do
332
332
  store.send(:destroy, env)
333
- end.to raise_error(Errno::ECONNREFUSED)
333
+ end.to raise_error(Redis::CannotConnectError)
334
334
  end
335
335
  end
336
336
  end
data/spec/support.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # vim:fileencoding=utf-8
2
2
 
3
3
  unless defined?(Rack::Session::Abstract::ENV_SESSION_OPTIONS_KEY)
4
- module Rack # rubocop:disable Documentation
4
+ module Rack
5
5
  module Session
6
- module Abstract # rubocop:disable Documentation
6
+ module Abstract
7
7
  ENV_SESSION_OPTIONS_KEY = 'rack.session.options'.freeze
8
8
  end
9
9
  end
@@ -11,9 +11,9 @@ unless defined?(Rack::Session::Abstract::ENV_SESSION_OPTIONS_KEY)
11
11
  end
12
12
 
13
13
  unless defined?(ActionDispatch::Session::AbstractStore)
14
- module ActionDispatch # rubocop:disable Documentation
14
+ module ActionDispatch
15
15
  module Session
16
- class AbstractStore # rubocop:disable Documentation
16
+ class AbstractStore
17
17
  ENV_SESSION_OPTIONS_KEY = 'rack.session.options'.freeze
18
18
  DEFAULT_OPTIONS = {
19
19
  key: '_session_id',
@@ -45,7 +45,7 @@ end
45
45
  unless defined?(Rails)
46
46
  require 'logger'
47
47
 
48
- module Rails # rubocop:disable Documentation
48
+ module Rails
49
49
  def self.logger
50
50
  @logger ||= Logger.new('/dev/null')
51
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-session-store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Meyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-28 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '3'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '5'
36
+ version: '5.1'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '3'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '5'
46
+ version: '5.1'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: fakeredis
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  requirements: []
165
165
  rubyforge_project:
166
- rubygems_version: 2.2.2
166
+ rubygems_version: 2.5.1
167
167
  signing_key:
168
168
  specification_version: 4
169
169
  summary: A drop-in replacement for e.g. MemCacheStore to store Rails sessions (and