summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-06-17 17:22:18 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-06-17 17:22:18 +0200
commitc4fc070d4080bc609dfaba0db9e2e493cbffd1ac (patch)
treee703d9c85b1036059d112afef5a984ed9f4b9e81 /lib
parenta190b0c594a5636506984bb30da1f06fe64513cc (diff)
downloadzorglub-c4fc070d4080bc609dfaba0db9e2e493cbffd1ac.zip
zorglub-c4fc070d4080bc609dfaba0db9e2e493cbffd1ac.tar.gz
add Session class
Diffstat (limited to 'lib')
-rw-r--r--lib/zorglub.rb1
-rw-r--r--lib/zorglub/node.rb3
-rw-r--r--lib/zorglub/session.rb20
3 files changed, 23 insertions, 1 deletions
diff --git a/lib/zorglub.rb b/lib/zorglub.rb
index 9adda5d..62aa10c 100644
--- a/lib/zorglub.rb
+++ b/lib/zorglub.rb
@@ -9,6 +9,7 @@ module Zorglub
autoload :Config, './lib/zorglub/config.rb'
autoload :Helpers, './lib/zorglub/helpers.rb'
autoload :Node, './lib/zorglub/node.rb'
+ autoload :Session, './lib/zorglub/session.rb'
#
end
#
diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb
index b4f7e62..2e080ca 100644
--- a/lib/zorglub/node.rb
+++ b/lib/zorglub/node.rb
@@ -30,7 +30,8 @@ module Zorglub
def call env
meth, *args = env['PATH_INFO'][1..-1].split '/'
meth||= 'index'
- node = self.new Rack::Request.new(env), Rack::Response.new, {:engine=>engine,:layout=>layout,:view=>File.join(r,meth),:method=>meth,:args=>args}
+ action = {:engine=>engine,:layout=>layout,:view=>File.join(r,meth),:method=>meth,:args=>args}
+ node = self.new Rack::Request.new(env), Rack::Response.new, action
return error_404 node if not node.respond_to? meth
# TODO
# - session
diff --git a/lib/zorglub/session.rb b/lib/zorglub/session.rb
new file mode 100644
index 0000000..b119e2b
--- /dev/null
+++ b/lib/zorglub/session.rb
@@ -0,0 +1,20 @@
+# -*- coding: UTF-8 -*-
+#
+require 'securerandom'
+#
+module Zorglub
+ #
+ Config.session_id_length ||= 64
+ Config.session_ttl ||= (60 * 60 * 24 * 5)
+ #
+ class Session
+ #
+ def gen_session_id
+ SecureRandom.hex Config.session_id_length
+ end
+ #
+ end
+ #
+end
+#
+# EOF