require 'facets/core/string/margin' # TODO get rid of. def breakout( error ) file, line = *error.exception.backtrace[0].split(':') line = line.to_i puts error e = "# DEBUG " + error.to_s e.gsub!("`","'") e = Regexp.escape(e) case ed = ENV['EDITOR'] when 'vi', 'vim', 'gvim' cmd = %[ |#{ed} -e -s #{file} <<-EOS |:#{line} |a |#{e} |. |:.,+#{e.size} |EOS ].margin else puts "EDITOR environment variable not set" end system cmd end # command-line mode if __FILE__ == $0 begin load $file = ARGV[0] rescue Exception => e error = breakout(e) end end