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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19a8c64399c2b093fa2ac3a14550b07def30fe4a
4
- data.tar.gz: cfd978435567433f61bb149594b1b519104cdba2
3
+ metadata.gz: 901594325c18d407574d514765134a0156cd98dd
4
+ data.tar.gz: d73af85e93635f5f91a7f485a9ee7ba59a379a2e
5
5
  SHA512:
6
- metadata.gz: b67be67115eea63f4e58a5d5222c7ad4fdf0579a576485459ed0b3f6a20443c825c8bf944ccd1fee93bd2e370b29dd7bcc54011c75f277c617308bd040ab3a01
7
- data.tar.gz: 37f4d2e3d9037dd8284554015a5a8b3d07d86d23179490bffa2052f73bfb2e08d4a8ef1caf915810cf2f2d66ce6ee1e2da66eeb702aacbcbb331398d1d6e4af1
6
+ metadata.gz: 53d0b2c71b720dbdc070bd855e8cd17c12e52a337c557565b73cc028ecdc71f20d79d2385f277f453b5812ca1f0ae807e1ec46e3f03c2a78a814d29ccbbc08cd
7
+ data.tar.gz: 2e32d8f6aa0d850739c4912bbd333e4c00ab8194ea5d1d0367e59cf84118aecc1baf96f40d4aaa0b1f25d1610430c145ec06b1de7521372df55f09c6a9440460
@@ -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
- unless local_variables_values.empty?
72
- if CONFIG[:multi_line]
73
- indent = ' ' * CONFIG[:multi_line_indent]
74
- additional = ''
75
-
76
- # file scope
77
- if CONFIG[:file_contents] && File.exists?(absolute_path)
78
- fclines = CONFIG[:file_contents_lines]
79
- start_line = lineno - 1 - 1 * fclines
80
- start_line = 0 if start_line < 0
81
-
82
- additional << indent + "[FILE]\n"
83
- additional << open(absolute_path){|f| f.readlines[start_line, 1 + 2 * fclines]}.map.with_index{|line, i|
84
- ln = start_line + i + 1
85
- line = line.chomp
86
- '%s%4d|%s' % [ln == lineno ? indent[0..-3] + "->" : indent, ln, line]
87
- }.join("\n")
88
- additional << "\n"
89
- additional << "\n"
90
- end
91
-
92
- # local variables
93
- unless local_variables_values.empty?
94
- additional << indent + "[LOCAL VARIABLES]\n"
95
- additional << local_variables_values.map{|lv, v|
96
- v = v[0..CONFIG[:multi_line_truncate_length]] + '...' if v.length > CONFIG[:multi_line_truncate_length]
97
- indent + " #{lv} = #{v.to_s}"
98
- }.join("\n") + "\n"
99
- end
100
-
101
- trace_line = "#{trace_line}\n#{additional}" unless additional.empty?
102
- else
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}"
@@ -1,3 +1,3 @@
1
1
  module PrettyBacktrace
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretty_backtrace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Sasada