Module: Rack::Insight::FilteredBacktrace
- Included in:
- ActiveResourcePanel::RequestResult, DefaultInvocation, RedisPanel::Stats::Query, SQLPanel::QueryResult, SphinxPanel::Stats::Query
- Defined in:
- lib/rack/insight/filtered_backtrace.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.backtrace_regexp ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rack/insight/filtered_backtrace.rb', line 16 def self.backtrace_regexp @backtrace_regexp ||= begin if !Rack::Insight::Config.filtered_backtrace || (app_root = root_for_backtrace_filtering).nil? /.*/ else excludes = %w{vendor} %r{^#{app_root}(?:#{::File::Separator}(?!#{excludes.join("|")}).+)$} end end end |
.root_for_backtrace_filtering(sub_path = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rack/insight/filtered_backtrace.rb', line 28 def self.root_for_backtrace_filtering(sub_path = nil) if defined?(Rails) && Rails.respond_to?(:root) sub_path ? Rails.root.join(sub_path) : Rails.root else root = if defined?(RAILS_ROOT) RAILS_ROOT elsif defined?(ROOT) ROOT elsif defined?(Sinatra::Application) Sinatra::Application.root else nil end sub_path ? ::File.join(root, sub_path) : root end end |
Instance Method Details
#backtrace ⇒ Object
4 5 6 |
# File 'lib/rack/insight/filtered_backtrace.rb', line 4 def backtrace @backtrace end |
#filtered_backtrace ⇒ Object
12 13 14 |
# File 'lib/rack/insight/filtered_backtrace.rb', line 12 def filtered_backtrace @filtered_backtrace ||= @backtrace.respond_to?(:grep) ? @backtrace.grep(FilteredBacktrace.backtrace_regexp) : [] end |
#has_backtrace? ⇒ Boolean
8 9 10 |
# File 'lib/rack/insight/filtered_backtrace.rb', line 8 def has_backtrace? filtered_backtrace.any? end |