module Aygabtu::PointOfCall

Public Class Methods

gem_root() click to toggle source
# File lib/aygabtu/point_of_call.rb, line 17
def self.gem_root
  @gem_root ||= begin
    path = Pathname(__FILE__)
    while new_path = path.parent and new_path.to_s.include?('lib/aygabtu')
      path = new_path
    end

    path.to_s
  end
end

Public Instance Methods

file_and_line_at_point_of_call() click to toggle source
# File lib/aygabtu/point_of_call.rb, line 12
def file_and_line_at_point_of_call
  filename, line_and_context = point_of_call.split(':', 2)
  [filename, line_and_context.to_i] # make use of the fact to_i tolerates being passed a string only _beginning_ with a number
end
point_of_call() click to toggle source
# File lib/aygabtu/point_of_call.rb, line 8
def point_of_call
  caller.drop_while { |point| point.start_with?(PointOfCall.gem_root) }.first
end