Last active
August 29, 2015 13:56
-
-
Save rhettc/8792937 to your computer and use it in GitHub Desktop.
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 app_path | |
unless @app_path | |
git_root = `git rev-parse --show-toplevel`.chomp | |
@app_path = $?.success? ? git_root : Dir.pwd | |
end | |
@app_path | |
end | |
class Exception | |
def quick_trace(lines = 5) | |
beautify(backtrace.take lines) | |
end | |
# filter the backtrace to show lines from files in the 'current app' | |
def app_trace | |
beautify(backtrace.grep /#{app_path}/) | |
end | |
def filter_path(paths) | |
paths.map { |path| path.gsub app_path, ''} | |
end | |
# remove uninteresting path segments and prepend the result to make our printed result aligned | |
def beautify(entries) | |
filter_path(entries).unshift '' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment