Sha256: 7a8cd884f4524e670d0df00b710ec78d793df8861728988169f6a29e560d3886

Contents?: true

Size: 1010 Bytes

Versions: 3

Compression:

Stored size: 1010 Bytes

Contents

module Bullet
  module StackTraceFilter
    VENDOR_PATH = '/vendor'.freeze

    def caller_in_project
      app_root = rails? ? Rails.root.to_s : Dir.pwd
      vendor_root = app_root + VENDOR_PATH
      caller_locations.select do |location|
        caller_path = location.absolute_path.to_s
        caller_path.include?(app_root) && !caller_path.include?(vendor_root) ||
          Bullet.stacktrace_includes.any? do |include_pattern|
          case include_pattern
          when String
            caller_path.include?(include_pattern)
          when Regexp
            caller_path =~ include_pattern
          end
        end
      end
    end

    def excluded_stacktrace_path?
      Bullet.stacktrace_excludes.any? do |exclude_pattern|
        caller_in_project.any? do |caller_path|
          case exclude_pattern
          when String
            caller_path.include?(exclude_pattern)
          when Regexp
            caller_path =~ exclude_pattern
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bullet-5.7.1 lib/bullet/stack_trace_filter.rb
bullet-5.7.0 lib/bullet/stack_trace_filter.rb
bullet-5.6.1 lib/bullet/stack_trace_filter.rb