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.
 
 
 
 
 

26 lines
649 B

module Semantic
# useful public functions
module Helper
class << self
include AnsiColors
def stackisize(*items, symbol: '➟')
return if items.empty?
Rails.backtrace_cleaner
.clean(items)
.map { |item| ansi_trace(item, symbol) }
.join("\n")
end
private
def 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} #{colorize(m4.chop, BOLD)}"
end
end
end
end