Skip to content

Repeatedly load sig directory from loaded gems #32

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

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

Conversation

tompng
Copy link
Member

@tompng tompng commented Jun 23, 2024

Loads rbs defined in gem sig directory.
Adds ReplTypeCompletor.reload_rbs, which should be called from IRB in InputMethod#gets

class IRB::TypeCompletor
  def reload
    ReplTypeCompletor.reload_rbs rescue nil
  end
end

class IRB::ReadlineInputMethod < StdioInputMethod
  def gets
    @completor.reload
    ...
  end
end

ReplTypeCompletor reloads rbs when additional gem is loaded (by checking $LOADED_FEATURES difference)

# loads sig defined in required gems
irb(main):001> Prism.parse('1').value.statements.b
                           '1').value.statements.body
irb(main):002> require 'rmagick'
irb(main):003> # Automatically loads rmagic/sig/*.rbs in another thread
irb(main):003> pix = Magick::Pixel.new; pix.red.ab
                                        pix.red.abs 
                                        pix.red.abs2

@tompng tompng changed the title Add ReplTypeCompletor.reload_rbs to load rbs in newly required gem Load sig directory from gem Jun 23, 2024
@tompng tompng added the enhancement New feature or request label Jun 23, 2024
@tompng tompng changed the title Load sig directory from gem Repeatedly load sig directory from loaded gems Oct 8, 2024
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.

1 participant