trace_tree 0.3.2 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5faac3e419aae49a1d520caabd21eca4b4569b60bed6be5f29d69b26561781e6
4
- data.tar.gz: 95441a432f9fdd29d4cd3ffa50ae468fec4764ccada641d0cdd25e6db5564da0
3
+ metadata.gz: cc09963c20ff9fa2325a140cdba7f52a365a86e6345c91c0b73ed7e84954da88
4
+ data.tar.gz: b4fc0967633be32701de2ae30fffe7c5d96d010a061f3885cda766ea893db261
5
5
  SHA512:
6
- metadata.gz: 510554091628f1449c479cb0a218a9875e446fb6414cb53d101390c6bff35490deb409979e73e8eddeb7edbffd56e6682ca3c96cfd60fab7ede0a7d0a9c27abb
7
- data.tar.gz: 516bf6a7a61ddc1c2487261fd2b24aaf58fa105a6b914bd87ab3ae95771d9e70a5f854c72fb1c634a850631e350bc377bf25df7cd617100b2dc30e080b43f8f9
6
+ metadata.gz: 39a369877af219019c3bdf138733c265a69f20af06661c3c84fcc529b78e75e9e3007eac211755cbecd1c79eab33bfa2c32ec5d84cddc1f9c2d6d283c928b5eb
7
+ data.tar.gz: 7ecbd1ecc5e2ecc2fafadefa02a41482bbed8e44790fc6f41b6aa1ba72e01b9e79f8e75141824ff4a99d52d6c7168fe8918898b9626f87031912c065389f6eb5
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  *.swp
11
11
  *.gem
12
+ .tool-versions
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
- * `transcode => false` by default. Set it true to convert unknown character into `"?"` when you see `Encoding::UndefinedConversionError`.
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 press `f`/`u` to fold/unfold it's callee, press `p`/`n` to jump to it's previous/next sibling call, press `r` to print return value in console.
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
 
@@ -3,10 +3,5 @@ require 'yaml'
3
3
  class TraceTree
4
4
  GemPaths = {}
5
5
 
6
- ::YAML.load(`gem env`.gsub(/=>/, ':'))["RubyGems Environment"].
7
- select{|h| h.has_key?("GEM PATHS")}[0].
8
- values[0].
9
- each_with_index do |path, i|
10
- GemPaths["GemPath#{i}"] = path
11
- end
6
+ ::Gem.path.each_with_index { |path, i| GemPaths["GemPath#{i}"] = path }
12
7
  end
@@ -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 = '&lt;'
11
+ GT_RAW= />/
12
+ GT_ESC = '&gt;'
13
+ COL_RAW = '|'
14
+ COL_ESC = '&#124;'
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
@@ -1,3 +1,3 @@
1
1
  class TraceTree
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.4"
3
3
  end
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
@@ -46,7 +46,8 @@ class TraceTree
46
46
  enhance_point
47
47
  @build_command = (opt[:html] || opt[:htmp]) ? :tree_html_full : :tree_graph
48
48
  make_filter
49
- @__file__, @__line__, there = bi.eval('[__FILE__, __LINE__, self]')
49
+ @__file__, @__line__ = bi.source_location
50
+ there = bi.eval('self')
50
51
 
51
52
  dry_run
52
53
 
@@ -114,7 +115,7 @@ class TraceTree
114
115
  end
115
116
 
116
117
  def table_of_points
117
- Terminal::Table.from_hashes trace_points_array.map(&:to_h)
118
+ PointsMarkdownTable.new(trace_points_array)
118
119
  rescue => e
119
120
  log.puts "#{__method__}", e.inspect, e.backtrace
120
121
  end
data/trace_tree.gemspec CHANGED
@@ -25,9 +25,8 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "minitest", "~> 5.0"
26
26
  spec.add_development_dependency "pry"
27
27
 
28
- spec.add_dependency "binding_of_callers", "~> 0.2.0"
29
- spec.add_dependency "tree_graph", "~> 0.2.0"
30
- spec.add_dependency "tree_html", "~> 0.1.7"
31
- spec.add_dependency "terminal-tableofhashes", "~> 0.1.0"
28
+ spec.add_dependency "binding_of_callers", "~> 0.2.3"
29
+ spec.add_dependency "tree_graph", "~> 0.2.4"
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.2
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: 2021-05-29 00:00:00.000000000 Z
11
+ date: 2022-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,56 +72,42 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.2.0
75
+ version: 0.2.3
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.2.0
82
+ version: 0.2.3
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: tree_graph
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.2.0
89
+ version: 0.2.4
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.2.0
96
+ version: 0.2.4
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: tree_html
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.1.7
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.7
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
@@ -190,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
177
  - !ruby/object:Gem::Version
191
178
  version: '0'
192
179
  requirements: []
193
- rubygems_version: 3.2.3
180
+ rubygems_version: 3.1.6
194
181
  signing_key:
195
182
  specification_version: 4
196
183
  summary: Print TracePoint(:b_call, :b_return, :c_call, :c_return, :call, :return,