From d5b3f884e0fc232dd36a466a32bbe09659e67fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 1 Jan 2019 09:57:12 +0100 Subject: small code cleanups --- lib/zorglub/app.rb | 19 +++++++++---------- lib/zorglub/node.rb | 10 ++++------ lib/zorglub/rack_session.rb | 4 ---- lib/zorglub/session.rb | 4 ---- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/lib/zorglub/app.rb b/lib/zorglub/app.rb index 43b03b7..9619968 100644 --- a/lib/zorglub/app.rb +++ b/lib/zorglub/app.rb @@ -78,11 +78,10 @@ module Zorglub end def register_engine! name, ext, proc - return unless name if ext.nil? or ext.empty? x = nil else - x = (ext[0]=='.' ? (ext.length==1 ? nil : ext) : '.'+ext) + x = (ext[0]=='.' ? (ext.length==1 ? nil : ext) : '.' + ext) end @options[:engines][name]=[ proc, x ] end @@ -94,20 +93,20 @@ module Zorglub end def view_base_path - p = @options[:view_path] - ( p.nil? ? File.join(@options[:root], @options[:view_dir]) : p ) + _base_path @options[:view_path], :view_dir end def layout_base_path - p = @options[:layout_path] - ( p.nil? ? File.join(@options[:root], @options[:layout_dir]) : p ) + _base_path @options[:layout_path], :layout_dir end def static_base_path - p = @options[:static_path] - ( p.nil? ? File.join(@options[:root], @options[:static_dir]) : p ) + _base_path @options[:static_path], :static_dir + end + + private + def _base_path p, sym + ( p.nil? ? File.join(@options[:root], @options[sym]) : p ) end end end -# -# EOF diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb index 42b0304..d1a075a 100644 --- a/lib/zorglub/node.rb +++ b/lib/zorglub/node.rb @@ -74,7 +74,7 @@ module Zorglub def layout return nil if @layout.nil? - File.join(self.class.layout_base_path, @layout)+ext + File.join(self.class.layout_base_path, @layout) + ext end def no_view! @@ -87,7 +87,7 @@ module Zorglub def view return nil if @view.nil? - File.join(self.class.view_base_path, @view)+ext + File.join(self.class.view_base_path, @view) + ext end def static! val, lifetime=0 @@ -97,11 +97,11 @@ module Zorglub def static return nil if not @static or @view.nil? - File.join(app.static_base_path, @view)+ext + File.join(app.static_base_path, @view) + ext end def ext! ext - @ext = ( (ext.nil? or ext.empty?) ? nil : (ext[0]=='.' ? (ext.length==1 ? nil : ext) : '.'+ext) ) + @ext = ( (ext.nil? or ext.empty?) ? nil : (ext[0]=='.' ? (ext.length==1 ? nil : ext) : '.' + ext) ) end def ext @@ -332,5 +332,3 @@ module Zorglub end end - -# EOF diff --git a/lib/zorglub/rack_session.rb b/lib/zorglub/rack_session.rb index b7c19fc..d08cd84 100644 --- a/lib/zorglub/rack_session.rb +++ b/lib/zorglub/rack_session.rb @@ -1,13 +1,9 @@ # -*- coding: UTF-8 -*- module Zorglub - class Node - def session @request.session end - end - end diff --git a/lib/zorglub/session.rb b/lib/zorglub/session.rb index db36fd2..fc5fdbe 100644 --- a/lib/zorglub/session.rb +++ b/lib/zorglub/session.rb @@ -148,9 +148,5 @@ module Zorglub Digest::SHA2.hexdigest(entropy.join) end end - end - end - -# EOF -- cgit v1.1-2-g2b99