trace_graph 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.txt +21 -0
- data/README.md +129 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/images/document_worker_trace.png +0 -0
- data/docs/images/foo_trace.png +0 -0
- data/lib/trace_graph/trace_node.rb +35 -0
- data/lib/trace_graph/tracer.rb +166 -0
- data/lib/trace_graph/version.rb +3 -0
- data/lib/trace_graph.rb +8 -0
- data/trace_graph.gemspec +38 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dd780ac25e119f53019469ce53d16566fb3acbe251ca04eec7f275b5170bcdae
|
4
|
+
data.tar.gz: d0055ce4f5bf0c69d384b40b4fb72b88584de876bc830084c3b527fc290a3e88
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 45e82dac33a5477f396d3f4bff13f4eef95bc4ad6435f63a16d94a9268ae08e83009a4e2420e2e7a67b15b8db2c68f27bd141ee6aaed94d35d48085ce562da52
|
7
|
+
data.tar.gz: 8b4066d99e34ea38b1e1cb4957a6a732b795fa001b1912337f8da12d2926c5351eb495c2df3c630c806fe6be80b2eaca70c2366e7fecb9192e143304b9701fc7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 jeremy@octolabs.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
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
trace_graph (0.1.0)
|
5
|
+
ruby-graphviz
|
6
|
+
tree_graph
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
byebug (11.1.3)
|
12
|
+
diff-lcs (1.3)
|
13
|
+
rake (10.5.0)
|
14
|
+
rexml (3.2.4)
|
15
|
+
rspec (3.9.0)
|
16
|
+
rspec-core (~> 3.9.0)
|
17
|
+
rspec-expectations (~> 3.9.0)
|
18
|
+
rspec-mocks (~> 3.9.0)
|
19
|
+
rspec-core (3.9.2)
|
20
|
+
rspec-support (~> 3.9.3)
|
21
|
+
rspec-expectations (3.9.2)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.9.0)
|
24
|
+
rspec-mocks (3.9.1)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.9.0)
|
27
|
+
rspec-support (3.9.3)
|
28
|
+
ruby-graphviz (1.2.5)
|
29
|
+
rexml
|
30
|
+
tree_graph (0.2.2)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
bundler (~> 2.0)
|
37
|
+
byebug
|
38
|
+
rake (~> 10.0)
|
39
|
+
rspec (~> 3.0)
|
40
|
+
trace_graph!
|
41
|
+
|
42
|
+
BUNDLED WITH
|
43
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Jeremy Green
|
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,129 @@
|
|
1
|
+
# TraceGraph
|
2
|
+
|
3
|
+
TraceGraph gives you visibility into the control flow of your application. Rather than read all the code
|
4
|
+
trying to form a mental picture of it, let TraceGraph draw you a picture like this:
|
5
|
+
|
6
|
+

