class Guard::Dsl

def _cleanup_backtrace(backtrace)

def _cleanup_backtrace(backtrace)
  dirs = { File.realpath(Dir.pwd) => ".", }
  gem_env = ENV["GEM_HOME"] || ""
  dirs[gem_env] = "$GEM_HOME" unless gem_env.empty?
  gem_paths = (ENV["GEM_PATH"] || "").split(File::PATH_SEPARATOR)
  gem_paths.each_with_index do |path, index|
    dirs[path] = "$GEM_PATH[#{index}]"
  end
  backtrace.dup.map do |raw_line|
    path = nil
    symlinked_path = raw_line.split(":").first
    begin
      path = raw_line.sub(symlinked_path, File.realpath(symlinked_path))
      dirs.detect { |dir, name| path.sub!(File.realpath(dir), name) }
      path
    rescue Errno::ENOENT
      path || symlinked_path
    end
  end
end