rubysl-cgi-session 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +5 -6
- data/README.md +2 -2
- data/Rakefile +0 -1
- data/lib/cgi/session/pstore.rb +29 -29
- data/lib/rubysl/cgi/session/session.rb +140 -109
- data/lib/rubysl/cgi/session/version.rb +1 -1
- data/rubysl-cgi-session.gemspec +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4789df406231c3e8a7bfa32f2f03bbcd88016c0b
|
4
|
+
data.tar.gz: 93dcf411efbe9cb4ed3177fb1a6265ee5a643b09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2cc342d9538cd0d82d5441082d8d4d19f307bb269728ffa068fd192dd0622750f06c50893a8b47b5a262a742248bc3cb98e9c98a388efe1b6374ed354074b7e
|
7
|
+
data.tar.gz: 4114b261866635d2c6d540d18da5c7f6f04db324028aea4338869b4eb742374b8d7d3c1b33b28f67c18cc5b5e11880f7e9924e1b5df786d089d4ea53963699cd
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Rubysl::Cgi::Session
|
2
2
|
|
3
3
|
TODO: Write a gem description
|
4
4
|
|
@@ -24,6 +24,6 @@ TODO: Write usage instructions here
|
|
24
24
|
|
25
25
|
1. Fork it
|
26
26
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am '
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
28
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
29
|
5. Create new Pull Request
|
data/Rakefile
CHANGED
data/lib/cgi/session/pstore.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# cgi/session/pstore.rb - persistent storage of marshalled session data
|
3
3
|
#
|
4
4
|
# Documentation: William Webber (william@williamwebber.com)
|
5
|
-
#
|
5
|
+
#
|
6
6
|
# == Overview
|
7
7
|
#
|
8
8
|
# This file provides the CGI::Session::PStore class, which builds
|
@@ -29,7 +29,7 @@ class CGI
|
|
29
29
|
# created. The session id must only contain alphanumeric
|
30
30
|
# characters; automatically generated session ids observe
|
31
31
|
# this requirement.
|
32
|
-
#
|
32
|
+
#
|
33
33
|
# +option+ is a hash of options for the initializer. The
|
34
34
|
# following options are recognised:
|
35
35
|
#
|
@@ -43,55 +43,55 @@ class CGI
|
|
43
43
|
# This session's PStore file will be created if it does
|
44
44
|
# not exist, or opened if it does.
|
45
45
|
def initialize(session, option={})
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
dir = option['tmpdir'] || Dir::tmpdir
|
47
|
+
prefix = option['prefix'] || ''
|
48
|
+
id = session.session_id
|
49
49
|
require 'digest/md5'
|
50
50
|
md5 = Digest::MD5.hexdigest(id)[0,16]
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
path = dir+"/"+prefix+md5
|
52
|
+
path.untaint
|
53
|
+
if File::exist?(path)
|
54
|
+
@hash = nil
|
55
|
+
else
|
56
56
|
unless session.new_session
|
57
57
|
raise CGI::Session::NoSession, "uninitialized session"
|
58
58
|
end
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
@hash = {}
|
60
|
+
end
|
61
|
+
@p = ::PStore.new(path)
|
62
|
+
@p.transaction do |p|
|
63
|
+
File.chmod(0600, p.path)
|
64
|
+
end
|
65
65
|
end
|
66
66
|
|
67
67
|
# Restore session state from the session's PStore file.
|
68
68
|
#
|
69
69
|
# Returns the session state as a hash.
|
70
70
|
def restore
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
unless @hash
|
72
|
+
@p.transaction do
|
73
|
+
@hash = @p['hash'] || {}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
@hash
|
77
77
|
end
|
78
78
|
|
79
79
|
# Save session state to the session's PStore file.
|
80
|
-
def update
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
def update
|
81
|
+
@p.transaction do
|
82
|
+
@p['hash'] = @hash
|
83
|
+
end
|
84
84
|
end
|
85
85
|
|
86
86
|
# Update and close the session's PStore file.
|
87
87
|
def close
|
88
|
-
|
88
|
+
update
|
89
89
|
end
|
90
90
|
|
91
91
|
# Close and delete the session's PStore file.
|
92
92
|
def delete
|
93
|
-
|
94
|
-
|
93
|
+
path = @p.path
|
94
|
+
File::unlink path
|
95
95
|
end
|
96
96
|
|
97
97
|
end
|
@@ -8,28 +8,22 @@
|
|
8
8
|
# Author: Yukihiro "Matz" Matsumoto
|
9
9
|
#
|
10
10
|
# Documentation: William Webber (william@williamwebber.com)
|
11
|
-
#
|
12
|
-
# == Overview
|
13
|
-
#
|
14
|
-
# This file provides the +CGI::Session+ class, which provides session
|
15
|
-
# support for CGI scripts. A session is a sequence of HTTP requests
|
16
|
-
# and responses linked together and associated with a single client.
|
17
|
-
# Information associated with the session is stored
|
18
|
-
# on the server between requests. A session id is passed between client
|
19
|
-
# and server with every request and response, transparently
|
20
|
-
# to the user. This adds state information to the otherwise stateless
|
21
|
-
# HTTP request/response protocol.
|
22
|
-
#
|
23
|
-
# See the documentation to the +CGI::Session+ class for more details
|
24
|
-
# and examples of usage. See cgi.rb for the +CGI+ class itself.
|
25
11
|
|
26
12
|
require 'cgi'
|
27
13
|
require 'tmpdir'
|
28
14
|
|
29
15
|
class CGI
|
30
16
|
|
31
|
-
#
|
32
|
-
#
|
17
|
+
# == Overview
|
18
|
+
#
|
19
|
+
# This file provides the CGI::Session class, which provides session
|
20
|
+
# support for CGI scripts. A session is a sequence of HTTP requests
|
21
|
+
# and responses linked together and associated with a single client.
|
22
|
+
# Information associated with the session is stored
|
23
|
+
# on the server between requests. A session id is passed between client
|
24
|
+
# and server with every request and response, transparently
|
25
|
+
# to the user. This adds state information to the otherwise stateless
|
26
|
+
# HTTP request/response protocol.
|
33
27
|
#
|
34
28
|
# == Lifecycle
|
35
29
|
#
|
@@ -47,7 +41,7 @@ class CGI
|
|
47
41
|
# == Setting and retrieving session data.
|
48
42
|
#
|
49
43
|
# The Session class associates data with a session as key-value pairs.
|
50
|
-
# This data can be set and retrieved by indexing the Session instance
|
44
|
+
# This data can be set and retrieved by indexing the Session instance
|
51
45
|
# using '[]', much the same as hashes (although other hash methods
|
52
46
|
# are not supported).
|
53
47
|
#
|
@@ -60,21 +54,21 @@ class CGI
|
|
60
54
|
#
|
61
55
|
# == Storing session state
|
62
56
|
#
|
63
|
-
# The caller can specify what form of storage to use for the session's
|
57
|
+
# The caller can specify what form of storage to use for the session's
|
64
58
|
# data with the +database_manager+ option to CGI::Session::new. The
|
65
59
|
# following storage classes are provided as part of the standard library:
|
66
60
|
#
|
67
|
-
# CGI::Session::FileStore:: stores data as plain text in a flat file. Only
|
68
|
-
# works with String data. This is the default
|
61
|
+
# CGI::Session::FileStore:: stores data as plain text in a flat file. Only
|
62
|
+
# works with String data. This is the default
|
69
63
|
# storage type.
|
70
|
-
# CGI::Session::MemoryStore:: stores data in an in-memory hash. The data
|
71
|
-
# only persists for as long as the current ruby
|
64
|
+
# CGI::Session::MemoryStore:: stores data in an in-memory hash. The data
|
65
|
+
# only persists for as long as the current ruby
|
72
66
|
# interpreter instance does.
|
73
67
|
# CGI::Session::PStore:: stores data in Marshalled format. Provided by
|
74
|
-
# cgi/session/pstore.rb. Supports data of any type,
|
68
|
+
# cgi/session/pstore.rb. Supports data of any type,
|
75
69
|
# and provides file-locking and transaction support.
|
76
70
|
#
|
77
|
-
# Custom storage types can also be created by defining a class with
|
71
|
+
# Custom storage types can also be created by defining a class with
|
78
72
|
# the following methods:
|
79
73
|
#
|
80
74
|
# new(session, options)
|
@@ -99,14 +93,14 @@ class CGI
|
|
99
93
|
# The simplest way to do this is via cookies. The CGI::Session class
|
100
94
|
# provides transparent support for session id communication via cookies
|
101
95
|
# if the client has cookies enabled.
|
102
|
-
#
|
96
|
+
#
|
103
97
|
# If the client has cookies disabled, the session id must be included
|
104
98
|
# as a parameter of all requests sent by the client to the server. The
|
105
99
|
# CGI::Session class in conjunction with the CGI class will transparently
|
106
100
|
# add the session id as a hidden input field to all forms generated
|
107
101
|
# using the CGI#form() HTML generation method. No built-in support is
|
108
102
|
# provided for other mechanisms, such as URL re-writing. The caller is
|
109
|
-
# responsible for extracting the session id from the session_id
|
103
|
+
# responsible for extracting the session id from the session_id
|
110
104
|
# attribute and manually encoding it in URLs and adding it as a hidden
|
111
105
|
# input to HTML forms created by other mechanisms. Also, session expiry
|
112
106
|
# is not automatically handled.
|
@@ -124,10 +118,10 @@ class CGI
|
|
124
118
|
# session = CGI::Session.new(cgi,
|
125
119
|
# 'database_manager' => CGI::Session::PStore, # use PStore
|
126
120
|
# 'session_key' => '_rb_sess_id', # custom session key
|
127
|
-
# 'session_expires' => Time.now + 30 * 60, # 30 minute timeout
|
121
|
+
# 'session_expires' => Time.now + 30 * 60, # 30 minute timeout
|
128
122
|
# 'prefix' => 'pstore_sid_') # PStore option
|
129
123
|
# if cgi.has_key?('user_name') and cgi['user_name'] != ''
|
130
|
-
# # coerce to String: cgi[] returns the
|
124
|
+
# # coerce to String: cgi[] returns the
|
131
125
|
# # string-like CGI::QueryExtension::Value
|
132
126
|
# session['user_name'] = cgi['user_name'].to_s
|
133
127
|
# elsif !session['user_name']
|
@@ -143,11 +137,11 @@ class CGI
|
|
143
137
|
# cgi = CGI.new("html4")
|
144
138
|
#
|
145
139
|
# # We make sure to delete an old session if one exists,
|
146
|
-
# # not just to free resources, but to prevent the session
|
140
|
+
# # not just to free resources, but to prevent the session
|
147
141
|
# # from being maliciously hijacked later on.
|
148
142
|
# begin
|
149
|
-
# session = CGI::Session.new(cgi, 'new_session' => false)
|
150
|
-
# session.delete
|
143
|
+
# session = CGI::Session.new(cgi, 'new_session' => false)
|
144
|
+
# session.delete
|
151
145
|
# rescue ArgumentError # if no old session
|
152
146
|
# end
|
153
147
|
# session = CGI::Session.new(cgi, 'new_session' => true)
|
@@ -163,7 +157,7 @@ class CGI
|
|
163
157
|
|
164
158
|
def Session::callback(dbman) #:nodoc:
|
165
159
|
Proc.new{
|
166
|
-
|
160
|
+
dbman[0].close unless dbman.empty?
|
167
161
|
}
|
168
162
|
end
|
169
163
|
|
@@ -172,7 +166,7 @@ class CGI
|
|
172
166
|
# The session id is an MD5 hash based upon the time,
|
173
167
|
# a random number, and a constant string. This routine
|
174
168
|
# is used internally for automatically generated
|
175
|
-
# session ids.
|
169
|
+
# session ids.
|
176
170
|
def create_new_id
|
177
171
|
require 'securerandom'
|
178
172
|
begin
|
@@ -205,7 +199,7 @@ class CGI
|
|
205
199
|
# it is retrieved from the +session_key+ parameter
|
206
200
|
# of the request, or automatically generated for
|
207
201
|
# a new session.
|
208
|
-
# new_session:: if true, force creation of a new session. If not set,
|
202
|
+
# new_session:: if true, force creation of a new session. If not set,
|
209
203
|
# a new session is only created if none currently
|
210
204
|
# exists. If false, a new session is never created,
|
211
205
|
# and if none currently exists and the +session_id+
|
@@ -220,7 +214,7 @@ class CGI
|
|
220
214
|
# The following options are also recognised, but only apply if the
|
221
215
|
# session id is stored in a cookie.
|
222
216
|
#
|
223
|
-
# session_expires:: the time the current session expires, as a
|
217
|
+
# session_expires:: the time the current session expires, as a
|
224
218
|
# +Time+ object. If not set, the session will terminate
|
225
219
|
# when the user's browser is closed.
|
226
220
|
# session_domain:: the hostname domain for which this session is valid.
|
@@ -232,10 +226,10 @@ class CGI
|
|
232
226
|
# +option+ is also passed on to the session storage class initializer; see
|
233
227
|
# the documentation for each session storage class for the options
|
234
228
|
# they support.
|
235
|
-
#
|
229
|
+
#
|
236
230
|
# The retrieved or created session is automatically added to +request+
|
237
231
|
# as a cookie, and also to its +output_hidden+ table, which is used
|
238
|
-
# to add hidden input elements to forms.
|
232
|
+
# to add hidden input elements to forms.
|
239
233
|
#
|
240
234
|
# *WARNING* the +output_hidden+
|
241
235
|
# fields are surrounded by a <fieldset> tag in HTML 4 generation, which
|
@@ -253,26 +247,26 @@ class CGI
|
|
253
247
|
session_key = option['session_key'] || '_session_id'
|
254
248
|
session_id = option['session_id']
|
255
249
|
unless session_id
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
250
|
+
if option['new_session']
|
251
|
+
session_id = create_new_id
|
252
|
+
@new_session = true
|
253
|
+
end
|
260
254
|
end
|
261
255
|
unless session_id
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
256
|
+
if request.key?(session_key)
|
257
|
+
session_id = request[session_key]
|
258
|
+
session_id = session_id.read if session_id.respond_to?(:read)
|
259
|
+
end
|
260
|
+
unless session_id
|
261
|
+
session_id, = request.cookies[session_key]
|
262
|
+
end
|
263
|
+
unless session_id
|
264
|
+
unless option.fetch('new_session', true)
|
265
|
+
raise ArgumentError, "session_key `%s' should be supplied"%session_key
|
266
|
+
end
|
267
|
+
session_id = create_new_id
|
268
|
+
@new_session = true
|
269
|
+
end
|
276
270
|
end
|
277
271
|
@session_id = session_id
|
278
272
|
dbman = option['database_manager'] || FileStore
|
@@ -283,24 +277,25 @@ class CGI
|
|
283
277
|
raise ArgumentError, "invalid session_id `%s'"%session_id
|
284
278
|
end
|
285
279
|
session_id = @session_id = create_new_id unless session_id
|
286
|
-
|
280
|
+
@new_session=true
|
287
281
|
retry
|
288
282
|
end
|
289
283
|
request.instance_eval do
|
290
|
-
|
291
|
-
|
284
|
+
@output_hidden = {session_key => session_id} unless option['no_hidden']
|
285
|
+
@output_cookies = [
|
292
286
|
Cookie::new("name" => session_key,
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
287
|
+
"value" => session_id,
|
288
|
+
"expires" => option['session_expires'],
|
289
|
+
"domain" => option['session_domain'],
|
290
|
+
"secure" => option['session_secure'],
|
291
|
+
"path" =>
|
292
|
+
if option['session_path']
|
293
|
+
option['session_path']
|
294
|
+
elsif ENV["SCRIPT_NAME"]
|
295
|
+
File::dirname(ENV["SCRIPT_NAME"])
|
296
|
+
else
|
297
|
+
""
|
298
|
+
end)
|
304
299
|
] unless option['no_cookies']
|
305
300
|
end
|
306
301
|
@dbprot = [@dbman]
|
@@ -313,7 +308,7 @@ class CGI
|
|
313
308
|
@data[key]
|
314
309
|
end
|
315
310
|
|
316
|
-
# Set the session
|
311
|
+
# Set the session data for key +key+.
|
317
312
|
def []=(key, val)
|
318
313
|
@write_lock ||= true
|
319
314
|
@data ||= @dbman.restore
|
@@ -322,11 +317,11 @@ class CGI
|
|
322
317
|
|
323
318
|
# Store session data on the server. For some session storage types,
|
324
319
|
# this is a no-op.
|
325
|
-
def update
|
320
|
+
def update
|
326
321
|
@dbman.update
|
327
322
|
end
|
328
323
|
|
329
|
-
# Store session data on the server and close the session storage.
|
324
|
+
# Store session data on the server and close the session storage.
|
330
325
|
# For some session storage types, this is a no-op.
|
331
326
|
def close
|
332
327
|
@dbman.close
|
@@ -358,7 +353,7 @@ class CGI
|
|
358
353
|
# created. The session id must only contain alphanumeric
|
359
354
|
# characters; automatically generated session ids observe
|
360
355
|
# this requirement.
|
361
|
-
#
|
356
|
+
#
|
362
357
|
# +option+ is a hash of options for the initializer. The
|
363
358
|
# following options are recognised:
|
364
359
|
#
|
@@ -367,7 +362,7 @@ class CGI
|
|
367
362
|
# on Unix systems).
|
368
363
|
# prefix:: the prefix to add to the session id when generating
|
369
364
|
# the filename for this session's FileStore file.
|
370
|
-
# Defaults to
|
365
|
+
# Defaults to "cgi_sid_".
|
371
366
|
# suffix:: the prefix to add to the session id when generating
|
372
367
|
# the filename for this session's FileStore file.
|
373
368
|
# Defaults to the empty string.
|
@@ -375,56 +370,56 @@ class CGI
|
|
375
370
|
# This session's FileStore file will be created if it does
|
376
371
|
# not exist, or opened if it does.
|
377
372
|
def initialize(session, option={})
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
373
|
+
dir = option['tmpdir'] || Dir::tmpdir
|
374
|
+
prefix = option['prefix'] || 'cgi_sid_'
|
375
|
+
suffix = option['suffix'] || ''
|
376
|
+
id = session.session_id
|
382
377
|
require 'digest/md5'
|
383
378
|
md5 = Digest::MD5.hexdigest(id)[0,16]
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
379
|
+
@path = dir+"/"+prefix+md5+suffix
|
380
|
+
if File::exist? @path
|
381
|
+
@hash = nil
|
382
|
+
else
|
388
383
|
unless session.new_session
|
389
384
|
raise CGI::Session::NoSession, "uninitialized session"
|
390
385
|
end
|
391
|
-
|
392
|
-
|
386
|
+
@hash = {}
|
387
|
+
end
|
393
388
|
end
|
394
389
|
|
395
390
|
# Restore session state from the session's FileStore file.
|
396
391
|
#
|
397
392
|
# Returns the session state as a hash.
|
398
393
|
def restore
|
399
|
-
|
400
|
-
|
394
|
+
unless @hash
|
395
|
+
@hash = {}
|
401
396
|
begin
|
402
397
|
lockf = File.open(@path+".lock", "r")
|
403
398
|
lockf.flock File::LOCK_SH
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
399
|
+
f = File.open(@path, 'r')
|
400
|
+
for line in f
|
401
|
+
line.chomp!
|
402
|
+
k, v = line.split('=',2)
|
403
|
+
@hash[CGI::unescape(k)] = Marshal.restore(CGI::unescape(v))
|
404
|
+
end
|
410
405
|
ensure
|
411
|
-
|
406
|
+
f.close unless f.nil?
|
412
407
|
lockf.close if lockf
|
413
408
|
end
|
414
|
-
|
415
|
-
|
409
|
+
end
|
410
|
+
@hash
|
416
411
|
end
|
417
412
|
|
418
413
|
# Save session state to the session's FileStore file.
|
419
414
|
def update
|
420
|
-
|
415
|
+
return unless @hash
|
421
416
|
begin
|
422
417
|
lockf = File.open(@path+".lock", File::CREAT|File::RDWR, 0600)
|
423
|
-
|
418
|
+
lockf.flock File::LOCK_EX
|
424
419
|
f = File.open(@path+".new", File::CREAT|File::TRUNC|File::WRONLY, 0600)
|
425
|
-
|
426
|
-
|
427
|
-
|
420
|
+
for k,v in @hash
|
421
|
+
f.printf "%s=%s\n", CGI::escape(k), CGI::escape(String(Marshal.dump(v)))
|
422
|
+
end
|
428
423
|
f.close
|
429
424
|
File.rename @path+".new", @path
|
430
425
|
ensure
|
@@ -435,22 +430,21 @@ class CGI
|
|
435
430
|
|
436
431
|
# Update and close the session's FileStore file.
|
437
432
|
def close
|
438
|
-
|
433
|
+
update
|
439
434
|
end
|
440
435
|
|
441
436
|
# Close and delete the session's FileStore file.
|
442
437
|
def delete
|
443
438
|
File::unlink @path+".lock" rescue nil
|
444
439
|
File::unlink @path+".new" rescue nil
|
445
|
-
File::unlink @path
|
446
|
-
rescue Errno::ENOENT
|
440
|
+
File::unlink @path rescue Errno::ENOENT
|
447
441
|
end
|
448
442
|
end
|
449
443
|
|
450
444
|
# In-memory session storage class.
|
451
445
|
#
|
452
446
|
# Implements session storage as a global in-memory hash. Session
|
453
|
-
# data will only persist for as long as the ruby interpreter
|
447
|
+
# data will only persist for as long as the ruby interpreter
|
454
448
|
# instance does.
|
455
449
|
class MemoryStore
|
456
450
|
GLOBAL_HASH_TABLE = {} #:nodoc:
|
@@ -461,7 +455,7 @@ class CGI
|
|
461
455
|
# +option+ is a list of initialisation options. None are
|
462
456
|
# currently recognised.
|
463
457
|
def initialize(session, option=nil)
|
464
|
-
|
458
|
+
@session_id = session.session_id
|
465
459
|
unless GLOBAL_HASH_TABLE.key?(@session_id)
|
466
460
|
unless session.new_session
|
467
461
|
raise CGI::Session::NoSession, "uninitialized session"
|
@@ -474,26 +468,63 @@ class CGI
|
|
474
468
|
#
|
475
469
|
# Returns session data as a hash.
|
476
470
|
def restore
|
477
|
-
|
471
|
+
GLOBAL_HASH_TABLE[@session_id]
|
472
|
+
end
|
473
|
+
|
474
|
+
# Update session state.
|
475
|
+
#
|
476
|
+
# A no-op.
|
477
|
+
def update
|
478
|
+
# don't need to update; hash is shared
|
479
|
+
end
|
480
|
+
|
481
|
+
# Close session storage.
|
482
|
+
#
|
483
|
+
# A no-op.
|
484
|
+
def close
|
485
|
+
# don't need to close
|
486
|
+
end
|
487
|
+
|
488
|
+
# Delete the session state.
|
489
|
+
def delete
|
490
|
+
GLOBAL_HASH_TABLE.delete(@session_id)
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
# Dummy session storage class.
|
495
|
+
#
|
496
|
+
# Implements session storage place holder. No actual storage
|
497
|
+
# will be done.
|
498
|
+
class NullStore
|
499
|
+
# Create a new NullStore instance.
|
500
|
+
#
|
501
|
+
# +session+ is the session this instance is associated with.
|
502
|
+
# +option+ is a list of initialisation options. None are
|
503
|
+
# currently recognised.
|
504
|
+
def initialize(session, option=nil)
|
505
|
+
end
|
506
|
+
|
507
|
+
# Restore (empty) session state.
|
508
|
+
def restore
|
509
|
+
{}
|
478
510
|
end
|
479
511
|
|
480
512
|
# Update session state.
|
481
513
|
#
|
482
514
|
# A no-op.
|
483
515
|
def update
|
484
|
-
# don't need to update; hash is shared
|
485
516
|
end
|
486
517
|
|
487
518
|
# Close session storage.
|
488
519
|
#
|
489
520
|
# A no-op.
|
490
521
|
def close
|
491
|
-
# don't need to close
|
492
522
|
end
|
493
523
|
|
494
524
|
# Delete the session state.
|
525
|
+
#
|
526
|
+
# A no-op.
|
495
527
|
def delete
|
496
|
-
GLOBAL_HASH_TABLE.delete(@session_id)
|
497
528
|
end
|
498
529
|
end
|
499
530
|
end
|
data/rubysl-cgi-session.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysl-cgi-session
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Shirai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.5'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubysl-prettyprint
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.0'
|
69
55
|
description: Ruby standard library cgi-session.
|
70
56
|
email:
|
71
57
|
- brixen@gmail.com
|