Class: Telebugs::Middleware::RootDirectoryFilter
- Inherits:
-
BaseMiddleware
- Object
- BaseMiddleware
- Telebugs::Middleware::RootDirectoryFilter
- Defined in:
- lib/telebugs/middleware/root_directory_filter.rb
Overview
Filters out the root directory from the backtrace paths.
Constant Summary
Constants inherited from BaseMiddleware
BaseMiddleware::DEFAULT_WEIGHT
Instance Method Summary collapse
- #call(report) ⇒ Object
-
#initialize(root_directory) ⇒ RootDirectoryFilter
constructor
A new instance of RootDirectoryFilter.
- #weight ⇒ Object
Constructor Details
#initialize(root_directory) ⇒ RootDirectoryFilter
Returns a new instance of RootDirectoryFilter.
7 8 9 |
# File 'lib/telebugs/middleware/root_directory_filter.rb', line 7 def initialize(root_directory) @root_directory = root_directory end |
Instance Method Details
#call(report) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/telebugs/middleware/root_directory_filter.rb', line 11 def call(report) report.data[:errors].each do |error| error[:backtrace].each do |frame| next unless (file = frame[:file]) next unless file.start_with?(@root_directory) frame[:root_dir] = true file.sub!(/#{@root_directory}\/?/, "") end end end |
#weight ⇒ Object
23 24 25 |
# File 'lib/telebugs/middleware/root_directory_filter.rb', line 23 def weight -999 end |