Created
January 30, 2016 15:03
-
-
Save cheerfulstoic/0f4bfbc660e1430e2ad1 to your computer and use it in GitHub Desktop.
Method to find the first uncommon point in the call stack of a line of Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def puts_first_common_point | |
if $previous_caller | |
this_caller = caller[1..-1] | |
this_caller.each_with_index do |line, i| | |
if $previous_caller[i] == line | |
puts line | |
else | |
puts 'FIRST DIFFERENT LINE:' | |
puts "Previous: #{$previous_caller[i]}" | |
puts "This: #{line}" | |
exit! | |
end | |
end | |
else | |
$previous_caller = caller[1..-1] | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment