require_relative 'ansi_colors' # gather common definitions and functions class AnsiCommon def self.ansi_trace(trace, symbol) match = trace.match(/(↳ )?(.*:\d+)(:in `)?(.*'?)/) # only m2(=file) and m4(=optional function) are useful return trace unless match _, m2, _, m4 = match.captures "#{symbol} #{m2} #{AnsiColors::BOLD}#{m4.chop}#{AnsiColors::CLEAR}" end end