pretty_debug 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pretty_debug.rb +18 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51103fc126497b1d9c41ee408db9dff752a4ec2b
|
4
|
+
data.tar.gz: edf7ffac17899f563307fe54383d50954bb6d7b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 835c7e7c4209ee1851eac0a18ef04c11a2375051353bab015d3995536d3747402e7f292e438c970588cd8f842b540999b5841f44511dc8206a5c449b41ad73ca
|
7
|
+
data.tar.gz: d20a4b0fdf35811c190c3ecbe44448f9031b8de226add2f203e4d95c33ffb3033b4893193e9616d146d94c652fbebee8267a6e4c0fd33495b6f19cd1712fb25c
|
data/lib/pretty_debug.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!ruby
|
2
2
|
require "string"
|
3
3
|
require "ruby-prof"
|
4
|
+
require "utility"
|
4
5
|
|
5
6
|
module Kernel
|
6
7
|
at_exit do
|
@@ -8,7 +9,7 @@ module Kernel
|
|
8
9
|
when nil, SystemExit, Interrupt
|
9
10
|
else
|
10
11
|
puts PrettyDebug.message
|
11
|
-
puts PrettyDebug.clean($@).align(":")
|
12
|
+
puts PrettyDebug.clean($@).align.map{|row| row.join(":")}
|
12
13
|
end
|
13
14
|
$stderr.reopen(IO::NULL)
|
14
15
|
$stdout.reopen(IO::NULL)
|
@@ -147,16 +148,26 @@ class Array
|
|
147
148
|
map(&:inspect)
|
148
149
|
.chain{|s| length < 2 ? "[#{s.join}]" : "[#$/#{s.join(",#$/").indent}#$/]"}
|
149
150
|
end
|
150
|
-
def align
|
151
|
+
def align ellipsis_limit = nil
|
152
|
+
transpose
|
153
|
+
.map do |col|
|
154
|
+
just = case col.first; when Numeric then :rjust; else :ljust end
|
155
|
+
width = col.map{|cell| cell.to_s.length}.max
|
156
|
+
max = ellipsis_limit || width
|
157
|
+
col.map{|cell| cell.to_s.ellipsis(max).send(just, width.at_most(max))}
|
158
|
+
end
|
159
|
+
.transpose
|
160
|
+
=begin
|
151
161
|
col_widths = transpose.map{|col| col.map{|cell| cell.to_s.length}.max}
|
152
|
-
map{|row| [row, col_widths].transpose.map{|
|
162
|
+
map{|row| [row, col_widths].transpose.map{|cell, l|
|
153
163
|
max = ellipsis_limit || l
|
154
164
|
l = l.at_most(max)
|
155
|
-
case
|
156
|
-
when Numeric then
|
157
|
-
else
|
165
|
+
case cell
|
166
|
+
when Numeric then cell.to_s.ellipsis(max).rjust(l)
|
167
|
+
else cell.to_s.ellipsis(max).ljust(l)
|
158
168
|
end
|
159
169
|
}.join(sep)}
|
170
|
+
=end
|
160
171
|
end
|
161
172
|
end
|
162
173
|
|
@@ -191,7 +202,7 @@ module Test
|
|
191
202
|
end
|
192
203
|
rescue Exception
|
193
204
|
puts "#{title} ... Test Error".color(:red),
|
194
|
-
[$!.message, *PrettyDebug.clean($@).align(":")].map{|l| l.color(:red)}
|
205
|
+
[$!.message, *PrettyDebug.clean($@).align.map{|row| row.join(":")}].map{|l| l.color(:red)}
|
195
206
|
end
|
196
207
|
end
|
197
208
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pretty_debug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email: []
|