pretty_trace 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -2
- data/lib/pretty_trace/enable-trim.rb +3 -0
- data/lib/pretty_trace/formatter.rb +11 -0
- data/lib/pretty_trace/handler.rb +1 -1
- data/lib/pretty_trace/module_methods.rb +8 -0
- data/lib/pretty_trace/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01f4109d20baa996682e6f71ce0ea1b03d7d95ac
|
4
|
+
data.tar.gz: ecb6f5346c533dc4915df2abe151c098423627da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a4c2476428a4a7e4a29d6fcc183c0159fe5b51aed461a15a207394b6fac1cad2124a648be183e24fb4dd819272c7a8cd988e3ae63d945cc943a8d2cc10e88b4
|
7
|
+
data.tar.gz: cb7c2888add66b808803af25b5b52c5ee37e51a87149df709757c5e90c56e204c302c64cea6a55ee18d1cb334e6802c417c04446f0a758b962954aaa0f08b979
|
data/README.md
CHANGED
@@ -23,7 +23,14 @@ $ gem install pretty_trace
|
|
23
23
|
Or with bundler:
|
24
24
|
|
25
25
|
```
|
26
|
+
# Just install, do not activate
|
27
|
+
$ gem 'pretty_trace'
|
28
|
+
|
29
|
+
# Install and enable
|
26
30
|
$ gem 'pretty_trace', require: 'pretty_trace/enable'
|
31
|
+
|
32
|
+
# Install, enable and enable trimming
|
33
|
+
$ gem 'pretty_trace', require: 'pretty_trace/enable-trim'
|
27
34
|
```
|
28
35
|
|
29
36
|
Example
|
@@ -55,8 +62,15 @@ require 'pretty_trace/enable'
|
|
55
62
|
|
56
63
|
From this point on, any exception will be formatted.
|
57
64
|
|
58
|
-
If you
|
59
|
-
|
65
|
+
If you wish to show a trimmed version of the backtrace (only the first and
|
66
|
+
last line), require this script instead:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
require 'pretty_trace/enable-trim'
|
70
|
+
```
|
71
|
+
|
72
|
+
If you prefer to have more control,you can use configure these settings
|
73
|
+
manually:
|
60
74
|
|
61
75
|
```ruby
|
62
76
|
require 'pretty_trace'
|
@@ -70,6 +84,14 @@ PrettyTrace.enable
|
|
70
84
|
PrettyTrace.disable
|
71
85
|
|
72
86
|
# Exceptions here will not be formatted
|
87
|
+
|
88
|
+
PrettyTrace.trim
|
89
|
+
|
90
|
+
# Exceptions here will be trimmed
|
91
|
+
|
92
|
+
PrettyTrace.no_trim
|
93
|
+
|
94
|
+
# Exceptions here will not be trimmed
|
73
95
|
```
|
74
96
|
|
75
97
|
|
@@ -95,3 +117,11 @@ to see the full trace paths), you can set the environment variable
|
|
95
117
|
```
|
96
118
|
$ PRETTY_TRACE=off ruby myscript.rb
|
97
119
|
```
|
120
|
+
|
121
|
+
If you wish to temporarily disable trimming, you can set the environment
|
122
|
+
variable `PRETTY_TRACE=full` before running your script:
|
123
|
+
|
124
|
+
```
|
125
|
+
$ PRETTY_TRACE=full ruby myscript.rb
|
126
|
+
```
|
127
|
+
|
@@ -8,6 +8,8 @@ module PrettyTrace
|
|
8
8
|
backtrace.reject! { |trace| trace =~ expression }
|
9
9
|
end
|
10
10
|
|
11
|
+
backtrace = trim backtrace if should_trim? backtrace
|
12
|
+
|
11
13
|
backtrace.map! do |item|
|
12
14
|
if item =~ /(.+):(-?\d+):in `(.+)'/
|
13
15
|
file, line, method = $1, $2, $3
|
@@ -36,5 +38,14 @@ module PrettyTrace
|
|
36
38
|
white: "\e[37m",
|
37
39
|
}
|
38
40
|
end
|
41
|
+
|
42
|
+
def self.trim(backtrace)
|
43
|
+
[backtrace[0], '...... (trimmed)', backtrace[-1]]
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.should_trim?(backtrace)
|
47
|
+
ENV['PRETTY_TRACE_TRIM'] and ENV['PRETTY_TRACE'] != 'full' and
|
48
|
+
backtrace.size > 3
|
49
|
+
end
|
39
50
|
end
|
40
51
|
end
|
data/lib/pretty_trace/handler.rb
CHANGED
data/lib/pretty_trace/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pretty_trace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: runfile
|
@@ -88,6 +88,7 @@ extra_rdoc_files: []
|
|
88
88
|
files:
|
89
89
|
- README.md
|
90
90
|
- lib/pretty_trace.rb
|
91
|
+
- lib/pretty_trace/enable-trim.rb
|
91
92
|
- lib/pretty_trace/enable.rb
|
92
93
|
- lib/pretty_trace/formatter.rb
|
93
94
|
- lib/pretty_trace/handler.rb
|