From c4fc070d4080bc609dfaba0db9e2e493cbffd1ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 17 Jun 2011 17:22:18 +0200 Subject: add Session class --- lib/zorglub.rb | 1 + lib/zorglub/node.rb | 3 ++- lib/zorglub/session.rb | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 lib/zorglub/session.rb 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 -- cgit v1.1-2-g2b99