Module: Rack::Bug::FilteredBacktrace

Included in:
RedisPanel::Stats::Query, SQLPanel::QueryResult
Defined in:
lib/rack/bug/filtered_backtrace.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.backtrace_regexpObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rack/bug/filtered_backtrace.rb', line 17

def self.backtrace_regexp
  @backtrace_regexp ||=
    begin
      if true or (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



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rack/bug/filtered_backtrace.rb', line 29

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

#backtraceObject



5
6
7
# File 'lib/rack/bug/filtered_backtrace.rb', line 5

def backtrace
  @backtrace
end

#filtered_backtraceObject



13
14
15
# File 'lib/rack/bug/filtered_backtrace.rb', line 13

def filtered_backtrace
  @filtered_backtrace ||= @backtrace.grep(FilteredBacktrace.backtrace_regexp)
end

#has_backtrace?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/rack/bug/filtered_backtrace.rb', line 9

def has_backtrace?
  filtered_backtrace.any?
end