trace_tree 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3ed16dd1d28ade745f6747ea00c37cb6c2339e2a
4
+ data.tar.gz: f8fea91ae5169fc4459dd4a4940f38d83f151936
5
+ SHA512:
6
+ metadata.gz: 21de039bb2b3f511347ce7bb5e96373f23ba7ae303f7d6ac629c28ebbba506458b9f262ee4b793006c90de9d95b7356278c303dc1afa636e3916873f65399a41
7
+ data.tar.gz: 5d3257a13fce2dfa510141e844241e363ec1ab7ddd319f1040c827d696183b161ec7ecfdeea999af1e018ec492edf339e94162251ab4daf659df0937cf0c6423
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.swp
11
+ *.gem
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at block24block@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trace_tree.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 ken
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,231 @@
1
+ # TraceTree
2
+
3
+ Print TracePoint(normal ruby call, block call, raise call, throw call) in tree graph.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'trace_tree'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install trace_tree
20
+
21
+ ## Usage
22
+
23
+ Just call the method you want to trace in the block passed to `binding.trace_tree`:
24
+
25
+ ```ruby
26
+ things_done = binding.trace_tree do
27
+ somebody.do_something
28
+ end
29
+ ```
30
+
31
+ ### Parameters
32
+
33
+ You may pass optional parameters while invoking `binding.trace_tree`:
34
+
35
+ ```ruby
36
+ binding.trace_tree(file, color: false, gem: false) do
37
+ somebody.do_something
38
+ end
39
+ ```
40
+
41
+ * `file == STDOUT` by default. You can give it a File object or anything responds to `puts`.
42
+ * `:color => true` by default. It makes method names have different color than source_location in output. When you print the output to file, you may want to set it false to discard those color ANSI escape sequences.
43
+ * `:gem => true` by default. Replace the gem paths in source_location with $GemPathN, can make the lines shorter. To see what are replaced, inspect `TraceTree::GemPaths`.
44
+
45
+ ### Example
46
+
47
+ Want to know what `Sinatra::Base#call` does? Wrap it with `binding.trace_tree`:
48
+
49
+ ```ruby
50
+ require 'sinatra'
51
+ require 'trace_tree'
52
+
53
+ get '/' do
54
+ 'wtf'
55
+ end
56
+
57
+ class Sinatra::Base
58
+ alias_method :o_call, :call
59
+
60
+ def call env
61
+ binding.trace_tree do
62
+ o_call env
63
+ end
64
+ end
65
+ end
66
+ ```
67
+
68
+ Execute that sinatra script as normal, then you will see in console:
69
+
70
+ ```
71
+ Sinatra::Application#block in call sin.rb:12
72
+ └─Sinatra::Application#call $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:894
73
+ └─Sinatra::Application#call! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:898
74
+ ├─Sinatra::Request#initialize $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:16
75
+ ├─Sinatra::Response#initialize $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:124
76
+ │ ├─Sinatra::Response#initialize $GemPath0/gems/rack-1.6.5/lib/rack/response.rb:25
77
+ │ │ ├─Rack::Utils::HeaderHash.new $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:489
78
+ │ │ │ └─Rack::Utils::HeaderHash#initialize $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:493
79
+ │ │ ├─Rack::Utils::HeaderHash#merge $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:542
80
+ │ │ │ └─Rack::Utils::HeaderHash#merge! $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:537
81
+ │ │ └─Rack::Utils::HeaderHash#[] $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:511
82
+ │ ├─Rack::Utils::HeaderHash#[] $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:511
83
+ │ └─Rack::Utils::HeaderHash#[]= $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:515
84
+ ├─Sinatra::Request#params $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:229
85
+ │ ├─Sinatra::Request#GET $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:187
86
+ │ │ ├─Sinatra::Request#query_string $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:24
87
+ │ │ ├─Sinatra::Request#query_string $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:24
88
+ │ │ ├─Sinatra::Request#parse_query $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:368
89
+ │ │ │ └─Rack::Utils.parse_nested_query $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:116
90
+ │ │ │ ├─Rack::Utils::KeySpaceConstrainedParams#initialize $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:555
91
+ │ │ │ └─Rack::Utils::KeySpaceConstrainedParams#to_params_hash $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:575
92
+ │ │ └─Sinatra::Request#query_string $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:24
93
+ │ └─Sinatra::Request#POST $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:201
94
+ │ ├─Sinatra::Request#form_data? $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:174
95
+ │ │ └─Sinatra::Request#media_type $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:42
96
+ │ │ └─Sinatra::Request#content_type $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:27
97
+ │ └─Sinatra::Request#parseable_data? $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:182
98
+ │ └─Sinatra::Request#media_type $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:42
99
+ │ └─Sinatra::Request#content_type $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:27
100
+ ├─Sinatra::Application#indifferent_params $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1047
101
+ │ └─Sinatra::Application#indifferent_hash $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1061
102
+ ├─Sinatra::Application#settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:927
103
+ │ └─Sinatra::Application.settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:922
104
+ ├─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1885
105
+ ├─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1885
106
+ │ └─Sinatra::Application.development? $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1404
107
+ │ └─Sinatra::Application.environment (eval):1
108
+ ├─Tilt::Cache#clear $GemPath0/gems/tilt-2.0.6/lib/tilt.rb:109
109
+ ├─Sinatra::Application#force_encoding $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1810
110
+ │ ├─Sinatra::Application#settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:927
111
+ │ │ └─Sinatra::Application.settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:922
112
+ │ └─Sinatra::Application.force_encoding $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1812
113
+ │ └─Sinatra::Application.settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:922
114
+ ├─Sinatra::Response#[]= $GemPath0/gems/rack-1.6.5/lib/rack/response.rb:56
115
+ │ └─Rack::Utils::HeaderHash#[]= $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:515
116
+ ├─Sinatra::Application#invoke $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1066
117
+ │ └─Sinatra::Application#block in invoke $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067
118
+ │ └─Sinatra::Application#block in call! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:907
119
+ │ └─Sinatra::Application#dispatch! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1081
120
+ │ ├─Sinatra::Application#invoke $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1066
121
+ │ │ ├─Sinatra::Application#block in invoke $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067
122
+ │ │ │ └─Sinatra::Application#block in dispatch! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1082
123
+ │ │ │ ├─Sinatra::Application#settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:927
124
+ │ │ │ │ └─Sinatra::Application.settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:922
125
+ │ │ │ ├─Sinatra::Application.static? (eval):1
126
+ │ │ │ │ ├─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1890
127
+ │ │ │ │ └─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1890
128
+ │ │ │ │ ├─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1889
129
+ │ │ │ │ ├─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1889
130
+ │ │ │ │ │ ├─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1883
131
+ │ │ │ │ │ ├─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1883
132
+ │ │ │ │ │ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
133
+ │ │ │ │ │ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
134
+ │ │ │ │ │ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
135
+ │ │ │ │ │ │ └─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
136
+ │ │ │ │ │ ├─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1883
137
+ │ │ │ │ │ └─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1883
138
+ │ │ │ │ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
139
+ │ │ │ │ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
140
+ │ │ │ │ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
141
+ │ │ │ │ │ └─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
142
+ │ │ │ │ ├─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1889
143
+ │ │ │ │ └─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1889
144
+ │ │ │ │ ├─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1883
145
+ │ │ │ │ ├─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1883
146
+ │ │ │ │ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
147
+ │ │ │ │ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
148
+ │ │ │ │ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
149
+ │ │ │ │ │ └─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
150
+ │ │ │ │ ├─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1883
151
+ │ │ │ │ └─Sinatra::Application.block in <class:Base> $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1883
152
+ │ │ │ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
153
+ │ │ │ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
154
+ │ │ │ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
155
+ │ │ │ │ └─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
156
+ │ │ │ ├─Sinatra::Application#filter! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:964
157
+ │ │ │ │ └─Sinatra::Application#filter! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:964
158
+ │ │ │ └─Sinatra::Application#route! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:970
159
+ │ │ │ ├─Sinatra::Request#request_method $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:23
160
+ │ │ │ └─Sinatra::Application#block in route! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:972
161
+ │ │ │ └─Sinatra::Application#process_route $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1002
162
+ │ │ │ ├─Sinatra::Request#path_info $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:22
163
+ │ │ │ └─Sinatra::Application#block in process_route $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1013
164
+ │ │ │ └─Sinatra::Application#block (2 levels) in route! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:973
165
+ │ │ │ └─Sinatra::Application#route_eval $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:993
166
+ │ │ │ ├─Sinatra::Application#block (3 levels) in route! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:975
167
+ │ │ │ │ └─Sinatra::Application.block in compile! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1611
168
+ │ │ │ │ ├─Sinatra::Application#block in <main> sin.rb:4
169
+ │ │ │ │ └─Sinatra::Application#block in <main> sin.rb:4
170
+ │ │ │ └─throw in Sinatra::Application#route_eval $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:994
171
+ │ │ └─Sinatra::Application#body $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:238
172
+ │ │ ├─Sinatra::Request#head? $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:122
173
+ │ │ │ └─Sinatra::Request#request_method $GemPath0/gems/rack-1.6.5/lib/rack/request.rb:23
174
+ │ │ ├─Object#require /home/z/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:39
175
+ │ │ │ ├─Monitor#mon_enter /home/z/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:185
176
+ │ │ │ ├─Gem.find_unresolved_default_spec /home/z/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems.rb:1240
177
+ │ │ │ │ ├─Gem.suffixes /home/z/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems.rb:1003
178
+ │ │ │ │ ├─Gem.block in find_unresolved_default_spec /home/z/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems.rb:1241
179
+ │ │ │ │ ├─Gem.block in find_unresolved_default_spec /home/z/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems.rb:1241
180
+ │ │ │ │ └─Gem.block in find_unresolved_default_spec /home/z/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems.rb:1241
181
+ │ │ │ ├─Gem::Specification.unresolved_deps /home/z/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/specification.rb:1296
182
+ │ │ │ └─Monitor#mon_exit /home/z/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:197
183
+ │ │ │ └─Monitor#mon_check_owner /home/z/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:247
184
+ │ │ ├─Sinatra::Application#headers $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:298
185
+ │ │ ├─Rack::Utils::HeaderHash#delete $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:522
186
+ │ │ │ ├─Rack::Utils::HeaderHash#block in delete $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:525
187
+ │ │ │ └─Rack::Utils::HeaderHash#block in delete $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:525
188
+ │ │ └─Sinatra::Response#body= $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:129
189
+ │ └─Sinatra::Application#filter! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:964
190
+ │ └─Sinatra::Application#filter! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:964
191
+ ├─Sinatra::Application#invoke $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1066
192
+ │ └─Sinatra::Application#block in invoke $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067
193
+ │ └─Sinatra::Application#block in call! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:908
194
+ │ └─Sinatra::Application#error_block! $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1128
195
+ │ └─Sinatra::Application#settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:927
196
+ │ └─Sinatra::Application.settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:922
197
+ ├─Sinatra::Response#[] $GemPath0/gems/rack-1.6.5/lib/rack/response.rb:52
198
+ │ └─Rack::Utils::HeaderHash#[] $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:511
199
+ ├─Sinatra::Application#body $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:238
200
+ ├─Sinatra::Application#body $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:238
201
+ ├─Sinatra::Application#content_type $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:320
202
+ │ ├─Sinatra::Application#mime_type $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:314
203
+ │ │ └─Sinatra::Base.mime_type $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1312
204
+ │ │ └─Rack::Mime.mime_type $GemPath0/gems/rack-1.6.5/lib/rack/mime.rb:16
205
+ │ ├─Sinatra::Application#settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:927
206
+ │ │ └─Sinatra::Application.settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:922
207
+ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
208
+ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
209
+ │ ├─Sinatra::Application#block in content_type $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:326
210
+ │ ├─Sinatra::Application#block in content_type $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:326
211
+ │ ├─Sinatra::Application#block in content_type $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:326
212
+ │ ├─Sinatra::Application#block in content_type $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:326
213
+ │ ├─Sinatra::Application#settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:927
214
+ │ │ └─Sinatra::Application.settings $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:922
215
+ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
216
+ │ ├─Sinatra::Application.block in set $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1221
217
+ │ ├─Sinatra::Application#block in content_type $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:332
218
+ │ └─Sinatra::Response#[]= $GemPath0/gems/rack-1.6.5/lib/rack/response.rb:56
219
+ │ └─Rack::Utils::HeaderHash#[]= $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:515
220
+ └─Sinatra::Response#finish $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:138
221
+ ├─Sinatra::Response#drop_content_info? $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:166
222
+ │ └─Sinatra::Response#drop_body? $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:170
223
+ ├─Sinatra::Response#drop_body? $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:170
224
+ ├─Sinatra::Response#calculate_content_length? $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:162
225
+ │ ├─Rack::Utils::HeaderHash#[] $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:511
226
+ │ └─Rack::Utils::HeaderHash#[] $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:511
227
+ ├─Sinatra::Response#block in finish $GemPath0/gems/sinatra-1.4.8/lib/sinatra/base.rb:154
228
+ │ └─Rack::Utils.bytesize $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:379
229
+ └─Rack::Utils::HeaderHash#[]= $GemPath0/gems/rack-1.6.5/lib/rack/utils.rb:515
230
+ ```
231
+
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.warning = false if ARGV.index('-W0')
6
+ t.libs << "test"
7
+ t.libs << "lib"
8
+ t.test_files = FileList['test/**/*_test.rb']
9
+ end
10
+
11
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "trace_tree"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,13 @@
1
+ class TraceTree
2
+ module Color
3
+ def label_for_tree_graph
4
+ "#{highlight class_and_method} #{source_location}"
5
+ end
6
+
7
+ private
8
+
9
+ def highlight str
10
+ "\e[1m\e[32m#{str}\e[0m"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ require 'yaml'
2
+
3
+ class TraceTree
4
+ GemPaths = {}
5
+
6
+ ::YAML.load(`gem env`)["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
12
+ end
@@ -0,0 +1,102 @@
1
+ require 'tree_graph'
2
+
3
+ class TraceTree
4
+ class Node
5
+
6
+ include TreeGraph
7
+
8
+ def parent_for_tree_graph
9
+ parent
10
+ end
11
+
12
+ def is_last_for_tree_graph
13
+ return true unless parent
14
+ parent.callees.index(self) == (parent.callees.count - 1)
15
+ end
16
+
17
+ def label_for_tree_graph
18
+ "#{class_and_method} #{source_location}"
19
+ end
20
+
21
+ def children_for_tree_graph
22
+ callees
23
+ end
24
+
25
+ attr_reader :bindings
26
+ attr_accessor :parent
27
+
28
+ def initialize trace_point
29
+ @event = trace_point.event
30
+ @method_id = trace_point.method_id
31
+ @bindings = filter_call_stack trace_point.binding.of_callers!
32
+ end
33
+
34
+ def << node
35
+ callees << node
36
+ node.parent = self
37
+ end
38
+
39
+ def callees
40
+ @callees ||= []
41
+ end
42
+
43
+ def whole_stack
44
+ bindings.map{|b| location_without_lineno b}
45
+ end
46
+
47
+ def parent_stack
48
+ range = (raise_event? ? bindings : bindings[1..-1])
49
+ range.map{|b| location_without_lineno b}
50
+ end
51
+
52
+ private
53
+
54
+ def location_without_lineno bi
55
+ [bi.klass, bi.call_symbol, bi.frame_env, bi.file]
56
+ end
57
+
58
+ def filter_call_stack bindings
59
+ bindings = bindings[2..-1]
60
+ bindings = callees_of_binding_trace_tree bindings
61
+ bindings = bindings.reject{|b| b.frame_env =~ /^rescue\sin\s/}
62
+ bindings.unshift bindings.first if throw_event?
63
+ bindings
64
+ end
65
+
66
+ def callees_of_binding_trace_tree bindings
67
+ bs = []
68
+ bindings.each do |b|
69
+ break if "#{b.klass}#{b.call_symbol}#{b.frame_env}" == "Binding#trace_tree"
70
+ bs << b
71
+ end
72
+ bs
73
+ end
74
+
75
+ def class_and_method
76
+ "#{event_indicator}#{current.klass}#{current.call_symbol}#{current.frame_env}"
77
+ end
78
+
79
+ def source_location
80
+ "#{current.file}:#{current.line}"
81
+ end
82
+
83
+ def current
84
+ bindings[0]
85
+ end
86
+
87
+ def raise_event?
88
+ @event == :raise
89
+ end
90
+
91
+ def throw_event?
92
+ @event == :c_call and :throw == @method_id
93
+ end
94
+
95
+ def event_indicator
96
+ return 'raise in ' if raise_event?
97
+ return 'throw in ' if throw_event?
98
+ return ''
99
+ end
100
+
101
+ end
102
+ end
@@ -0,0 +1,17 @@
1
+ require 'trace_tree/gem_paths'
2
+
3
+ class TraceTree
4
+ module ShortGemPath
5
+
6
+ def source_location
7
+ "#{shorten_gem_path current.file}:#{current.line}"
8
+ end
9
+
10
+ private
11
+
12
+ def shorten_gem_path loc
13
+ GemPaths.each{|name, path| loc = loc.gsub(path, "$#{name}")}
14
+ loc
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ class TraceTree
2
+ VERSION = "0.1.0"
3
+ end
data/lib/trace_tree.rb ADDED
@@ -0,0 +1,59 @@
1
+ require "trace_tree/version"
2
+ require 'binding_of_callers/pry'
3
+ require 'trace_tree/node'
4
+ require 'trace_tree/short_gem_path'
5
+ require 'trace_tree/color'
6
+
7
+ class TraceTree
8
+
9
+ def self.sort stack
10
+ hash = {}
11
+ stack.each do |call|
12
+ unless hash.empty?
13
+ parent = hash[call.parent_stack]
14
+ parent << call if parent
15
+ end
16
+ hash[call.whole_stack] = call
17
+ end
18
+ stack[0]
19
+ end
20
+
21
+ end
22
+
23
+ class Binding
24
+ def trace_tree *log, **opt, &to_do
25
+ log = log.empty? ? STDOUT : log[0]
26
+ node_class = optional_node opt
27
+
28
+ trace_points = []
29
+ tp = TracePoint.trace(:call, :b_call, :raise, :c_call) do |point|
30
+ trace_points << node_class.new(point) if wanted? point
31
+ end
32
+
33
+ eval('self').instance_eval &to_do
34
+ ensure
35
+ tp.disable
36
+ _dump_trace_tree log, trace_points
37
+ end
38
+
39
+ private
40
+
41
+ def optional_node opt
42
+ Class.new TraceTree::Node do
43
+ prepend TraceTree::ShortGemPath unless opt[:gem] == false
44
+ prepend TraceTree::Color unless opt[:color] == false
45
+ end
46
+ end
47
+
48
+ def _dump_trace_tree log, trace_points
49
+ tree = TraceTree.
50
+ sort(trace_points).
51
+ tree_graph
52
+
53
+ log.puts tree
54
+ end
55
+
56
+ def wanted? trace_point
57
+ trace_point.event != :c_call or trace_point.method_id == :throw
58
+ end
59
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'trace_tree/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "trace_tree"
8
+ spec.version = TraceTree::VERSION
9
+ spec.authors = ["ken"]
10
+ spec.email = ["block24block@gmail.com"]
11
+
12
+ spec.summary = %q{Print TracePoint(normal ruby call, block call, raise call, throw call) in tree graph}
13
+ spec.homepage = "https://github.com/turnon/trace_tree"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.14"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "minitest", "~> 5.0"
26
+
27
+ spec.add_dependency "binding_of_callers", "0.1.3"
28
+ spec.add_dependency "tree_graph", "~> 0.1.0"
29
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trace_tree
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ken
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: binding_of_callers
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: tree_graph
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.1.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.1.0
83
+ description:
84
+ email:
85
+ - block24block@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - CODE_OF_CONDUCT.md
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - lib/trace_tree.rb
100
+ - lib/trace_tree/color.rb
101
+ - lib/trace_tree/gem_paths.rb
102
+ - lib/trace_tree/node.rb
103
+ - lib/trace_tree/short_gem_path.rb
104
+ - lib/trace_tree/version.rb
105
+ - trace_tree.gemspec
106
+ homepage: https://github.com/turnon/trace_tree
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.6.8
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Print TracePoint(normal ruby call, block call, raise call, throw call) in
130
+ tree graph
131
+ test_files: []