pretty_backtrace 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pretty_backtrace.rb +32 -32
- data/lib/pretty_backtrace/version.rb +1 -1
- data/test.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 901594325c18d407574d514765134a0156cd98dd
|
4
|
+
data.tar.gz: d73af85e93635f5f91a7f485a9ee7ba59a379a2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53d0b2c71b720dbdc070bd855e8cd17c12e52a337c557565b73cc028ecdc71f20d79d2385f277f453b5812ca1f0ae807e1ec46e3f03c2a78a814d29ccbbc08cd
|
7
|
+
data.tar.gz: 2e32d8f6aa0d850739c4912bbd333e4c00ab8194ea5d1d0367e59cf84118aecc1baf96f40d4aaa0b1f25d1610430c145ec06b1de7521372df55f09c6a9440460
|
data/lib/pretty_backtrace.rb
CHANGED
@@ -68,38 +68,38 @@ module PrettyBacktrace
|
|
68
68
|
def self.modify_trace_line backtrace_location, absolute_path, lineno, local_variables_values
|
69
69
|
trace_line = backtrace_location.to_s
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
71
|
+
if CONFIG[:multi_line]
|
72
|
+
indent = ' ' * CONFIG[:multi_line_indent]
|
73
|
+
additional = ''
|
74
|
+
|
75
|
+
# file scope
|
76
|
+
if CONFIG[:file_contents] && File.exists?(absolute_path)
|
77
|
+
fclines = CONFIG[:file_contents_lines]
|
78
|
+
start_line = lineno - 1 - 1 * fclines
|
79
|
+
start_line = 0 if start_line < 0
|
80
|
+
|
81
|
+
additional << indent + "[FILE]\n"
|
82
|
+
additional << open(absolute_path){|f| f.readlines[start_line, 1 + 2 * fclines]}.map.with_index{|line, i|
|
83
|
+
ln = start_line + i + 1
|
84
|
+
line = line.chomp
|
85
|
+
'%s%4d|%s' % [ln == lineno ? indent[0..-3] + "->" : indent, ln, line]
|
86
|
+
}.join("\n")
|
87
|
+
additional << "\n"
|
88
|
+
additional << "\n"
|
89
|
+
end
|
90
|
+
|
91
|
+
# local variables
|
92
|
+
unless local_variables_values.empty?
|
93
|
+
additional << indent + "[LOCAL VARIABLES]\n"
|
94
|
+
additional << local_variables_values.map{|lv, v|
|
95
|
+
v = v[0..CONFIG[:multi_line_truncate_length]] + '...' if v.length > CONFIG[:multi_line_truncate_length]
|
96
|
+
indent + " #{lv} = #{v.to_s}"
|
97
|
+
}.join("\n") + "\n"
|
98
|
+
end
|
99
|
+
|
100
|
+
trace_line = "#{trace_line}\n#{additional}" unless additional.empty?
|
101
|
+
else
|
102
|
+
unless local_variables_values.empty?
|
103
103
|
additional = local_variables_values.map{|lv, v|
|
104
104
|
v = v[0..CONFIG[:truncate_length]] + '...' if v.length > CONFIG[:truncate_length]
|
105
105
|
"#{lv} = #{v.to_s}"
|
data/test.rb
CHANGED
@@ -3,6 +3,15 @@ require 'pretty_backtrace/enable'
|
|
3
3
|
|
4
4
|
PrettyBacktrace.multi_line = true
|
5
5
|
|
6
|
+
1.times{
|
7
|
+
1.times{
|
8
|
+
raise
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
|
13
|
+
__END__
|
14
|
+
|
6
15
|
def recursive n
|
7
16
|
str = "Hi #{n}!! " * 128
|
8
17
|
if n > 0
|
@@ -12,4 +21,6 @@ def recursive n
|
|
12
21
|
end
|
13
22
|
end
|
14
23
|
|
24
|
+
3.times{
|
15
25
|
recursive 3
|
26
|
+
}
|