Module: Rib::StripBacktrace
- Extended by:
- Plugin
- Defined in:
- lib/rib/core/strip_backtrace.rb
Instance Attribute Summary
Attributes included from Plugin
#disabled
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Plugin
disable, disabled?, enable, enabled?, extended
Class Method Details
.replace_path_prefix(prefix, substitute, path) ⇒ Object
41
42
43
|
# File 'lib/rib/core/strip_backtrace.rb', line 41
def replace_path_prefix prefix, substitute, path
path.sub(/\A#{Regexp.escape(prefix)}\//, substitute)
end
|
.strip_backtrace(backtrace) ⇒ Object
24
25
26
|
# File 'lib/rib/core/strip_backtrace.rb', line 24
def strip_backtrace backtrace
strip_home_backtrace(strip_cwd_backtrace(strip_rib_backtrace(backtrace)))
end
|
.strip_cwd_backtrace(backtrace) ⇒ Object
32
33
34
|
# File 'lib/rib/core/strip_backtrace.rb', line 32
def strip_cwd_backtrace backtrace
backtrace.map(&method(:replace_path_prefix).curry[Dir.pwd, ''])
end
|
.strip_home_backtrace(backtrace) ⇒ Object
28
29
30
|
# File 'lib/rib/core/strip_backtrace.rb', line 28
def strip_home_backtrace backtrace
backtrace.map(&method(:replace_path_prefix).curry[ENV['HOME'], '~/'])
end
|
.strip_rib_backtrace(backtrace) ⇒ Object
36
37
38
39
|
# File 'lib/rib/core/strip_backtrace.rb', line 36
def strip_rib_backtrace backtrace
backtrace[
0..backtrace.rindex{ |l| l =~ /\(#{name}\):\d+:in `.+?'/ } || -1]
end
|
Instance Method Details
10
11
12
13
14
|
# File 'lib/rib/core/strip_backtrace.rb', line 10
def format_error err
return super if StripBacktrace.disabled?
message, backtrace = get_error(err)
"#{message}\n #{backtrace.join("\n ")}"
end
|
#get_error(err) ⇒ Object
16
17
18
19
|
# File 'lib/rib/core/strip_backtrace.rb', line 16
def get_error err
return super if StripBacktrace.disabled?
["#{err.class}: #{err.message}", strip_backtrace(err.backtrace)]
end
|