pretty_debug 0.7.2 → 0.7.3
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 +5 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ba55e5de9b0f5da686b419b9be925467a35d6cf
|
4
|
+
data.tar.gz: 6206f02d3814abe89dfbaa39549c925931c89054
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80c939883ce15d22a8a5f08a96ef9b48cfd0694d9c9f13af1a57112b0abb0a3f5a10222192afb6f8bd18c2712557b159405f7915be1539121cd00ae9c22460e7
|
7
|
+
data.tar.gz: 145e08735761882533b06ffcec1f32a9e6f4486d92522f3f243fd06f66c0e30c8bb9c9cc05c95ef2d4be6394c17acc7a6acbe741907ff62bec0555bbcde3eb6f
|
data/lib/pretty_debug.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
#!ruby
|
2
|
-
require "tmpdir"
|
3
|
-
require "compact_time"
|
4
2
|
|
5
3
|
#############################################
|
6
4
|
# File
|
7
5
|
#############################################
|
8
6
|
|
9
7
|
class File
|
10
|
-
def self.relativize f; f.sub(%r{\A/}, "".freeze) end
|
11
8
|
def self.expand_path_relative f; expand_path(f, caller_location.dirname) end
|
12
9
|
end
|
13
10
|
|
@@ -28,7 +25,7 @@ class Object
|
|
28
25
|
def intercept
|
29
26
|
l = caller_location
|
30
27
|
tap do |x| puts \
|
31
|
-
"[Debug] #{"#{l.path}:#{l.lineno}"}".color(:yellow),
|
28
|
+
"[Debug] #{"#{l.path}:#{l.lineno}"}".bf.color(:yellow),
|
32
29
|
x.inspect.verbatim
|
33
30
|
end
|
34
31
|
end
|
@@ -88,7 +85,7 @@ module Kernel
|
|
88
85
|
when nil, SystemExit, Interrupt
|
89
86
|
else
|
90
87
|
puts \
|
91
|
-
PrettyDebug.message($!).color(:red),
|
88
|
+
PrettyDebug.message($!).bf.color(:red),
|
92
89
|
PrettyDebug.backtrace_locations($!).to_puts
|
93
90
|
end
|
94
91
|
$stderr.reopen(IO::NULL)
|
@@ -106,12 +103,13 @@ class PrettyDebug
|
|
106
103
|
@select = ->(*args){select.call(*args) or pr.call(*args)}
|
107
104
|
end
|
108
105
|
def self.format ≺ @format = pr end
|
106
|
+
def self.message_format ≺ @message_formar = pr end
|
109
107
|
@reject = ->f, m{
|
110
108
|
f == __FILE__ or
|
111
109
|
m =~ /\A<.*>\z/ # Such as `<top (required)>`, `<module:Foo>`.
|
112
110
|
}
|
113
111
|
@select = ->f, m{true}
|
114
|
-
format{|row| "#{row.join(" | ".freeze)} ".bg(:
|
112
|
+
format{|row| "#{row.join(" | ".freeze)} ".bg(:white).color(:black)}
|
115
113
|
def self.message e
|
116
114
|
e.complement_backtrace_locations
|
117
115
|
e.message.dup.tap{|s| s[0] = s[0].upcase unless s.empty?}.sub(/(?<=[^.])\z/, ".".freeze)
|
@@ -212,7 +210,7 @@ class Object
|
|
212
210
|
end
|
213
211
|
|
214
212
|
class String
|
215
|
-
def verbatim; bg(:
|
213
|
+
def verbatim; bg(:blue) end
|
216
214
|
def terminal_escape; "\"#{self}\"" end
|
217
215
|
def bf; "#{vt100("01".freeze)}#{self}#{vt100}" end
|
218
216
|
def underline; "#{vt100("04".freeze)}#{self}#{vt100}" end
|