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
22
23
24
25
26
27
|
# File 'lib/rib/core/strip_backtrace.rb', line 22
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
42
43
44
|
# File 'lib/rib/core/strip_backtrace.rb', line 42
def replace_path_prefix prefix, substitute, path
path.sub(/\A#{Regexp.escape(prefix)}\//, substitute)
end
|
.strip_cwd_backtrace(backtrace) ⇒ Object
33
34
35
|
# File 'lib/rib/core/strip_backtrace.rb', line 33
def strip_cwd_backtrace backtrace
backtrace.map(&method(:replace_path_prefix).curry[Dir.pwd, ''])
end
|
.strip_home_backtrace(backtrace) ⇒ Object
29
30
31
|
# File 'lib/rib/core/strip_backtrace.rb', line 29
def strip_home_backtrace backtrace
backtrace.map(&method(:replace_path_prefix).curry[ENV['HOME'], '~/'])
end
|
.strip_rib_backtrace(backtrace) ⇒ Object
37
38
39
40
|
# File 'lib/rib/core/strip_backtrace.rb', line 37
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}", format_backtrace(err.backtrace)]
end
|