diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-16 10:22:10 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-16 10:22:10 +0100 |
commit | 9d964f953f9aedf9362841207683ad0a47e88f30 (patch) | |
tree | 4b6cbbe4a763e77ec3075d45e90d8539be6b10f0 | |
parent | 600448a692abd79f44fe44e43f571537a492bad2 (diff) | |
download | zorglub-9d964f953f9aedf9362841207683ad0a47e88f30.zip zorglub-9d964f953f9aedf9362841207683ad0a47e88f30.tar.gz |
add Zorglub::Config.debug
-rw-r--r-- | lib/zorglub/config.rb | 1 | ||||
-rw-r--r-- | lib/zorglub/node.rb | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/zorglub/config.rb b/lib/zorglub/config.rb index cda71ac..b7e5785 100644 --- a/lib/zorglub/config.rb +++ b/lib/zorglub/config.rb @@ -4,6 +4,7 @@ module Zorglub # class Config @options = { + :debug => false, :root => '.', :engine => nil, :layout => 'default', diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb index d38862c..9974a20 100644 --- a/lib/zorglub/node.rb +++ b/lib/zorglub/node.rb @@ -60,6 +60,7 @@ module Zorglub def call env meth, *args = env['PATH_INFO'].sub(/^\//,'').split '/' meth||= 'index' + puts "=> #{meth}(#{args.join ','})" if Config.debug node = self.new env, {:engine=>engine,:layout=>layout,:view=>r(meth),:method=>meth,:args=>args,:static=>static} return error_404 node if not node.respond_to? meth node.realize! @@ -91,6 +92,7 @@ module Zorglub end # def error_404 node + puts " !! method not found" if Config.debug resp = node.response resp.status = 404 resp['Content-Type'] = 'text/plain' @@ -142,7 +144,9 @@ module Zorglub Dir.mkdir Config.static_base_path Dir.mkdir File.dirname path File.open(path, 'w') {|f| f.write("@mime:"+@mime+"\n"); f.write(@content); } + puts " * cache file created : #{path}" if Config.debug else + puts " * use cache file : #{path}" if Config.debug content = File.open(path, 'r') {|f| f.read } @content = content.sub /^@mime:(.*)\n/,'' @mime = $1 @@ -152,6 +156,10 @@ module Zorglub def compile! e, @options[:ext] = Config.engine_proc_ext @options[:engine], @options[:ext] v, l = view, layout + if Config.debug + puts " * "+(File.exists?(l) ? 'use layout' : 'not found layout')+" : "+l + puts " * "+(File.exists?(v) ? 'use view ' : 'not found view ')+" : "+v + end state (@options[:layout].nil? ? :partial : :view) @content, mime = e.call v, self if e and File.exists? v @mime = mime unless mime.nil? |