Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add ripper DSL #1820

wants to merge 1 commit into from

Conversation

kddnewton
Copy link
Contributor

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.

@kddnewton kddnewton requested a review from a team as a code owner March 14, 2024 14:24
@kddnewton kddnewton added the enhancement New feature or request label Mar 14, 2024
Copy link
Contributor

@KaanOzkan KaanOzkan left a 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)
Copy link
Contributor

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

Copy link
Member

@vinistock vinistock left a 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants