2015-11-04 13:13:19 -05:00
|
|
|
module Gitlab
|
|
|
|
module Sherlock
|
|
|
|
class Location
|
|
|
|
attr_reader :path, :line
|
|
|
|
|
|
|
|
SHERLOCK_DIR = File.dirname(__FILE__)
|
|
|
|
|
2015-11-05 12:01:05 -05:00
|
|
|
# Creates a new Location from a `Thread::Backtrace::Location`.
|
2015-11-04 13:13:19 -05:00
|
|
|
def self.from_ruby_location(location)
|
|
|
|
new(location.path, location.lineno)
|
|
|
|
end
|
|
|
|
|
2015-11-05 12:01:05 -05:00
|
|
|
# path - The full path of the frame as a String.
|
|
|
|
# line - The line number of the frame as a Fixnum.
|
2015-11-04 13:13:19 -05:00
|
|
|
def initialize(path, line)
|
|
|
|
@path = path
|
|
|
|
@line = line
|
|
|
|
end
|
|
|
|
|
2015-11-05 12:01:05 -05:00
|
|
|
# Returns true if the current frame originated from the application.
|
2015-11-04 13:13:19 -05:00
|
|
|
def application?
|
|
|
|
@path.start_with?(Rails.root.to_s) && !path.start_with?(SHERLOCK_DIR)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|