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
632 B

  1. module Semantic
  2. # useful public functions
  3. module Helper
  4. class << self
  5. include AnsiColors
  6. def stackisize(*items)
  7. return if items.empty?
  8. Rails.backtrace_cleaner
  9. .clean(items)
  10. .map { |item| ansi_trace(item, '➟') }
  11. .join("\n")
  12. end
  13. private
  14. def ansi_trace(trace, symbol)
  15. match = trace.match(/(↳ )?(.*:\d+)(:in `)?(.*'?)/) # only m2(=file) and m4(=optional function) are useful
  16. return trace unless match
  17. _, m2, _, m4 = match.captures
  18. "#{symbol} #{m2} #{BOLD}#{m4.chop}#{CLEAR}"
  19. end
  20. end
  21. end
  22. end