rack-redic 1.2.0 → 1.3.0
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 +4 -4
- data/.editorconfig +24 -0
- data/Makefile +18 -0
- data/Rakefile +2 -2
- data/lib/rack/session/redic.rb +43 -3
- data/rack-redic.gemspec +3 -3
- data/test/all.rb +5 -0
- data/{spec/spec_helper.rb → test/helper.rb} +6 -0
- data/{spec/session_redic_spec.rb → test/session_redic_test.rb} +39 -39
- data/{spec/storage_msgpack_spec.rb → test/storage_msgpack_test.rb} +5 -5
- data/test/storage_oj_test.rb +14 -0
- data/test/storage_test.rb +13 -0
- data/test/support/storage_marshaller_interface.rb +30 -0
- metadata +22 -19
- data/.rspec +0 -2
- data/spec/storage_oj_spec.rb +0 -14
- data/spec/storage_spec.rb +0 -13
- data/spec/support/shared_examples/storage_marshaller.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf92c89449d8d8709de10c6764860f6bf170e5d0
|
4
|
+
data.tar.gz: bf999b9c9675ad376c52ae1eb6df3042f6c4d7a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 245c12a951c0c0c395064a64ab594f2d5e8774979bdcb3feb23fc855666612e50db63eead26aa5df911287a7c1f184918ea1a2cc69ae01f07f52e8fa17c0807b
|
7
|
+
data.tar.gz: 5a0d6bff6ad7faae40884f75174d43728e87ea4526f73eb0b826ac414a2f05851b4c10f643ee0c53fb1bae5faa6ae6fe58f52f6222c1df731ff33d331b9f8e3a
|
data/.editorconfig
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# http://EditorConfig.org
|
2
|
+
# This is the top most config file.
|
3
|
+
root = true
|
4
|
+
|
5
|
+
# All files
|
6
|
+
[*]
|
7
|
+
|
8
|
+
# Unix-style newlines with a newline ending every file
|
9
|
+
end_of_line = lf
|
10
|
+
insert_final_newline = true
|
11
|
+
|
12
|
+
# Character set
|
13
|
+
charset = utf-8
|
14
|
+
|
15
|
+
# Trim extra whitespace.
|
16
|
+
trim_trailing_whitespace = true
|
17
|
+
|
18
|
+
# Soft tabs and 2 spaces.
|
19
|
+
indent_style = space
|
20
|
+
indent_size = 2
|
21
|
+
|
22
|
+
# Makefiles use tabs
|
23
|
+
[Makefile]
|
24
|
+
indent_style = tab
|
data/Makefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
.DEFAULT_GOAL := test
|
2
|
+
.PHONY: test
|
3
|
+
.SILENT: test
|
4
|
+
|
5
|
+
BE := bundle exec
|
6
|
+
|
7
|
+
# Run our test suite.
|
8
|
+
#
|
9
|
+
# To test an individual file, pass the "file" argument like so:
|
10
|
+
#
|
11
|
+
# make test file=test/storage_test.rb
|
12
|
+
#
|
13
|
+
test:
|
14
|
+
ifeq ($(origin file), undefined)
|
15
|
+
$(BE) ruby -r ./test/helper.rb test/all.rb
|
16
|
+
else
|
17
|
+
$(BE) ruby -r ./test/helper.rb $(file)
|
18
|
+
endif
|
data/Rakefile
CHANGED
data/lib/rack/session/redic.rb
CHANGED
@@ -78,7 +78,6 @@ module Rack
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
##
|
82
81
|
# A wrapper around Redic to simplify calls.
|
83
82
|
class Storage
|
84
83
|
# Redis commands.
|
@@ -91,20 +90,46 @@ module Rack
|
|
91
90
|
# Assorted.
|
92
91
|
ZERO = 0
|
93
92
|
|
93
|
+
# @param expires [Integer]
|
94
|
+
# The number of seconds for Redis to retain keys.
|
95
|
+
# @param marshaller [#dump, #load]
|
96
|
+
# The module or class used to marshal objects. It must respond to
|
97
|
+
# #dump and #load.
|
98
|
+
# @param url [String]
|
99
|
+
# The URL to access Redis at.
|
94
100
|
def initialize(expires, marshaller, url)
|
95
101
|
@expires = expires
|
96
102
|
@marshaller = marshaller
|
97
103
|
@storage = ::Redic.new(url)
|
98
104
|
end
|
99
105
|
|
106
|
+
# Check for an identifier's existence.
|
107
|
+
#
|
108
|
+
# @param id [String]
|
109
|
+
# The key to check for.
|
110
|
+
# @return [Boolean]
|
100
111
|
def exists?(id)
|
101
112
|
@storage.call(EXISTS, id) != ZERO
|
102
113
|
end
|
103
114
|
|
115
|
+
# Retrieve an object.
|
116
|
+
#
|
117
|
+
# @param id [String]
|
118
|
+
# The key in Redis to retrieve from.
|
119
|
+
# @return [Object, nil]
|
120
|
+
# The object stored at the identifier provided, or nil.
|
104
121
|
def get(id)
|
105
122
|
deserialize(@storage.call(GET, id))
|
106
123
|
end
|
107
124
|
|
125
|
+
# Store an object.
|
126
|
+
#
|
127
|
+
# @param id [String]
|
128
|
+
# The key to use to store the object.
|
129
|
+
# @param object [Object]
|
130
|
+
# Any object that can be serialized.
|
131
|
+
# @return [String]
|
132
|
+
# See {https://redis.io/commands/set#return-value Redis' docs for more}.
|
108
133
|
def set(id, object)
|
109
134
|
arguments = [SET, id, serialize(object)]
|
110
135
|
arguments += [EX, @expires] if @expires
|
@@ -112,18 +137,33 @@ module Rack
|
|
112
137
|
@storage.call(*arguments)
|
113
138
|
end
|
114
139
|
|
140
|
+
# Remove an object.
|
141
|
+
#
|
142
|
+
# @param id [String]
|
143
|
+
# The key to delete.
|
144
|
+
# @return [Integer]
|
145
|
+
# The number of keys that were deleted. See
|
146
|
+
# {https://redis.io/commands/del#return-value Redis' docs for more}.
|
115
147
|
def delete(id)
|
116
148
|
@storage.call(DELETE, id)
|
117
149
|
end
|
118
150
|
|
119
151
|
private
|
120
152
|
|
121
|
-
#
|
153
|
+
# Serialize an object using our marshaller.
|
154
|
+
#
|
155
|
+
# @param object [Object]
|
156
|
+
# @return [String]
|
157
|
+
# The object serialized by the marshaller.
|
122
158
|
def serialize(object)
|
123
159
|
@marshaller.dump(object)
|
124
160
|
end
|
125
161
|
|
126
|
-
#
|
162
|
+
# Deserialize a string back into an object.
|
163
|
+
#
|
164
|
+
# @param string [String]
|
165
|
+
# @return [Object, nil]
|
166
|
+
# Returns the object as loaded by the marshaller, or nil.
|
127
167
|
def deserialize(string)
|
128
168
|
@marshaller.load(string) if string
|
129
169
|
|
data/rack-redic.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'rack-redic'
|
5
|
-
spec.version = '1.
|
5
|
+
spec.version = '1.3.0'
|
6
6
|
spec.authors = ['Evan Lecklider']
|
7
7
|
spec.email = ['evan@lecklider.com']
|
8
8
|
|
@@ -11,12 +11,12 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.homepage = 'https://github.com/evanleck/rack-redic'
|
12
12
|
spec.license = 'MIT'
|
13
13
|
spec.files = `git ls-files`.split("\n")
|
14
|
-
spec.test_files = spec.files.grep(/^
|
14
|
+
spec.test_files = spec.files.grep(/^test/)
|
15
15
|
|
16
16
|
spec.add_dependency 'rack'
|
17
17
|
spec.add_dependency 'redic'
|
18
18
|
|
19
|
+
spec.add_development_dependency 'minitest'
|
19
20
|
spec.add_development_dependency 'msgpack'
|
20
21
|
spec.add_development_dependency 'oj'
|
21
|
-
spec.add_development_dependency 'rspec'
|
22
22
|
end
|
data/test/all.rb
ADDED
@@ -1,8 +1,14 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
# Add our project folder to the root of our load path.
|
5
|
+
$LOAD_PATH.unshift File.expand_path('../..', __FILE__)
|
6
|
+
|
4
7
|
# Ensure we have this set before trying to initialize anything.
|
5
8
|
ENV['REDIS_URL'] ||= 'redis://localhost:6379'
|
6
9
|
|
7
10
|
# Require our core library.
|
8
11
|
require 'rack/session/redic'
|
12
|
+
|
13
|
+
# Kick off the tests.
|
14
|
+
require 'minitest/autorun'
|
@@ -44,8 +44,8 @@ describe Rack::Session::Redic do
|
|
44
44
|
redic = Rack::Session::Redic.new(incrementor)
|
45
45
|
response = Rack::MockRequest.new(redic).get(ROOT)
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
assert_includes response[Rack::SET_COOKIE], "#{ session_key }="
|
48
|
+
assert_equal response.body, '{"counter"=>1}'
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'determines session from a cookie' do
|
@@ -55,8 +55,8 @@ describe Rack::Session::Redic do
|
|
55
55
|
|
56
56
|
cookie = response[Rack::SET_COOKIE]
|
57
57
|
|
58
|
-
|
59
|
-
|
58
|
+
assert_equal request.get(ROOT, Rack::HTTP_COOKIE => cookie).body, '{"counter"=>2}'
|
59
|
+
assert_equal request.get(ROOT, Rack::HTTP_COOKIE => cookie).body, '{"counter"=>3}'
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'determines session only from a cookie by default' do
|
@@ -65,8 +65,8 @@ describe Rack::Session::Redic do
|
|
65
65
|
response = request.get(ROOT)
|
66
66
|
sid = response[Rack::SET_COOKIE][session_match, 1]
|
67
67
|
|
68
|
-
|
69
|
-
|
68
|
+
assert_equal request.get("/?rack.session=#{sid}").body, '{"counter"=>1}'
|
69
|
+
assert_equal request.get("/?rack.session=#{sid}").body, '{"counter"=>1}'
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'determines session from params' do
|
@@ -75,8 +75,8 @@ describe Rack::Session::Redic do
|
|
75
75
|
response = request.get(ROOT)
|
76
76
|
sid = response[Rack::SET_COOKIE][session_match, 1]
|
77
77
|
|
78
|
-
|
79
|
-
|
78
|
+
assert_equal request.get("/?rack.session=#{sid}").body, '{"counter"=>2}'
|
79
|
+
assert_equal request.get("/?rack.session=#{sid}").body, '{"counter"=>3}'
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'survives nonexistant cookies' do
|
@@ -85,29 +85,29 @@ describe Rack::Session::Redic do
|
|
85
85
|
redic = Rack::Session::Redic.new(incrementor)
|
86
86
|
response = Rack::MockRequest.new(redic).get(ROOT, Rack::HTTP_COOKIE => bad_cookie)
|
87
87
|
|
88
|
-
|
88
|
+
assert_equal response.body, '{"counter"=>1}'
|
89
89
|
|
90
90
|
cookie = response[Rack::SET_COOKIE][session_match]
|
91
|
-
|
91
|
+
refute_match /#{ bad_cookie }/, cookie
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'maintains freshness' do
|
95
95
|
redic = Rack::Session::Redic.new(incrementor, expire_after: 3)
|
96
96
|
response = Rack::MockRequest.new(redic).get(ROOT)
|
97
|
-
|
97
|
+
assert_includes response.body, '"counter"=>1'
|
98
98
|
|
99
99
|
cookie = response[Rack::SET_COOKIE]
|
100
100
|
response = Rack::MockRequest.new(redic).get(ROOT, Rack::HTTP_COOKIE => cookie)
|
101
101
|
|
102
|
-
|
103
|
-
|
102
|
+
assert_equal response[Rack::SET_COOKIE], cookie
|
103
|
+
assert_includes response.body, '"counter"=>2'
|
104
104
|
|
105
105
|
puts 'Sleeping to expire session' if $DEBUG
|
106
106
|
sleep 4
|
107
107
|
|
108
108
|
response = Rack::MockRequest.new(redic).get(ROOT, Rack::HTTP_COOKIE => cookie)
|
109
|
-
|
110
|
-
|
109
|
+
refute_equal response[Rack::SET_COOKIE], cookie
|
110
|
+
assert_includes response.body, '"counter"=>1'
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'does not send the same session id if it did not change' do
|
@@ -116,15 +116,15 @@ describe Rack::Session::Redic do
|
|
116
116
|
|
117
117
|
res0 = request.get(ROOT)
|
118
118
|
cookie = res0[Rack::SET_COOKIE][session_match]
|
119
|
-
|
119
|
+
assert_equal res0.body, '{"counter"=>1}'
|
120
120
|
|
121
121
|
res1 = request.get(ROOT, Rack::HTTP_COOKIE => cookie)
|
122
|
-
|
123
|
-
|
122
|
+
assert_nil res1[Rack::SET_COOKIE]
|
123
|
+
assert_equal res1.body, '{"counter"=>2}'
|
124
124
|
|
125
125
|
res2 = request.get(ROOT, Rack::HTTP_COOKIE => cookie)
|
126
|
-
|
127
|
-
|
126
|
+
assert_nil res2[Rack::SET_COOKIE]
|
127
|
+
assert_equal res2.body, '{"counter"=>3}'
|
128
128
|
end
|
129
129
|
|
130
130
|
it 'deletes cookies with :drop option' do
|
@@ -135,15 +135,15 @@ describe Rack::Session::Redic do
|
|
135
135
|
|
136
136
|
res1 = request.get(ROOT)
|
137
137
|
session = (cookie = res1[Rack::SET_COOKIE])[session_match]
|
138
|
-
|
138
|
+
assert_equal res1.body, '{"counter"=>1}'
|
139
139
|
|
140
140
|
res2 = dreq.get(ROOT, Rack::HTTP_COOKIE => cookie)
|
141
|
-
|
142
|
-
|
141
|
+
assert_nil res2[Rack::SET_COOKIE]
|
142
|
+
assert_equal res2.body, '{"counter"=>2}'
|
143
143
|
|
144
144
|
res3 = request.get(ROOT, Rack::HTTP_COOKIE => cookie)
|
145
|
-
|
146
|
-
|
145
|
+
refute_equal res3[Rack::SET_COOKIE][session_match], session
|
146
|
+
assert_equal res3.body, '{"counter"=>1}'
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'provides new session id with :renew option' do
|
@@ -154,20 +154,20 @@ describe Rack::Session::Redic do
|
|
154
154
|
|
155
155
|
res1 = request.get(ROOT)
|
156
156
|
session = (cookie = res1[Rack::SET_COOKIE])[session_match]
|
157
|
-
|
157
|
+
assert_equal res1.body, '{"counter"=>1}'
|
158
158
|
|
159
159
|
res2 = renew_request.get(ROOT, Rack::HTTP_COOKIE => cookie)
|
160
160
|
new_cookie = res2[Rack::SET_COOKIE]
|
161
161
|
new_session = new_cookie[session_match]
|
162
|
-
|
163
|
-
|
162
|
+
refute_equal new_session, session
|
163
|
+
assert_equal res2.body, '{"counter"=>2}'
|
164
164
|
|
165
165
|
res3 = request.get(ROOT, Rack::HTTP_COOKIE => new_cookie)
|
166
|
-
|
166
|
+
assert_equal res3.body, '{"counter"=>3}'
|
167
167
|
|
168
168
|
# Old cookie was deleted
|
169
169
|
res4 = request.get(ROOT, Rack::HTTP_COOKIE => cookie)
|
170
|
-
|
170
|
+
assert_equal res4.body, '{"counter"=>1}'
|
171
171
|
end
|
172
172
|
|
173
173
|
it 'omits cookie with :defer option but still updates the state' do
|
@@ -178,14 +178,14 @@ describe Rack::Session::Redic do
|
|
178
178
|
count_request = Rack::MockRequest.new(count)
|
179
179
|
|
180
180
|
res0 = defer_request.get(ROOT)
|
181
|
-
|
182
|
-
|
181
|
+
assert_nil res0[Rack::SET_COOKIE]
|
182
|
+
assert_equal res0.body, '{"counter"=>1}'
|
183
183
|
|
184
184
|
res0 = count_request.get(ROOT)
|
185
185
|
res1 = defer_request.get(ROOT, Rack::HTTP_COOKIE => res0[Rack::SET_COOKIE])
|
186
|
-
|
186
|
+
assert_equal res1.body, '{"counter"=>2}'
|
187
187
|
res2 = defer_request.get(ROOT, Rack::HTTP_COOKIE => res0[Rack::SET_COOKIE])
|
188
|
-
|
188
|
+
assert_equal res2.body, '{"counter"=>3}'
|
189
189
|
end
|
190
190
|
|
191
191
|
it 'omits cookie and state update with :skip option' do
|
@@ -196,14 +196,14 @@ describe Rack::Session::Redic do
|
|
196
196
|
count_request = Rack::MockRequest.new(count)
|
197
197
|
|
198
198
|
res0 = skip_request.get(ROOT)
|
199
|
-
|
200
|
-
|
199
|
+
assert_nil res0[Rack::SET_COOKIE]
|
200
|
+
assert_equal res0.body, '{"counter"=>1}'
|
201
201
|
|
202
202
|
res0 = count_request.get(ROOT)
|
203
203
|
res1 = skip_request.get(ROOT, Rack::HTTP_COOKIE => res0[Rack::SET_COOKIE])
|
204
|
-
|
204
|
+
assert_equal res1.body, '{"counter"=>2}'
|
205
205
|
res2 = skip_request.get(ROOT, Rack::HTTP_COOKIE => res0[Rack::SET_COOKIE])
|
206
|
-
|
206
|
+
assert_equal res2.body, '{"counter"=>2}'
|
207
207
|
end
|
208
208
|
|
209
209
|
it 'updates deep hashes correctly' do
|
@@ -229,6 +229,6 @@ describe Rack::Session::Redic do
|
|
229
229
|
request.get(ROOT, Rack::HTTP_COOKIE => cookie)
|
230
230
|
ses1 = redic.storage.get(session_id)
|
231
231
|
|
232
|
-
|
232
|
+
refute_equal ses1, ses0
|
233
233
|
end
|
234
234
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
require 'support/shared_examples/storage_marshaller'
|
4
3
|
require 'msgpack'
|
4
|
+
require_relative 'support/storage_marshaller_interface'
|
5
5
|
|
6
6
|
MessagePack::DefaultFactory.register_type(0x00, Symbol)
|
7
7
|
|
@@ -18,11 +18,11 @@ module MessagePackMarshaller
|
|
18
18
|
end
|
19
19
|
|
20
20
|
describe Rack::Session::Redic::Storage do
|
21
|
-
|
22
|
-
|
21
|
+
describe 'using the MessagePack as the marshaller' do
|
22
|
+
include StorageMarshallerInterface
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
before do
|
25
|
+
@store = Rack::Session::Redic::Storage.new(nil, MessagePackMarshaller, ENV['REDIS_URL'])
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
require 'oj'
|
4
|
+
require_relative 'support/storage_marshaller_interface'
|
5
|
+
|
6
|
+
describe Rack::Session::Redic::Storage do
|
7
|
+
describe 'using the Oj as the marshaller' do
|
8
|
+
include StorageMarshallerInterface
|
9
|
+
|
10
|
+
before do
|
11
|
+
@store = Rack::Session::Redic::Storage.new(nil, Oj, ENV['REDIS_URL'])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
require_relative 'support/storage_marshaller_interface'
|
4
|
+
|
5
|
+
describe Rack::Session::Redic::Storage do
|
6
|
+
describe 'using the default marshaller' do
|
7
|
+
include StorageMarshallerInterface
|
8
|
+
|
9
|
+
before do
|
10
|
+
@store = Rack::Session::Redic::Storage.new(nil, Marshal, ENV['REDIS_URL'])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
module StorageMarshallerInterface
|
4
|
+
def test_returns_nil_for_empty_keys
|
5
|
+
assert_nil @store.get('not-here')
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_saves_objects
|
9
|
+
object = { saved: true }
|
10
|
+
@store.set('saving', object)
|
11
|
+
|
12
|
+
assert_equal @store.get('saving'), object
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_existence_of_keys
|
16
|
+
@store.set('exists', false)
|
17
|
+
|
18
|
+
assert_equal @store.exists?('exists'), true
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_deletes_objects
|
22
|
+
object = { deleted: true }
|
23
|
+
@store.set('deleted', object)
|
24
|
+
|
25
|
+
assert_equal @store.get('deleted'), object
|
26
|
+
@store.delete('deleted')
|
27
|
+
|
28
|
+
assert_nil @store.get('deleted')
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-redic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Lecklider
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: msgpack
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: oj
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -87,21 +87,23 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
+
- ".editorconfig"
|
90
91
|
- ".gitignore"
|
91
|
-
- ".rspec"
|
92
92
|
- CODE_OF_CONDUCT.md
|
93
93
|
- Gemfile
|
94
94
|
- LICENSE.txt
|
95
|
+
- Makefile
|
95
96
|
- README.md
|
96
97
|
- Rakefile
|
97
98
|
- lib/rack/session/redic.rb
|
98
99
|
- rack-redic.gemspec
|
99
|
-
-
|
100
|
-
-
|
101
|
-
-
|
102
|
-
-
|
103
|
-
-
|
104
|
-
-
|
100
|
+
- test/all.rb
|
101
|
+
- test/helper.rb
|
102
|
+
- test/session_redic_test.rb
|
103
|
+
- test/storage_msgpack_test.rb
|
104
|
+
- test/storage_oj_test.rb
|
105
|
+
- test/storage_test.rb
|
106
|
+
- test/support/storage_marshaller_interface.rb
|
105
107
|
homepage: https://github.com/evanleck/rack-redic
|
106
108
|
licenses:
|
107
109
|
- MIT
|
@@ -122,14 +124,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
124
|
version: '0'
|
123
125
|
requirements: []
|
124
126
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.6.
|
127
|
+
rubygems_version: 2.6.13
|
126
128
|
signing_key:
|
127
129
|
specification_version: 4
|
128
130
|
summary: Rack::Session in Redis via Redic
|
129
131
|
test_files:
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
135
|
-
-
|
132
|
+
- test/all.rb
|
133
|
+
- test/helper.rb
|
134
|
+
- test/session_redic_test.rb
|
135
|
+
- test/storage_msgpack_test.rb
|
136
|
+
- test/storage_oj_test.rb
|
137
|
+
- test/storage_test.rb
|
138
|
+
- test/support/storage_marshaller_interface.rb
|
data/.rspec
DELETED
data/spec/storage_oj_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
require 'support/shared_examples/storage_marshaller'
|
4
|
-
require 'oj'
|
5
|
-
|
6
|
-
describe Rack::Session::Redic::Storage do
|
7
|
-
context 'using the Oj as the marshaller' do
|
8
|
-
it_behaves_like 'a storage marshaller'
|
9
|
-
|
10
|
-
subject do
|
11
|
-
described_class.new(nil, Oj, ENV['REDIS_URL'])
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/spec/storage_spec.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
require 'support/shared_examples/storage_marshaller'
|
4
|
-
|
5
|
-
describe Rack::Session::Redic::Storage do
|
6
|
-
context 'using the default marshaller' do
|
7
|
-
it_behaves_like 'a storage marshaller'
|
8
|
-
|
9
|
-
subject do
|
10
|
-
described_class.new(nil, Marshal, ENV['REDIS_URL'])
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
RSpec.shared_examples 'a storage marshaller' do
|
4
|
-
it 'returns nil for empty keys' do
|
5
|
-
expect(subject.get('not-here')).to eq(nil)
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'saves objects' do
|
9
|
-
object = { saved: true }
|
10
|
-
subject.set('saving', object)
|
11
|
-
|
12
|
-
expect(subject.get('saving')).to eq(object)
|
13
|
-
subject.delete('saving') # Cleanup.
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'checks the existence of keys' do
|
17
|
-
subject.set('exists', false)
|
18
|
-
|
19
|
-
expect(subject.exists?('exists')).to eq(true)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'deletes objects' do
|
23
|
-
object = { deleted: true }
|
24
|
-
subject.set('deleted', object)
|
25
|
-
|
26
|
-
expect(subject.get('deleted')).to eq(object)
|
27
|
-
subject.delete('deleted')
|
28
|
-
|
29
|
-
expect(subject.get('deleted')).to eq(nil)
|
30
|
-
end
|
31
|
-
end
|