rack-redic 2.1.0 → 2.2.0

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
  SHA256:
3
- metadata.gz: 96dbd70a8cef729a5d9b4f0c399de55962ddc4d426f8ad4a73dcc0d69b992e9a
4
- data.tar.gz: 43bf423e5bfca24d8980feaacd542f8e472ff8169cd7dc1b17f264f68a9147cc
3
+ metadata.gz: a8f406be5199f71812675e4b268718cec8feb6e04b52920c581b695f5e54f148
4
+ data.tar.gz: 43cb8d93b4994fb82ee47e87b3ea7df9dd74694fbd15cea7218b75b20415a5a0
5
5
  SHA512:
6
- metadata.gz: a22a042aa9a771885bee5e37f24a8ad1d5f7e892a09d8b9d288d69d460a84c80ffbffffc8f58dd266c8b0789945cd6eb5e84e17b0668f2773c1973415bfffca0
7
- data.tar.gz: 26431e0ecc103217dd55b7ac3179956a4dcbf473a79f5fa5850dab9634ca8259c952a3df5d2562eb65eeb3ba9cb3f23a962fb35b0319fc9f7108692d314ca132
6
+ metadata.gz: 159b1b037606983df8ab16e75278ce470db0fc5092e9d430a5defd3ca4d937cabec4934e335091ad258b333af8faed2624b7cbef7281ecc7f22b2f9233150d40
7
+ data.tar.gz: 9613b147b2fad92ce618f920ca57f806e829178152e6302275f536c31ff26b64908deb8002f9c946b41b192bbf128d1ab9cf7e43b85d66cfaed3bdd2b7dab7d3
data/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # Rack::Session::Redic
2
+
3
+ `Rack::Session::Redic` provides simple cookie based session management. Session
4
+ data is stored in [Redis](redis) via the [Redic](redic) gem. The corresponding
5
+ session key is maintained in the cookie.
6
+
7
+ Options include:
8
+
9
+ - `:marshaller` - You may optionally supply the class/module you would like to
10
+ use when marshalling objects in and out of Redis. All that is required is that
11
+ this class respond to the `load` and `dump` methods, returning the session hash
12
+ and a string respectively.
13
+ - `:url` - Additionally, you may pass in the URL for your Redis server. The
14
+ default URL is fetched from the `ENV` as `REDIS_URL` in keeping with Heroku and
15
+ others' practices.
16
+ - `:expire_after` - Finally, expiration will be passed to the Redis server via
17
+ the 'EX' option on 'SET'. Expiration should be in seconds, just like Rack's
18
+ default handling of the `:expire_after` option. This option will refresh the
19
+ expiration set in Redis with each request.
20
+
21
+ Any other options will get passed to `Rack::Session::Abstract::Persisted`.
22
+
23
+ ## Installation
24
+
25
+ Add this line to your application's Gemfile or gems.rb file:
26
+
27
+ ```ruby
28
+ gem 'rack-redic', require: 'rack/session/redic'
29
+ ```
30
+
31
+ And then execute:
32
+
33
+ ```sh
34
+ bundle
35
+ ```
36
+
37
+ Or install it yourself as:
38
+
39
+ ```sh
40
+ gem install rack-redic
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ Anywhere in your Rack application just add:
46
+
47
+ ```ruby
48
+ # Most basic usage.
49
+ use Rack::Session::Redic
50
+
51
+ # Optionally pass in a marshaller.
52
+ use Rack::Session::Redic, marshaller: Oj
53
+
54
+ # And/or pass in the URL of your Redis server.
55
+ use Rack::Session::Redic, marshaller: Oj, url: 'redis://host:port'
56
+
57
+ # And/or pass in the expiration. (1_800 is 30 minutes in seconds)
58
+ use Rack::Session::Redic, marshaller: Oj, url: 'redis://host:port', expire_after: 1_800
59
+ ```
60
+
61
+ ## Custom Marshallers
62
+
63
+ Since the class/module passed as `:marshaller` only needs to respond to the
64
+ methods `load` and `dump`, you can create any kind of marshaller you would like.
65
+ I've included examples for MessagePack and Oj here as reference.
66
+
67
+ ### [MessagePack](msgpack)
68
+
69
+ ```ruby
70
+ require 'msgpack'
71
+
72
+ MessagePack::DefaultFactory.register_type(0x00, Symbol)
73
+
74
+ module MessagePackMarshaller
75
+ def self.dump(object)
76
+ MessagePack.pack(object)
77
+ end
78
+
79
+ def self.load(string)
80
+ MessagePack.unpack(string)
81
+ end
82
+ end
83
+ ```
84
+
85
+ Then, while adding it your Rack application.
86
+
87
+ ```ruby
88
+ use Rack::Session::Redic, marshaller: MessagePackMarshaller
89
+ ```
90
+
91
+ **NOTE:** MessagePack [serializes symbols as strings by default](symbols) so I
92
+ suggest customizing that behavior per their instructions. You can [read more
93
+ about MessagePack's extension formats here](extensions).
94
+
95
+ ### [Oj](oj)
96
+
97
+ Oj responds to `load` and `dump` by default so there's no adapter module needed.
98
+
99
+ ```ruby
100
+ use Rack::Session::Redic, marshaller: Oj
101
+ ```
102
+
103
+ ## License
104
+
105
+ The gem is available as open source under the terms of the [MIT
106
+ License](http://opensource.org/licenses/MIT).
107
+
108
+ [extensions]: https://github.com/msgpack/msgpack/blob/master/spec.md#types-extension-type
109
+ [msgpack]: https://github.com/msgpack/msgpack-ruby
110
+ [oj]: https://github.com/ohler55/oj
111
+ [redic]: https://github.com/amakawa/redic
112
+ [redis]: http://redis.io
113
+ [symbols]: https://github.com/msgpack/msgpack-ruby#serializing-and-deserializing-symbols
metadata CHANGED
@@ -1,29 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-redic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.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: 2022-09-22 00:00:00.000000000 Z
11
+ date: 2023-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '2'
22
+ version: '4'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rack-session
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
25
45
  - !ruby/object:Gem::Version
26
- version: '2'
46
+ version: '0'
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: redic
29
49
  requirement: !ruby/object:Gem::Requirement
@@ -46,15 +66,14 @@ extensions: []
46
66
  extra_rdoc_files: []
47
67
  files:
48
68
  - LICENSE.txt
49
- - README.org
69
+ - README.md
50
70
  - lib/rack/session/redic.rb
51
- - lib/rack/session/redic/version.rb
52
71
  homepage: https://github.com/evanleck/rack-redic
53
72
  licenses:
54
73
  - MIT
55
74
  metadata:
56
75
  bug_tracker_uri: https://github.com/evanleck/rack-redic/issues
57
- changelog_uri: https://github.com/evanleck/rack-redic/blob/main/CHANGELOG.org
76
+ changelog_uri: https://github.com/evanleck/rack-redic/blob/main/CHANGELOG.md
58
77
  homepage_uri: https://github.com/evanleck/rack-redic
59
78
  rubygems_mfa_required: 'true'
60
79
  source_code_uri: https://github.com/evanleck/rack-redic
@@ -73,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
92
  - !ruby/object:Gem::Version
74
93
  version: '0'
75
94
  requirements: []
76
- rubygems_version: 3.3.7
95
+ rubygems_version: 3.4.10
77
96
  signing_key:
78
97
  specification_version: 4
79
98
  summary: Rack::Session in Redis via Redic
data/README.org DELETED
@@ -1,105 +0,0 @@
1
- * Rack::Session::Redic
2
-
3
- =Rack::Session::Redic= provides simple cookie based session management. Session
4
- data is stored in [[http://redis.io][Redis]] via the [[https://github.com/amakawa/redic][Redic]] gem. The corresponding session key is
5
- maintained in the cookie.
6
-
7
- Options include:
8
-
9
- - =:marshaller= - You may optionally supply the class/module you would
10
- like to use when marshalling objects in and out of Redis. All that is
11
- required is that this class respond to the =load= and =dump= methods,
12
- returning the session hash and a string respectively.
13
- - =:url= - Additionally, you may pass in the URL for your Redis server.
14
- The default URL is fetched from the =ENV= as =REDIS_URL= in keeping
15
- with Heroku and others' practices.
16
- - =:expire_after= - Finally, expiration will be passed to the Redis
17
- server via the 'EX' option on 'SET'. Expiration should be in seconds,
18
- just like Rack's default handling of the =:expire_after= option. This
19
- option will refresh the expiration set in Redis with each request.
20
-
21
- Any other options will get passed to =Rack::Session::Abstract::Persisted=.
22
-
23
- ** Installation
24
-
25
- Add this line to your application's Gemfile or gems.rb file:
26
-
27
- #+begin_src ruby
28
- gem 'rack-redic', require: 'rack/session/redic'
29
- #+end_src
30
-
31
- And then execute:
32
-
33
- #+begin_src sh
34
- bundle
35
- #+end_src
36
-
37
- Or install it yourself as:
38
-
39
- #+begin_src sh
40
- gem install rack-redic
41
- #+end_src
42
-
43
- ** Usage
44
-
45
- Anywhere in your Rack application just add:
46
-
47
- #+begin_src ruby
48
- # Most basic usage.
49
- use Rack::Session::Redic
50
-
51
- # Optionally pass in a marshaller.
52
- use Rack::Session::Redic, marshaller: Oj
53
-
54
- # And/or pass in the URL of your Redis server.
55
- use Rack::Session::Redic, marshaller: Oj, url: 'redis://host:port'
56
-
57
- # And/or pass in the expiration. (1_800 is 30 minutes in seconds)
58
- use Rack::Session::Redic, marshaller: Oj, url: 'redis://host:port', expire_after: 1_800
59
- #+end_src
60
-
61
- ** Custom Marshallers
62
-
63
- Since the class/module passed as =:marshaller= only needs to respond to the
64
- methods =load= and =dump=, you can create any kind of marshaller you would like.
65
- I've included examples for MessagePack and Oj here as reference.
66
-
67
- *** [[https://github.com/msgpack/msgpack-ruby][MessagePack]]
68
-
69
- #+begin_src ruby
70
- require 'msgpack'
71
-
72
- MessagePack::DefaultFactory.register_type(0x00, Symbol)
73
-
74
- module MessagePackMarshaller
75
- def self.dump(object)
76
- MessagePack.pack(object)
77
- end
78
-
79
- def self.load(string)
80
- MessagePack.unpack(string)
81
- end
82
- end
83
- #+end_src
84
-
85
- Then, while adding it your Rack application.
86
-
87
- #+BEGIN_SRC ruby
88
- use Rack::Session::Redic, marshaller: MessagePackMarshaller
89
- #+END_SRC
90
-
91
- *NOTE:* MessagePack [[https://github.com/msgpack/msgpack-ruby#serializing-and-deserializing-symbols][serializes symbols as strings by default]] so I suggest
92
- customizing that behavior per their instructions. You can [[https://github.com/msgpack/msgpack/blob/master/spec.md#types-extension-type][read more about
93
- MessagePack's extension formats here]].
94
-
95
- *** [[https://github.com/ohler55/oj][Oj]]
96
-
97
- Oj responds to =load= and =dump= by default so there's no adapter module needed.
98
-
99
- #+begin_src ruby
100
- use Rack::Session::Redic, marshaller: Oj
101
- #+end_src
102
-
103
- ** License
104
-
105
- The gem is available as open source under the terms of the [[http://opensource.org/licenses/MIT][MIT License]].
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
- require_relative '../redic'
3
-
4
- module Rack
5
- module Session
6
- class Redic
7
- VERSION = '3.0.0'
8
- end
9
- end
10
- end