You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
452 B

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. require_relative 'ansi_colors'
  2. # gather common definitions and functions
  3. class AnsiCommon
  4. ANSI_REGEX = /\e\[[0-9;]*m/ # TODO: support for \x1b and \033
  5. def self.ansi_trace(trace, symbol)
  6. match = trace.match(/(↳ )?(.*:\d+)(:in `)?(.*'?)/) # only m2(=file) and m4(=optional function) are useful
  7. return trace unless match
  8. _, m2, _, m4 = match.captures
  9. "#{symbol} #{m2} #{AnsiColors::BOLD}#{m4.chop}#{AnsiColors::CLEAR}"
  10. end
  11. end