Class: Airbrake::Filters::RootDirectoryFilter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/airbrake-ruby/filters/root_directory_filter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Replaces root directory with a label.

Constant Summary collapse

PROJECT_ROOT_LABEL =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Returns:

  • (String)
'/PROJECT_ROOT'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_directory) ⇒ RootDirectoryFilter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RootDirectoryFilter.



12
13
14
15
# File 'lib/airbrake-ruby/filters/root_directory_filter.rb', line 12

def initialize(root_directory)
  @root_directory = root_directory
  @weight = 100
end

Instance Attribute Details

#weightInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)


10
11
12
# File 'lib/airbrake-ruby/filters/root_directory_filter.rb', line 10

def weight
  @weight
end

Instance Method Details

#call(notice) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

This is a mandatory method required by any filter integrated with FilterChain.

Parameters:

  • notice (Notice)

    the notice to be filtered

See Also:



18
19
20
21
22
23
24
25
26
# File 'lib/airbrake-ruby/filters/root_directory_filter.rb', line 18

def call(notice)
  notice[:errors].each do |error|
    error[:backtrace].each do |frame|
      next unless (file = frame[:file])

      file.sub!(/\A#{@root_directory}/, PROJECT_ROOT_LABEL)
    end
  end
end