Argtrace is a Ruby MRI method type analyser.
Argtrace uses TracePoint and traces all of method calling, peeks actual type of parameters and return value, and finally summarize them into RBS format.
Add this line to your application's Gemfile:
gem 'argtrace'And then execute:
$ bundle install
Or install it yourself as:
$ gem install argtrace
require 'argtrace'
Argtrace::Default.main(rbs_path: "sig.rbs")
... (YOUR PROGRAM HERE) ...RBS file is saved as "sig.rbs" in current directory.
$ ruby -r argtrace/autorun YOUR_PROGRAM_HERE.rbRBS file is saved as "sig.rbs" in current directory.
Modify Rakefile to load Argtrace.
RSpec::Core::RakeTask.new(:spec) do |t|
t.ruby_opts = %w[-r argtrace/autorun]
endthen run as usual like rake test.
RBS file is saved as "sig.rbs" in current directory.
Modify global helper under test/ to load Argtrace. For example:
require "argtrace/autorun"
require "minitest/autorun"And add Argtrace to Gemfile
gem "argtrace"then run as usual like rake test.
RBS file is saved as "sig.rbs" in current directory.
- Argtrace cannot work with C-extension, because TracePoint doesn't provide feature to access arguments of calls into C-extension.
- Only work with single-thread programs.
Bug reports and pull requests are welcome on GitHub at https://github.com/jljse/argtrace.
The gem is available as open source under the terms of the MIT License.