pretty_backtrace 0.0.1 → 0.0.2

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: 3572b7c273aed0de085880965919d39ff5f695a9
4
- data.tar.gz: 32482304d2e4fb3b662b0ea4b7831d156fe4f317
3
+ metadata.gz: 3971218f377ecdef54fa8b356ccc3c02ac4335cb
4
+ data.tar.gz: 04f0c5fa5a805cbbb23292f6068af5a3ca6a4b28
5
5
  SHA512:
6
- metadata.gz: 978793b5cabdf4f7272dfc058fef5a496c920dda00b5071bee94216bd85596da4080cac020bf3b615f1b02c9b3cc8cfc11f126601fd0d164dbd42ceb77aea3dc
7
- data.tar.gz: d1a1c7c98bbe2c7a6d259ed3087ce1a97f7cca53d92e22f615e2cdcc6f18044e4d2a7e01f72f562a128684c6814e3f584a9d23633f5d1529ef134f8816b394f5
6
+ metadata.gz: 66899e9934ad1a5e2cd125483146a6e33b7702e632f4aa7aeeb34e25ec91b16081f1bb9bfe68e738ca710e022f782ced1de6100deb89b0053c5930ce3f8b1148
7
+ data.tar.gz: 315156aab1dc90a8c2438550c058df9b990c5bb79b6f60e556d393470651076ac35c0be4e53f800ba41a0f9b6f93e25b980385a38d8dec744c51d321295d10ac
data/README.md CHANGED
@@ -27,7 +27,7 @@ require 'pretty_backtrace'
27
27
  PrettyBacktrace.enable
28
28
 
29
29
  def recursive n
30
- str = "Hi #{n}!!" * 128
30
+ str = "Hi #{n}!! " * 128
31
31
  if n > 0
32
32
  recursive n - 1
33
33
  else
@@ -41,17 +41,47 @@ recursive 3
41
41
  and you can see prettier backtrace (you can see local variable names and values).
42
42
 
43
43
  ```
44
- test.rb:10:in `recursive' (n = 0, str = "Hi 0!!Hi 0!!Hi 0!!Hi...): bottom of recursive (RuntimeError)
45
- from test.rb:8:in `recursive' (n = 1, str = "Hi 1!!Hi 1!!Hi 1!!Hi...)
46
- from test.rb:8:in `recursive' (n = 2, str = "Hi 2!!Hi 2!!Hi 2!!Hi...)
47
- from test.rb:8:in `recursive' (n = 3, str = "Hi 3!!Hi 3!!Hi 3!!Hi...)
48
- from test.rb:14:in `<main>'
44
+ test.rb:10:in `recursive' (n = 0, str = "Hi 0!! Hi 0!! Hi 0...): bottom of recursive (RuntimeError)
45
+ from test.rb:9:in `recursive' (n = 1, str = "Hi 1!! Hi 1!! Hi 1...)
46
+ from test.rb:9:in `recursive' (n = 2, str = "Hi 2!! Hi 2!! Hi 2...)
47
+ from test.rb:9:in `recursive' (n = 3, str = "Hi 3!! Hi 3!! Hi 3...)
48
+ from test.rb:15:in `<main>'
49
49
  ```
50
50
 
51
51
  You only need to require "pretty_backtrace/enable" to eliminate "PrettyBacktrace.enable call".
52
52
 
53
53
  PrettyBacktrace::CONFIG can change behaviour. See source code files for details.
54
54
 
55
+ ### Multi-line mode
56
+
57
+ You can use multi-line mode with the following configuration.
58
+
59
+ ```ruby
60
+ PrettyBacktrace::CONFIG[:multi_line] = true
61
+ ```
62
+
63
+ Multi-line mode enable to show all variables (and pointing values) in each lines like that:
64
+
65
+ ```
66
+ test.rb:11:in `recursive'
67
+ n = 0
68
+ str = "Hi 0!! Hi 0!! Hi 0!! Hi 0!! Hi 0!! Hi 0!! Hi 0!! Hi 0...
69
+ : bottom of recursive (RuntimeError)
70
+ from test.rb:9:in `recursive'
71
+ n = 1
72
+ str = "Hi 1!! Hi 1!! Hi 1!! Hi 1!! Hi 1!! Hi 1!! Hi 1!! Hi 1...
73
+
74
+ from test.rb:9:in `recursive'
75
+ n = 2
76
+ str = "Hi 2!! Hi 2!! Hi 2!! Hi 2!! Hi 2!! Hi 2!! Hi 2!! Hi 2...
77
+
78
+ from test.rb:9:in `recursive'
79
+ n = 3
80
+ str = "Hi 3!! Hi 3!! Hi 3!! Hi 3!! Hi 3!! Hi 3!! Hi 3!! Hi 3...
81
+
82
+ from test.rb:15:in `<main>'
83
+ ```
84
+
55
85
  ## Contributing
56
86
 
57
87
  There are no spec tests. I love to get your contributions!
@@ -5,6 +5,9 @@ module PrettyBacktrace
5
5
  CONFIG = {
6
6
  truncate_length: 20,
7
7
  disabled_exception_classes: {},
8
+ multi_line: false,
9
+ multi_line_truncate_length: 60,
10
+ multi_line_indent: 10,
8
11
  }
9
12
 
10
13
  EXCEPTION_MODIFIER_TRACE = TracePoint.new(:raise){|tp|
@@ -77,11 +80,19 @@ module PrettyBacktrace
77
80
  trace_line = backtrace_location.to_s
78
81
 
79
82
  unless local_variables_values.empty?
80
- additional = local_variables_values.map{|lv, v|
81
- v = v[0..CONFIG[:truncate_length]] + '...' if v.length > CONFIG[:truncate_length]
82
- "#{lv} = #{v.to_s}"
83
- }.join(", ")
84
- trace_line = "#{trace_line} (#{additional})"
83
+ if CONFIG[:multi_line]
84
+ additional = local_variables_values.map{|lv, v|
85
+ v = v[0..CONFIG[:multi_line_truncate_length]] + '...' if v.length > CONFIG[:multi_line_truncate_length]
86
+ ' ' * CONFIG[:multi_line_indent] + "#{lv} = #{v.to_s}"
87
+ }.join("\n") + "\n"
88
+ trace_line = "#{trace_line}\n#{additional}"
89
+ else
90
+ additional = local_variables_values.map{|lv, v|
91
+ v = v[0..CONFIG[:truncate_length]] + '...' if v.length > CONFIG[:truncate_length]
92
+ "#{lv} = #{v.to_s}"
93
+ }.join(", ")
94
+ trace_line = "#{trace_line} (#{additional})"
95
+ end
85
96
  end
86
97
 
87
98
  trace_line
@@ -1,3 +1,3 @@
1
1
  module PrettyBacktrace
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/test.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  $: << './lib'
2
2
  require 'pretty_backtrace/enable'
3
3
 
4
+ # PrettyBacktrace::CONFIG[:multi_line] = true
5
+
4
6
  def recursive n
5
- str = "Hi #{n}!!" * 128
7
+ str = "Hi #{n}!! " * 128
6
8
  if n > 0
7
9
  recursive n - 1
8
10
  else
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.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Sasada