New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ripper DSL #1820
base: main
Are you sure you want to change the base?
Add ripper DSL #1820
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with having this here since it can't be in ruby. Can you commit the resulting RBI file as well. After running bundle exec tapioca dsl
.
it "generates RBI definitions for ripper state constants" do | ||
rbi = rbi_for(:Ripper) | ||
|
||
assert_match(/^Ripper::EXPR_BEG = \d+$/, rbi) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually generates Ripper::EXPR_BEG = T.let(T.unsafe(nil), ::Integer)
so this match fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have some test failures, but the code looks good to me
This doesn't quite fit in to the normal idea of a DSL, but I think it fits best here. Basically, because ripper isn't a normal gem and doesn't have a version, there's not a great way to generate static RBIs for it, because it depends on your current version of Ruby.
Motivation
This doesn't quite fit in to the normal idea of a DSL, but I think it fits best here. Basically, because ripper isn't a normal gem and doesn't have a version, there's not a great way to generate static RBIs for it, because it depends on your current version of Ruby.
If this doesn't belong here and can go elsewhere, let me know.
Implementation
Loop over the defined constants at runtime, generate the definitions.
Tests
I included tests.