BigW Consortium Gitlab

location.rb 698 Bytes
Newer Older
1 2 3 4 5 6 7
module Gitlab
  module Sherlock
    class Location
      attr_reader :path, :line

      SHERLOCK_DIR = File.dirname(__FILE__)

8
      # Creates a new Location from a `Thread::Backtrace::Location`.
9 10 11 12
      def self.from_ruby_location(location)
        new(location.path, location.lineno)
      end

13 14
      # path - The full path of the frame as a String.
      # line - The line number of the frame as a Fixnum.
15 16 17 18 19
      def initialize(path, line)
        @path = path
        @line = line
      end

20
      # Returns true if the current frame originated from the application.
21 22 23 24 25 26
      def application?
        @path.start_with?(Rails.root.to_s) && !path.start_with?(SHERLOCK_DIR)
      end
    end
  end
end