trace_tree 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -2
- data/lib/trace_tree/points_markdown_table.rb +60 -0
- data/lib/trace_tree/version.rb +1 -1
- data/lib/trace_tree.rb +2 -2
- data/trace_tree.gemspec +1 -2
- metadata +5 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc09963c20ff9fa2325a140cdba7f52a365a86e6345c91c0b73ed7e84954da88
|
4
|
+
data.tar.gz: b4fc0967633be32701de2ae30fffe7c5d96d010a061f3885cda766ea893db261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39a369877af219019c3bdf138733c265a69f20af06661c3c84fcc529b78e75e9e3007eac211755cbecd1c79eab33bfa2c32ec5d84cddc1f9c2d6d283c928b5eb
|
7
|
+
data.tar.gz: 7ecbd1ecc5e2ecc2fafadefa02a41482bbed8e44790fc6f41b6aa1ba72e01b9e79f8e75141824ff4a99d52d6c7168fe8918898b9626f87031912c065389f6eb5
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ end
|
|
58
58
|
* `:warm => nil` by default. Set it something unique to the code block so that the code block will be traced only when it's called second time, in case we dump lots of code loading and initialization.
|
59
59
|
* `:timer => nil` by default. Set it true if you want to know how much time spent in tracing and drawing tree. Notice the `file` should be appendable, otherwise the time will overwrite the tree.
|
60
60
|
* `:debug => nil` by default. Give it `STDOUT`/`STDERR` or anything responds to `:puts` to output a whole list of TracePoints. Or give it a file name in the default tmp dir of your system.
|
61
|
-
*
|
61
|
+
* `:transcode => false` by default. Set it true to convert unknown character into `"?"` when you see `Encoding::UndefinedConversionError`.
|
62
62
|
|
63
63
|
### Methods' return values
|
64
64
|
|
@@ -78,7 +78,12 @@ Try to remove a non-existing index:
|
|
78
78
|
ArgumentError: Index name 'index_cars_on_online_at' on table 'cars' does not exist
|
79
79
|
```
|
80
80
|
|
81
|
-
Then find the result HTML in tmp dir. Move your mouse on any method name, and
|
81
|
+
Then find the result HTML in tmp dir. Move your mouse on any method name, and:
|
82
|
+
|
83
|
+
- press `f`/`u` to fold/unfold it's callee
|
84
|
+
- press `p`/`n` to jump to it's previous/next sibling call
|
85
|
+
- press `r` to print return value in console
|
86
|
+
- press `a` to print ascii tree in console
|
82
87
|
|
83
88
|
You may type `group_by_file()` in console, to group callees defined in same file, under additional `li` tag. Type `group_by_file()` once again to switch back.
|
84
89
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class TraceTree
|
2
|
+
class PointsMarkdownTable
|
3
|
+
HEADERS = [:event, :defined_class, :method_id, :frame_env, :path, :lineno, :thread, :return_value]
|
4
|
+
COL_SEPERATOR = '|'
|
5
|
+
HEADER_BOTTOM = '-'
|
6
|
+
NEWLINE = "\n"
|
7
|
+
RETURN = /return/
|
8
|
+
|
9
|
+
LT_RAW = /</
|
10
|
+
LT_ESC = '<'
|
11
|
+
GT_RAW= />/
|
12
|
+
GT_ESC = '>'
|
13
|
+
COL_RAW = '|'
|
14
|
+
COL_ESC = '|'
|
15
|
+
|
16
|
+
def initialize(points)
|
17
|
+
@points = points
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
@buffer = []
|
22
|
+
generate_headers
|
23
|
+
generate_rows
|
24
|
+
@buffer.join
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_headers
|
28
|
+
HEADERS.each{ |h| @buffer << COL_SEPERATOR << h }
|
29
|
+
@buffer << COL_SEPERATOR
|
30
|
+
@buffer << NEWLINE
|
31
|
+
HEADERS.each{ |h| @buffer << COL_SEPERATOR << HEADER_BOTTOM }
|
32
|
+
end_row
|
33
|
+
end
|
34
|
+
|
35
|
+
def generate_rows
|
36
|
+
@points.each do |point|
|
37
|
+
point_to_row(point.event)
|
38
|
+
point_to_row(point.defined_class)
|
39
|
+
point_to_row(point.method_id)
|
40
|
+
point_to_row(point.thread? ? nil : point.frame_env)
|
41
|
+
point_to_row(point.path)
|
42
|
+
point_to_row(point.lineno)
|
43
|
+
point_to_row(point.thread)
|
44
|
+
point_to_row(point.event =~ RETURN ? point.return_value : nil)
|
45
|
+
end_row
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def end_row
|
50
|
+
@buffer << COL_SEPERATOR << NEWLINE
|
51
|
+
end
|
52
|
+
|
53
|
+
def point_to_row(info)
|
54
|
+
info = info.to_s.gsub(LT_RAW, LT_ESC)
|
55
|
+
info.gsub!(GT_RAW, GT_ESC)
|
56
|
+
info.gsub!(COL_RAW, COL_ESC)
|
57
|
+
@buffer << COL_SEPERATOR << info
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/trace_tree/version.rb
CHANGED
data/lib/trace_tree.rb
CHANGED
@@ -9,8 +9,8 @@ require 'trace_tree/tmp_file'
|
|
9
9
|
require 'trace_tree/timer'
|
10
10
|
require 'trace_tree/config'
|
11
11
|
require 'trace_tree/warm'
|
12
|
+
require 'trace_tree/points_markdown_table'
|
12
13
|
require 'thread'
|
13
|
-
require 'terminal-tableofhashes'
|
14
14
|
|
15
15
|
class Binding
|
16
16
|
def trace_tree *log, **opt, &to_do
|
@@ -115,7 +115,7 @@ class TraceTree
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def table_of_points
|
118
|
-
|
118
|
+
PointsMarkdownTable.new(trace_points_array)
|
119
119
|
rescue => e
|
120
120
|
log.puts "#{__method__}", e.inspect, e.backtrace
|
121
121
|
end
|
data/trace_tree.gemspec
CHANGED
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_dependency "binding_of_callers", "~> 0.2.3"
|
29
29
|
spec.add_dependency "tree_graph", "~> 0.2.4"
|
30
|
-
spec.add_dependency "tree_html", "~> 0.1.
|
31
|
-
spec.add_dependency "terminal-tableofhashes", "~> 0.1.0"
|
30
|
+
spec.add_dependency "tree_html", "~> 0.1.10"
|
32
31
|
|
33
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trace_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,28 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.1.
|
103
|
+
version: 0.1.10
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.1.
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: terminal-tableofhashes
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.1.0
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.1.0
|
110
|
+
version: 0.1.10
|
125
111
|
description:
|
126
112
|
email:
|
127
113
|
- block24block@gmail.com
|
@@ -162,6 +148,7 @@ files:
|
|
162
148
|
- lib/trace_tree/point/omit.rb
|
163
149
|
- lib/trace_tree/point/threadbegin.rb
|
164
150
|
- lib/trace_tree/point/threadend.rb
|
151
|
+
- lib/trace_tree/points_markdown_table.rb
|
165
152
|
- lib/trace_tree/return_value.rb
|
166
153
|
- lib/trace_tree/short_gem_path.rb
|
167
154
|
- lib/trace_tree/timer.rb
|