pretty_debug 0.9.13 → 0.9.14
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 +21 -21
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fc7b8fdf2ef02eb5f58e5cf5d4c8b2557f22633
|
4
|
+
data.tar.gz: 3b231cff8da4e3972481aff6e306881bd9197e95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 613356bd0aeede281657efffa09803956aa72988b218794ae69e99b39ebc780c522c207662b67d6efd74332bb0ebf515857c9083a0e79d7a01d632f8dde492b6
|
7
|
+
data.tar.gz: dea874bb01e855ce924b250bc5013c7da3a20d0951f67c92b8a6b17a0e3869ff79a053b72131dc730073c9ee89a05591a9a370b8c3f69358b27d55a8fef0ccb0
|
data/lib/pretty_debug.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!ruby
|
2
|
+
#frozen-string-literal: true
|
2
3
|
|
3
4
|
# File
|
4
5
|
|
@@ -19,7 +20,7 @@ end
|
|
19
20
|
|
20
21
|
class BasicObject
|
21
22
|
def intercept; self ensure
|
22
|
-
::Kernel.puts "[Debug] ?:?".bf.color(:yellow), "#<Basic Object>"
|
23
|
+
::Kernel.puts "[Debug] ?:?".bf.color(:yellow), "#<Basic Object>"
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -36,7 +37,7 @@ class Object
|
|
36
37
|
mt = method(m)
|
37
38
|
puts \
|
38
39
|
"[Debug] #{"#{l.realpath}:#{l.lineno}"}".bf.color(:yellow),
|
39
|
-
"#{self.class}(#{mt.owner})\##{m}@#{mt.source_location.to_a.join(":"
|
40
|
+
"#{self.class}(#{mt.owner})\##{m}@#{mt.source_location.to_a.join(":")}"
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -46,7 +47,7 @@ module Kernel
|
|
46
47
|
when *klass
|
47
48
|
else
|
48
49
|
ArgumentError.raise(
|
49
|
-
"#{yield + " "
|
50
|
+
"#{yield + " " if block_given?}should be #{klass.map(&:expand).join(", ")} instance "\
|
50
51
|
"but is #{v.expand}")
|
51
52
|
end
|
52
53
|
end
|
@@ -76,7 +77,7 @@ class Thread::Backtrace::PseudoLocation
|
|
76
77
|
def basename; File.basename(absolute_path) end
|
77
78
|
def realpath
|
78
79
|
case absolute_path
|
79
|
-
when "-e"
|
80
|
+
when "-e", "(eval)" then absolute_path
|
80
81
|
else File.realpath(absolute_path)
|
81
82
|
end
|
82
83
|
end
|
@@ -90,7 +91,7 @@ class Thread::Backtrace::Location
|
|
90
91
|
def basename; File.basename(absolute_path) end
|
91
92
|
def realpath
|
92
93
|
case absolute_path
|
93
|
-
when "-e"
|
94
|
+
when "-e", "(eval)" then absolute_path
|
94
95
|
else File.realpath(absolute_path)
|
95
96
|
end
|
96
97
|
end
|
@@ -132,7 +133,7 @@ class PrettyDebug
|
|
132
133
|
def self.format ≺ @format = pr end
|
133
134
|
def self.message e
|
134
135
|
e.complement_backtrace_locations
|
135
|
-
e.message.to_s.sub(/./, &:upcase).sub(/(?<=[^.])\z/, "."
|
136
|
+
e.message.to_s.sub(/./, &:upcase).sub(/(?<=[^.])\z/, ".").tr("'", "`")
|
136
137
|
end
|
137
138
|
def self.backtrace_locations e
|
138
139
|
e.complement_backtrace_locations
|
@@ -174,18 +175,18 @@ class PrettyDebug
|
|
174
175
|
|m|
|
175
176
|
case m
|
176
177
|
when *Hook then "(#{m})"
|
177
|
-
when /\A(rescue in )?block( .*)? in / then "(entered block)"
|
178
|
-
when /\Arescue in / then ""
|
178
|
+
when /\A(rescue in )?block( .*)? in / then "(entered block)"
|
179
|
+
when /\Arescue in / then ""
|
179
180
|
else m
|
180
181
|
end
|
181
182
|
end
|
182
|
-
ms[-1] = ""
|
183
|
+
ms[-1] = ""; ms.rotate!(-1)
|
183
184
|
end.transpose
|
184
185
|
end
|
185
186
|
end
|
186
187
|
|
187
188
|
PrettyDebug.select{|f, m| true}
|
188
|
-
PrettyDebug.format{|row| "#{row.join(" | "
|
189
|
+
PrettyDebug.format{|row| "#{row.join(" | ")} ".bg(:white).color(:black)}
|
189
190
|
|
190
191
|
# Inspection
|
191
192
|
|
@@ -208,7 +209,7 @@ end
|
|
208
209
|
|
209
210
|
class Proc
|
210
211
|
def inspect; f, l = source_location; "Proc@#{f}:#{l}"
|
211
|
-
rescue; "Proc@source_unknown"
|
212
|
+
rescue; "Proc@source_unknown"
|
212
213
|
end
|
213
214
|
end
|
214
215
|
|
@@ -218,7 +219,7 @@ class UnboundMethod; def inspect; "#{owner}\##{name}" end end
|
|
218
219
|
|
219
220
|
class BasicObject
|
220
221
|
def recursive? *; false end
|
221
|
-
def inspect; ""
|
222
|
+
def inspect; "" end
|
222
223
|
end
|
223
224
|
|
224
225
|
module Enumerable
|
@@ -244,7 +245,7 @@ class Array
|
|
244
245
|
return super if recursive?
|
245
246
|
s = map(&:inspect)
|
246
247
|
length < 2 || s.map(&:length).inject(:+) < SingleLength ?
|
247
|
-
"[#{s.join(", "
|
248
|
+
"[#{s.join(", ")}]" : "[#$/#{s.join(",#$/").indent}#$/]"
|
248
249
|
end
|
249
250
|
end
|
250
251
|
prepend PrettyInspect
|
@@ -262,7 +263,7 @@ class Hash
|
|
262
263
|
w = w > KeyLengthMax ? KeyLengthMax : w
|
263
264
|
s = [keys, values].transpose.map{|k, v| "#{k.ljust(w)} => #{v.inspect}"}
|
264
265
|
length < 2 || s.map(&:length).inject(:+) < SingleLength ?
|
265
|
-
"{#{s.join(", "
|
266
|
+
"{#{s.join(", ")}}" : "{#$/#{s.join(",#$/").indent}#$/}"
|
266
267
|
end
|
267
268
|
end
|
268
269
|
prepend PrettyInspect
|
@@ -277,16 +278,16 @@ end
|
|
277
278
|
class String
|
278
279
|
def verbatim; bg(:blue) end
|
279
280
|
def terminal_escape; "\"#{self}\"" end
|
280
|
-
def bf; "#{vt100("01"
|
281
|
-
def underline; "#{vt100("04"
|
281
|
+
def bf; "#{vt100("01")}#{self}#{vt100}" end
|
282
|
+
def underline; "#{vt100("04")}#{self}#{vt100}" end
|
282
283
|
def color sym; "#{vt100(30+
|
283
284
|
{black: 0, red: 1, green: 2, yellow: 3, blue: 4, magenta: 5, cyan: 6, white: 7}[sym.to_sym]
|
284
285
|
)}#{self}#{vt100}" end
|
285
286
|
def bg sym; "#{vt100(40+
|
286
287
|
{black: 0, red: 1, green: 2, yellow: 3, blue: 4, magenta: 5, cyan: 6, white: 7}[sym.to_sym]
|
287
288
|
)}#{self}#{vt100}" end
|
288
|
-
def de_vt100; gsub(/\e\[\d*m/, ""
|
289
|
-
private def vt100 s = ""
|
289
|
+
def de_vt100; gsub(/\e\[\d*m/, "") end
|
290
|
+
private def vt100 s = ""; "\e[#{s}m" end
|
290
291
|
end
|
291
292
|
|
292
293
|
# String Formatting
|
@@ -302,7 +303,7 @@ class Array
|
|
302
303
|
end.transpose
|
303
304
|
end
|
304
305
|
def common_prefix
|
305
|
-
each{|e| class_check(String, e){"All elements must be a String"
|
306
|
+
each{|e| class_check(String, e){"All elements must be a String"}}
|
306
307
|
first, *others = self
|
307
308
|
i = 0
|
308
309
|
i += 1 while first[i] and others.all?{|s| first[i] == s[i]}
|
@@ -311,7 +312,7 @@ class Array
|
|
311
312
|
# first[0, (0...first.length).find{|i| first[i].! or others.any?{|s| first[i] != s[i]}}.to_i]
|
312
313
|
end
|
313
314
|
def common_affix
|
314
|
-
each{|e| class_check(String, e){"All elements must be a String"
|
315
|
+
each{|e| class_check(String, e){"All elements must be a String"}}
|
315
316
|
first, *others = self
|
316
317
|
i = - 1
|
317
318
|
i -= 1 while first[i] and others.all?{|s| first[i] == s[i]}
|
@@ -322,7 +323,6 @@ end
|
|
322
323
|
class String
|
323
324
|
@@indent = " "
|
324
325
|
def indent n = 1; gsub(/^/, @@indent * n) end
|
325
|
-
def unindent; gsub(/^#{match(/^\s+/)}/, "".freeze).chomp end
|
326
326
|
def unchomp; sub(/#$/?\z/, $/) end
|
327
327
|
def unchomp!; sub!(/#$/?\z/, $/) end
|
328
328
|
def ellipsis n
|
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.9.
|
4
|
+
version: 0.9.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email: []
|
@@ -36,7 +36,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
36
|
version: '0'
|
37
37
|
requirements: []
|
38
38
|
rubyforge_project:
|
39
|
-
rubygems_version: 2.
|
39
|
+
rubygems_version: 2.5.1
|
40
40
|
signing_key:
|
41
41
|
specification_version: 4
|
42
42
|
summary: ''
|