iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
💎
Getting Started with Ruby Type Profiler
Follow the steps as described in https://github.com/mame/ruby-type-profiler.
git clone https://github.com/mame/ruby-type-profiler.git
cd ruby-type-profiler
git submodule init
git submodule update
bundle install
ruby exe/type-profiler target.rb
You write your own program in the target.rb part.
# test.rb
def foo(x)
if x > 10
x.to_s
else
nil
end
end
foo(42)
If you write it like this, execute it as follows:
ruby exe/type-profiler test.rb
In my environment, an error ``require': cannot load such file -- rbs (LoadError)` occurred, but I was able to run it after installing the following:
gem install rbs
It should have been installed via submodule, so I checked and was able to run the latest version with the following:
Update: The README update was merged via PR.
cd rbs && bundle install && bundle exec rake parser && cd ..
Currently, it seems there are files for verification under the smoke directory.
bundle exec ruby exe/type-profiler smoke/alias.rb
# Classes
class Object
def foo : (Integer) -> Integer
def bar : (String) -> String
end
class Test
def baz : (Integer) -> Integer
def qux : (String) -> String
end
Discussion