|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'trace_graph'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install trace_graph
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
A simple use might look like this:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
foo = Foo.new
|
30
|
+
tracer = TraceGraph::Tracer.new({ included_paths: ["foo"], png: 'foo_trace.png' })
|
31
|
+
tracer.trace{ foo.foo_both }
|
32
|
+
```
|
33
|
+
|
34
|
+
For the `Foo` class shown below you'd see output like this in your console:
|
35
|
+
|
36
|
+
```
|
37
|
+
trace
|
38
|
+
└─Foo#foo_both
|
39
|
+
├─Foo#first_method
|
40
|
+
└─Foo#second_method
|
41
|
+
```
|
42
|
+
|
43
|
+
And a graph like this would be generated at `foo_trace.png`
|
44
|
+
|
45
|
+
|
46
|
+

|
47
|
+
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
# foo.rb
|
51
|
+
class Foo
|
52
|
+
def first_method
|
53
|
+
end
|
54
|
+
|
55
|
+
def second_method
|
56
|
+
end
|
57
|
+
|
58
|
+
def foo_both
|
59
|
+
first_method
|
60
|
+
second_method
|
61
|
+
end
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
## Options
|
66
|
+
|
67
|
+
When constructing a tracer you can pass in a number of options to control what shows up
|
68
|
+
in the graph.
|
69
|
+
|
70
|
+
* `included_paths` - By default TraceGraph will not capture any lines, so you need to tell it
|
71
|
+
what files you're interested in. If your app lives in a directory called `my_app` and you
|
72
|
+
want to see everything in your app you could pass `["my_app"]`. You can include as many paths
|
73
|
+
as you need in the array. Default value is an empty array. If you weant to see _everythin_ you
|
74
|
+
can pass `nil`. (For something like a Rails app you probably really don't want to see everything.)
|
75
|
+
|
76
|
+
* `excluded_paths` - A list of paths to exclude. Maybe `["my_app/some_utility_helper"]`. Default
|
77
|
+
value is `nil`.
|
78
|
+
|
79
|
+
* `png` - A string path where to write a png graph.
|
80
|
+
|
81
|
+
* `mark_duplicate_calls` - Either `true` or `false`. Default value is `false`. When `true` any
|
82
|
+
repeat calls to a method will be marked with a count, and will be colored red on the png.
|
83
|
+
|
84
|
+
* `show_arguments` - Either `true` or `false`. Default value is `false`. When `true` the arguments
|
85
|
+
passed to each method call will be shown. (This doesn't work so well if there are lots of arguments
|
86
|
+
or some very large ones...)
|
87
|
+
|
88
|
+
* `show_return_values` - Either `true` or `false`. Default value is `false`. When `true` the return
|
89
|
+
values from each method call will be shown. (This doesn't work so well for lots or large return values.)
|
90
|
+
|
91
|
+
A robust tracer might look like this:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
tracer = TraceGraph::Tracer.new({
|
95
|
+
included_paths: ["my_app/app"], # See everything local to a rails app
|
96
|
+
excluded_paths: ["my_app/app/helpers"], # Except the helpers
|
97
|
+
mark_duplicate_calls: true,
|
98
|
+
show_arguments: true,
|
99
|
+
show_return_values: true,
|
100
|
+
png: 'my_very_busy_trace.png'
|
101
|
+
})
|
102
|
+
```
|
103
|
+
|
104
|
+
### Matching for `included_paths` and `excluded_paths`
|
105
|
+
|
106
|
+
TraceGraph uses the ruby TracePoint class, and paths are matched on the `inspect` value
|
107
|
+
for a trace. A typical `inspect` values looks like this:
|
108
|
+
|
109
|
+
```
|
110
|
+
#<TracePoint:call `first_method'@/Users/jgreen/projects/trace_graph/spec/support/foo.rb:2>
|
111
|
+
```
|
112
|
+
|
113
|
+
## Development
|
114
|
+
|
115
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
116
|
+
|
117
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
118
|
+
|
119
|
+
## Contributing
|
120
|
+
|
121
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jagthedrummer/trace_graph. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
122
|
+
|
123
|
+
## License
|
124
|
+
|
125
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
126
|
+
|
127
|
+
## Code of Conduct
|
128
|
+
|
129
|
+
Everyone interacting in the TraceGraph project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/trace_graph/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "trace_graph"
|
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
Binary file
|
Binary file
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'tree_graph'
|
2
|
+
|
3
|
+
module TraceGraph
|
4
|
+
class TraceNode
|
5
|
+
include TreeGraph
|
6
|
+
attr_accessor :label
|
7
|
+
attr_accessor :sub_nodes
|
8
|
+
attr_accessor :is_duplicate
|
9
|
+
|
10
|
+
alias_method :label_for_tree_graph, :label
|
11
|
+
alias_method :children_for_tree_graph, :sub_nodes
|
12
|
+
|
13
|
+
def initialize(label, is_duplicate: false)
|
14
|
+
self.label = label
|
15
|
+
self.is_duplicate = is_duplicate
|
16
|
+
self.sub_nodes = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def << child_node
|
20
|
+
sub_nodes << child_node
|
21
|
+
end
|
22
|
+
|
23
|
+
def node_count
|
24
|
+
sub_nodes.length
|
25
|
+
end
|
26
|
+
|
27
|
+
def first
|
28
|
+
sub_nodes.first
|
29
|
+
end
|
30
|
+
|
31
|
+
def second
|
32
|
+
sub_nodes[1]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
module TraceGraph
|
2
|
+
class Tracer
|
3
|
+
require 'ruby-graphviz'
|
4
|
+
|
5
|
+
def initialize(options)
|
6
|
+
@options = options
|
7
|
+
# We check included paths differently than excluded ones to allow nil to be bassed, to include everyting
|
8
|
+
@included_paths = options.key?(:included_paths) ? options[:included_paths] : []
|
9
|
+
@excluded_paths = options[:excluded_paths] || []
|
10
|
+
@include_protected = options[:include_protected] || false
|
11
|
+
@mark_duplicate_calls = options.key?(:mark_duplicate_calls) ? options[:mark_duplicate_calls] : true
|
12
|
+
@show_arguments = options[:show_arguments] || false
|
13
|
+
@show_return_values = options[:show_return_values] || false
|
14
|
+
|
15
|
+
@trace_point = build_trace_point
|
16
|
+
@top_node = TraceGraph::TraceNode.new("trace")
|
17
|
+
@stack = []
|
18
|
+
@all_nodes = [@top_node]
|
19
|
+
@edge_count = 0
|
20
|
+
@unique_node_counts = {}
|
21
|
+
end
|
22
|
+
|
23
|
+
def trace
|
24
|
+
unless block_given?
|
25
|
+
raise Error.new "You must pass a block to the tracer."
|
26
|
+
end
|
27
|
+
|
28
|
+
@edge_count = 0
|
29
|
+
@unique_node_counts = {}
|
30
|
+
@trace_point.enable
|
31
|
+
yield
|
32
|
+
@trace_point.disable
|
33
|
+
# TODO : Maybe outputting this should be an options, or a different tracer?
|
34
|
+
puts @top_node.tree_graph
|
35
|
+
if @options[:png]
|
36
|
+
write_png @options[:png]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def call_trace
|
41
|
+
@top_node
|
42
|
+
end
|
43
|
+
|
44
|
+
def node_count
|
45
|
+
@all_nodes.length - 1 # should top_node count as a node?
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def write_png png
|
51
|
+
g = ::GraphViz.new( :G, :type => :digraph )
|
52
|
+
add_node g, @top_node, nil
|
53
|
+
g.output( :png => png )
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_node graph, node, parent
|
57
|
+
label = node.label.gsub("←","\n←").gsub("→","\n→")
|
58
|
+
gnode = graph.add_nodes(label)
|
59
|
+
if node.is_duplicate
|
60
|
+
gnode[:color] = "red:white"
|
61
|
+
end
|
62
|
+
if parent
|
63
|
+
edge = graph.add_edges(parent.label, label)
|
64
|
+
edge[:label] = @edge_count + 1
|
65
|
+
@edge_count += 1
|
66
|
+
# add edge
|
67
|
+
end
|
68
|
+
node.sub_nodes.each do |sub_node|
|
69
|
+
add_node graph, sub_node, node
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def build_trace_point
|
74
|
+
TracePoint.new(:call,:return) do |tp|
|
75
|
+
if should_include_trace_line(tp)
|
76
|
+
if tp.event == :call
|
77
|
+
handle_call(tp)
|
78
|
+
elsif tp.event == :return
|
79
|
+
handle_return(tp)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def extract_arguments(trace)
|
86
|
+
return {} unless trace.respond_to?(:parameters)
|
87
|
+
param_names = trace.parameters.map(&:last)
|
88
|
+
param_names.map { |n| [n, trace.binding.eval(n.to_s)] }.to_h
|
89
|
+
end
|
90
|
+
|
91
|
+
def build_node_label(tp, for_call: true)
|
92
|
+
label = "#{tp.defined_class}##{tp.method_id}"
|
93
|
+
args = extract_arguments(tp)
|
94
|
+
if @show_arguments && args.any?
|
95
|
+
label = "#{label} →(#{args})"
|
96
|
+
end
|
97
|
+
is_dupicate = false
|
98
|
+
if @mark_duplicate_calls
|
99
|
+
if for_call # we don't want to mess with the count on a return
|
100
|
+
if @unique_node_counts[label]
|
101
|
+
@unique_node_counts[label] += 1
|
102
|
+
else
|
103
|
+
@unique_node_counts[label] = 0
|
104
|
+
end
|
105
|
+
end
|
106
|
+
if @unique_node_counts[label] && @unique_node_counts[label] > 0
|
107
|
+
label = "#{label} (##{@unique_node_counts[label]+1})"
|
108
|
+
is_duplicate = true
|
109
|
+
end
|
110
|
+
end
|
111
|
+
return label, is_duplicate
|
112
|
+
end
|
113
|
+
|
114
|
+
def handle_call(tp)
|
115
|
+
parent = @stack.last
|
116
|
+
label, is_duplicate = build_node_label(tp)
|
117
|
+
new_node = TraceGraph::TraceNode.new(label, is_duplicate: is_duplicate)
|
118
|
+
@stack << new_node
|
119
|
+
@all_nodes << new_node
|
120
|
+
if parent
|
121
|
+
parent << new_node
|
122
|
+
else
|
123
|
+
@top_node << new_node
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def handle_return(tp)
|
128
|
+
label, _is_duplicate = build_node_label(tp, for_call: false)
|
129
|
+
last_node = @stack.last
|
130
|
+
if last_node && last_node.label == label
|
131
|
+
if @show_return_values && tp.return_value
|
132
|
+
last_node.label = "#{last_node.label} ←(#{tp.return_value})"
|
133
|
+
end
|
134
|
+
@stack.pop
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def should_include_trace_line(tp)
|
139
|
+
should_include = false
|
140
|
+
if @included_paths
|
141
|
+
@included_paths.each do |path|
|
142
|
+
path = path.is_a?(String) ? /#{path}/ : path
|
143
|
+
if tp.inspect =~ path
|
144
|
+
should_include = true
|
145
|
+
end
|
146
|
+
end
|
147
|
+
else
|
148
|
+
# If included_paths was passed as nil that means to include everything that's not excluded
|
149
|
+
should_include = true
|
150
|
+
end
|
151
|
+
@excluded_paths.each do |path|
|
152
|
+
path = path.is_a?(String) ? /#{path}/ : path
|
153
|
+
if tp.inspect =~ path
|
154
|
+
should_include = false
|
155
|
+
end
|
156
|
+
end
|
157
|
+
klass = tp.defined_class
|
158
|
+
method = tp.method_id
|
159
|
+
public_methods = klass.public_methods(false) + klass.public_instance_methods(false)
|
160
|
+
unless public_methods.include?(method) || @include_protected
|
161
|
+
should_include = false
|
162
|
+
end
|
163
|
+
return should_include
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
data/lib/trace_graph.rb
ADDED
data/trace_graph.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "trace_graph/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "trace_graph"
|
7
|
+
spec.version = TraceGraph::VERSION
|
8
|
+
spec.authors = ["Jeremy Green"]
|
9
|
+
spec.email = ["jeremy@octolabs.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Generate a visual graph of method calls}
|
12
|
+
spec.description = %q{Generate a visua graph of method calls}
|
13
|
+
spec.homepage = "https://github.com/jagthedrummer/trace_graph"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/jagthedrummer/trace_graph"
|
20
|
+
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_dependency "tree_graph"
|
32
|
+
spec.add_dependency "ruby-graphviz"
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
37
|
+
spec.add_development_dependency "byebug"
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trace_graph
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeremy Green
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tree_graph
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruby-graphviz
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Generate a visua graph of method calls
|
98
|
+
email:
|
99
|
+
- jeremy@octolabs.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
107
|
+
- CODE_OF_CONDUCT.md
|
108
|
+
- Gemfile
|
109
|
+
- Gemfile.lock
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- bin/console
|
114
|
+
- bin/setup
|
115
|
+
- docs/images/document_worker_trace.png
|
116
|
+
- docs/images/foo_trace.png
|
117
|
+
- lib/trace_graph.rb
|
118
|
+
- lib/trace_graph/trace_node.rb
|
119
|
+
- lib/trace_graph/tracer.rb
|
120
|
+
- lib/trace_graph/version.rb
|
121
|
+
- trace_graph.gemspec
|
122
|
+
homepage: https://github.com/jagthedrummer/trace_graph
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata:
|
126
|
+
homepage_uri: https://github.com/jagthedrummer/trace_graph
|
127
|
+
source_code_uri: https://github.com/jagthedrummer/trace_graph
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubygems_version: 3.0.3
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: Generate a visual graph of method calls
|
147
|
+
test_files: []
|