pretty_debug 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pretty_debug.rb +13 -12
- 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: 586a6a3bbcec2fd560dec4af52d338f2f8276b92
|
4
|
+
data.tar.gz: 29a97950744e70acaf157ea78a7d949d231cd7a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c85006d3881f2b1ae1d4b5c767e64b9fdaa3f1f6426bf6ae64171be88292c5ddf97ce763ba1118dabf6d3e488a9e722f62c7dc3b1af85a01d456ef764ea0f12
|
7
|
+
data.tar.gz: ac303b059e31df106d595778a220477705d86c76bc4a51eb7c6b19fca0b7c3bf661ad1d26bbdd509108531d3ed0c0832c34d6844a69d40bd7f292d52c9ba0094
|
data/lib/pretty_debug.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!ruby
|
2
2
|
require "tmpdir"
|
3
3
|
require "compact_time"
|
4
|
-
require "utility"
|
5
4
|
|
6
5
|
#############################################
|
7
6
|
# File
|
@@ -86,8 +85,8 @@ class Thread::Backtrace::PseudoLocation
|
|
86
85
|
attr_accessor :to_s, :absolute_path, :lineno, :label, :path, :base_label
|
87
86
|
def initialize to_s
|
88
87
|
@to_s = to_s
|
89
|
-
|
90
|
-
@
|
88
|
+
m = @to_s.match(Pattern)
|
89
|
+
@absolute_path, @lineno, @label = m[:f], m[:l] ? m[:l].to_i : nil, m[:m].to_s
|
91
90
|
@path = File.basename(@absolute_path)
|
92
91
|
@base_label = @label
|
93
92
|
end
|
@@ -212,16 +211,16 @@ class UnboundMethod; def inspect; "#{owner}##{name}" end end
|
|
212
211
|
class Array
|
213
212
|
SingleLength = 50
|
214
213
|
def inspect
|
215
|
-
map(&:inspect)
|
216
|
-
|
217
|
-
"[#{s.join(", ".freeze)}]" : "[#$/#{s.join(",#$/".freeze).indent}#$/]"
|
214
|
+
s = map(&:inspect)
|
215
|
+
length < 2 || s.map(&:length).inject(:+) < SingleLength ?
|
216
|
+
"[#{s.join(", ".freeze)}]" : "[#$/#{s.join(",#$/".freeze).indent}#$/]"
|
218
217
|
end
|
219
218
|
def align ellipsis_limit = nil
|
220
219
|
transpose.map do |col|
|
221
220
|
just = case col.first; when Numeric then :rjust; else :ljust end
|
222
221
|
width = col.map{|cell| cell.to_s.length}.max
|
223
222
|
max = ellipsis_limit || width
|
224
|
-
col.map{|cell| cell.to_s.ellipsis(max).__send__(just, width
|
223
|
+
col.map{|cell| cell.to_s.ellipsis(max).__send__(just, width > max ? max : width)}
|
225
224
|
end.transpose
|
226
225
|
end
|
227
226
|
def common_prefix
|
@@ -246,17 +245,19 @@ class Hash
|
|
246
245
|
def inspect
|
247
246
|
keys = self.keys.map(&:inspect)
|
248
247
|
# When `self == empty?`, `...max` becomes `nil`. `to_i` turns it to `0`.
|
249
|
-
w = keys.map(&:length).max.to_i
|
250
|
-
|
251
|
-
|
252
|
-
|
248
|
+
w = keys.map(&:length).max.to_i
|
249
|
+
w = w > KeyLengthMax ? KeyLengthMax : w
|
250
|
+
s = [keys, values].transpose.map{|k, v| "#{k.ljust(w)} => #{v.inspect}"}
|
251
|
+
length < 2 || s.map(&:length).inject(:+) < SingleLength ?
|
252
|
+
"{#{s.join(", ".freeze)}}" : "{#$/#{s.join(",#$/".freeze).indent}#$/}"
|
253
253
|
end
|
254
254
|
end
|
255
255
|
|
256
256
|
class Object
|
257
257
|
def intercept &pr
|
258
|
+
l = caller_location(3)
|
258
259
|
tap do |x| puts \
|
259
|
-
"[Debug] #{
|
260
|
+
"[Debug] #{"#{l.path}:#{l.lineno}"}".color(:yellow),
|
260
261
|
(pr ? pr.call(x) : x).inspect.verbatim.unchomp
|
261
262
|
end
|
262
263
|
end
|
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.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email: []
|