lib/rack/insight/panel.rb in rack-insight-0.5.4 vs lib/rack/insight/panel.rb in rack-insight-0.5.5

- old
+ new

@@ -1,7 +1,7 @@ require "erb" -require "rack/insight/logger" +require "rack/insight/logging" require 'rack/insight/database' require 'rack/insight/instrumentation' require 'rack/insight/render' module Rack::Insight @@ -15,10 +15,11 @@ include Rack::Insight::Instrumentation::Client attr_reader :request class << self + attr_accessor :template_root def file_index return @file_index ||= Hash.new do |h,k| h[k] = [] end end @@ -38,11 +39,11 @@ return (file_index[rel_path] - panel_exclusion) ensure Thread::current['rack-panel_file'] = old_rel end - def current_panel_file + def current_panel_file(sub) return Thread::current['rack-panel_file'] || begin file_name = nil matched_line = nil caller.each do |line| @@ -56,17 +57,18 @@ matched_line = line unless file_name.nil? break unless file_name.nil? end break unless file_name.nil? end + sub.template_root = File.dirname(matched_line.split(':')[0]) if matched_line.respond_to?(:split) file_name end end def inherited(sub) - if filename = current_panel_file - Panel::file_index[current_panel_file] << sub + if filename = current_panel_file(sub) + Panel::file_index[filename] << sub else warn "Rack::Insight::Panel inherited by #{sub.name} outside rack-insight's :panel_load_paths. Discarded. Configured panel load paths are: #{Rack::Insight::Config.config[:panel_load_paths].inspect}" end end @@ -85,14 +87,14 @@ end end def call(env) @env = env - logger.debug{ "Before call: #{self.name}" } + logger.debug{ "Before call: #{self.name}" } if verbose(:debug) before(env) status, headers, body = @app.call(env) @request = Rack::Request.new(env) - logger.debug{ "After call: #{self.name}" } + logger.debug{ "After call: #{self.name}" } if verbose(:debug) after(env, status, headers, body) env["rack-insight.panels"] << self return [status, headers, body] end