pvincent
2 months ago
4 changed files with 68 additions and 29 deletions
-
5config/initializers/backtrace_cleaning.rb
-
23lib/semantic/abstract_formatter.rb
-
26lib/semantic/helper.rb
-
43lib/semantic/subscribers/action_view.rb
@ -1,3 +1,2 @@ |
|||||
bc = Rails.backtrace_cleaner |
|
||||
# bc.add_silencer { |line| %r{^lib/(monkey_patches|semantic)}.match?(line) } |
|
||||
bc.add_silencer { |line| %r{^lib/(monkey_patches)}.match?(line) } |
|
||||
|
Rails.backtrace_cleaner |
||||
|
.add_silencer { |line| %r{^lib/(monkey_patches)}.match?(line) } |
@ -0,0 +1,26 @@ |
|||||
|
module Semantic |
||||
|
# useful public functions |
||||
|
module Helper |
||||
|
class << self |
||||
|
include AnsiColors |
||||
|
def stackisize(*items) |
||||
|
return if items.empty? |
||||
|
|
||||
|
Rails.backtrace_cleaner |
||||
|
.clean(items) |
||||
|
.map { |item| ansi_trace(item, '➟') } |
||||
|
.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} #{BOLD}#{m4.chop}#{CLEAR}" |
||||
|
end |
||||
|
end |
||||
|
end |
||||
|
end |
Write
Preview
Loading…
Cancel
Save
Reference in new issue