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
const_missing, disable, disabled?, enable, enabled?, extended
Class Method Details
23
24
25
26
27
28
|
# File 'lib/rib/core/strip_backtrace.rb', line 23
def format_backtrace backtrace
return super if StripBacktrace.disabled?
strip_home_backtrace(
strip_cwd_backtrace(
strip_rib_backtrace(super(backtrace))))
end
|
.replace_path_prefix(prefix, substitute, path) ⇒ Object
43
44
45
|
# File 'lib/rib/core/strip_backtrace.rb', line 43
def replace_path_prefix prefix, substitute, path
path.sub(/\A#{Regexp.escape(prefix)}\//, substitute)
end
|
.strip_cwd_backtrace(backtrace) ⇒ Object
34
35
36
|
# File 'lib/rib/core/strip_backtrace.rb', line 34
def strip_cwd_backtrace backtrace
backtrace.map(&method(:replace_path_prefix).curry[Dir.pwd, ''])
end
|
.strip_home_backtrace(backtrace) ⇒ Object
30
31
32
|
# File 'lib/rib/core/strip_backtrace.rb', line 30
def strip_home_backtrace backtrace
backtrace.map(&method(:replace_path_prefix).curry[ENV['HOME'], '~/'])
end
|
.strip_rib_backtrace(backtrace) ⇒ Object
38
39
40
41
|
# File 'lib/rib/core/strip_backtrace.rb', line 38
def strip_rib_backtrace backtrace
backtrace[
0..backtrace.rindex{ |l| l =~ /\(#{name}\):\d+:in `.+?'/ } || -1]
end
|
Instance Method Details
11
12
13
14
15
|
# File 'lib/rib/core/strip_backtrace.rb', line 11
def format_error err
return super if StripBacktrace.disabled?
message, backtrace = get_error(err)
"#{message}\n #{backtrace.join("\n ")}"
end
|
#get_error(err) ⇒ Object
17
18
19
20
|
# File 'lib/rib/core/strip_backtrace.rb', line 17
def get_error err
return super if StripBacktrace.disabled?
["#{err.class}: #{err.message}", format_backtrace(err.backtrace)]
end
|