Skip to content

Instantly share code, notes, and snippets.

@cheerfulstoic
Created January 30, 2016 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheerfulstoic/0f4bfbc660e1430e2ad1 to your computer and use it in GitHub Desktop.
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
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