sinatra-session_helpers 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1055db28b1aa44b5fa3791f60ba17fdb3f407db7
4
- data.tar.gz: 327271558c5b3496b2ee52de0c3fcd93d710d4b9
3
+ metadata.gz: 7838404449cb5ca64f475784682933a9908da031
4
+ data.tar.gz: 9fb0e9582dd20b644428ffa758c163db4e0da060
5
5
  SHA512:
6
- metadata.gz: 1f2aeec69bc7a26d48596b4f7c9abc05b66fc595d08019ef0d2ee7e5b817627cda9b93b18becdf1014087abecf9f6d37d6eedc9ead81f19b27fd3d10f0cc227d
7
- data.tar.gz: e8695777493c024fd6cb1f39df6785aeff3e0bdbb1781cf2ab932b32f6bcf010bdde6343577e4255f20e0a0aac3b87564013b00479451cc3be035f5825d6b365
6
+ metadata.gz: 382c9678756366ac115562877839f8fe98797c2750ae52cf762bed9ba48ef950a49497afd8408dc23849d43e9aafe87e890adec6114644a0741d9cd3cdd7ed78
7
+ data.tar.gz: f6f8f5ee6bcc5039e8d37ce54e7542b93031c33d84bd66419370357405890f4cf19a049f96a3ee440349b50859ca3c9e62a9532a160c76fe44d06671773bbbfb
data/README.md CHANGED
@@ -22,34 +22,44 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- ### Helper Methods
25
+ ### [Enable Sessions](http://www.sinatrarb.com/faq.html#sessions)
26
+
27
+ Since 0.2.0, this gem doesn't automatically enable sessions.
28
+ This means **you have to enable sessions in your app.**
29
+
30
+ This is so you can choose how to enable them, like using `Rack::Session::Cookie` if you need.
31
+
32
+ Enable Sinatra built-in sessions:
26
33
 
27
34
  ```ruby
28
- `session_start!` -> Starts the session
29
- `session_end!(destroy=true)` -> Ends the session. If `destroy` is false then
30
- session data will be preserved, even though future calls to `session?` will return false
31
- `session?` -> Returns true if the session is valid
32
- `session!` -> Redirects the client to the URL specified in
33
- the `session_fail` option unless the session is valid
35
+ enable :sessions
34
36
  ```
35
37
 
36
- ### Settings
38
+ Or, if you need to set additional parameters for sessions, like expiration date, use `Rack::Session::Cookie` directly instead of `enable :sessions` (example from Rack documentation):
37
39
 
40
+ ```ruby
41
+ use Rack::Session::Cookie, :key => 'rack.session',
42
+ :domain => 'foo.com',
43
+ :path => '/',
44
+ :expire_after => 2592000, # In seconds
45
+ :secret => 'change_me'
38
46
  ```
39
- `session_fail` -> A URL in your app that the client will be redirected to
40
- when `session!` is called and the session is not valid.
41
- Defaults to '/login'
42
- ```
47
+
48
+ #### Advanced Sinatra built-in sessions parameters
49
+
50
+ Here's how to do if you want to use Sinatra's built-in sessions, instead of `Rack::Session::Cookie`, and still specify additional parameters.
43
51
 
44
52
  You can force a specific secret key on the session:
45
53
 
46
54
  ```ruby
55
+ enable :sessions
47
56
  set :session_secret, '$ecR3t'
48
57
  ```
49
58
 
50
59
  Or other optional parameters like this:
51
60
 
52
61
  ```ruby
62
+ enable :sessions
53
63
  set :sessions, :key => 'sinatra.session',
54
64
  :path => '/',
55
65
  :domain => 'foo.com',
@@ -57,6 +67,25 @@ set :sessions, :key => 'sinatra.session',
57
67
  :secret => 'change_me'
58
68
  ```
59
69
 
70
+ ### Helper Methods
71
+
72
+ ```ruby
73
+ `session_start!` -> Starts the session
74
+ `session_end!(destroy=true)` -> Ends the session. If `destroy` is false then
75
+ session data will be preserved, even though future calls to `session?` will return false
76
+ `session?` -> Returns true if the session is valid
77
+ `session!` -> Redirects the client to the URL specified in
78
+ the `session_fail` option unless the session is valid
79
+ ```
80
+
81
+ ### Settings
82
+
83
+ ```
84
+ `session_fail` -> A URL in your app that the client will be redirected to
85
+ when `session!` is called and the session is not valid.
86
+ Defaults to '/login'
87
+ ```
88
+
60
89
  ## Examples
61
90
 
62
91
  As with all Sinatra extensions, Sinatra::SessionHelpers may be used in both classic and modular-style apps. First, classic.
@@ -65,6 +94,7 @@ As with all Sinatra extensions, Sinatra::SessionHelpers may be used in both clas
65
94
  require 'sinatra'
66
95
  require 'sinatra/session_helpers'
67
96
 
97
+ enable :sessions
68
98
  set :session_fail, '/login'
69
99
  set :session_secret, 'So0perSeKr3t!'
70
100
  set :sessions, :key => 'my_app'
@@ -35,9 +35,6 @@ module Sinatra
35
35
 
36
36
  # This should be set to the redirect URL the client will be sent to if the session is not valid.
37
37
  app.set :session_fail, '/login'
38
-
39
- # Enable Sinatra built-in sessions
40
- app.enable :sessions
41
38
  end
42
39
  end
43
40
 
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module SessionHelpers
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-session_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Ma
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-01 00:00:00.000000000 Z
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra