Sha256: 07d948ba2f1bed4a32909ec177d71b2d2447e6a1d0464c01404e795a0d36e525

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

module Tennpipes

  # List of callers in a Tennpipes application that should be ignored as part of a stack trace.
  TENNPIPES_IGNORE_CALLERS = [
    %r{lib/tennpipes-.*$},
    %r{/tennpipes-.*/(lib|bin)},
    %r{/bin/tennpipes$},
    %r{/sinatra(/(base|main|show_?exceptions))?\.rb$},
    %r{lib/tilt.*\.rb$},
    %r{lib/rack.*\.rb$},
    %r{lib/mongrel.*\.rb$},
    %r{lib/shotgun.*\.rb$},
    %r{bin/shotgun$},
    %r{\(.*\)},
    %r{shoulda/context\.rb$},
    %r{mocha/integration},
    %r{test/unit},
    %r{rake_test_loader\.rb},
    %r{custom_require\.rb$},
    %r{active_support},
    %r{/thor}
  ] unless defined?(TENNPIPES_IGNORE_CALLERS)

  ##
  # Add rubinius (and hopefully other VM implementations) ignore patterns ...
  #
  TENNPIPES_IGNORE_CALLERS.concat(RUBY_IGNORE_CALLERS) if defined?(RUBY_IGNORE_CALLERS)

  private
  ##
  # The filename for the file that is the direct caller (first caller).
  #
  # @return [String]
  #   The file the caller method exists in.
  #
  def self.first_caller
    caller_files.first
  end

  #
  # Like +Kernel#caller+ but excluding certain magic entries and without
  # line / method information; the resulting array contains filenames only.
  #
  # @return [Array<String>]
  #   The files of the calling methods.
  #
  def self.caller_files
    caller(1).
      map    { |line| line.split(/:(?=\d|in )/)[0,2] }.
      reject { |file,line| TENNPIPES_IGNORE_CALLERS.any? { |pattern| file =~ pattern } }.
      map    { |file,line| file }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tennpipes-base-3.6.6 lib/tennpipes-base/caller.rb