Calleree helps to analyze Ruby's caller-callee relationships. Note that this tool consumes memory and introduces additional overhead because of dynamic analysis.
Add this line to your application's Gemfile:
gem 'calleree'And then execute:
$ bundle install
Or install it yourself as:
$ gem install calleree
1
2 require 'calleree'
3
4 def foo
5 :foo
6 end
7
8 def bar
9 foo
10 end
11
12 Calleree.start
13
14 foo
15
16 pp Calleree.resultAnd this program shows:
[[["test.rb", 14], ["test.rb", 5], 1],
[["test.rb", 16], ["/mnt/c/ko1/src/rb/calleree/lib/calleree.rb", 24], 1]]
The Calleree.result method returns an array of arrays which contains [[caller_path, caller_line], [callee_path, callee_line], called_caount].
In this case, foo at ["test.rb", 5] is called at ["test.rb", 14] only once.
- You can stop the analisys with
Calleree.stop.Calleree.startwill continue the analysis. - You can use block with
Calleree.start do ... end. - You can clear the result if
Calleree.result(clear: true)is passed.
After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
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.
Bug reports and pull requests are welcome on GitHub at https://github.com/ko1/calleree.
The gem is available as open source under the terms of the MIT License.