-
Notifications
You must be signed in to change notification settings - Fork 216
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 signatures for Gem
module in rubygems
gem
#605
Conversation
This change adds signatures of the `Gem` module in the `rubygems` gem. Note that this does not include signatures of `Gem::*` classes or modules like `Gem::Version`. (because it would be a too big PR) See also: - https://github.com/rubygems/rubygems/blob/v3.2.11/lib/rubygems.rb - https://ruby-doc.org/stdlib-3.0.0/libdoc/rubygems/rdoc/Gem.html
# TODO: Is this defined as a built-in type? | ||
interface _HashLike[K, V] | ||
def each_pair: () { ([ K, V ]) -> untyped } -> self | ||
end |
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.
[note] This interface _HashLike
is required by the Gem.paths=
method:
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 think it's better to put the type inside Gem
module, not exposing as a top level type.
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.
Thanks for the advice. I'll fix it with another PR. 👍
end | ||
|
||
def test_install | ||
omit "due to side-effect" |
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.
[note] Gem.install
has side-effect so this test is skipped. Please tell me a better way if you know it. 🙏
end | ||
|
||
def test_loaded_specs | ||
omit "due to Bundler::StubSpecification returns" |
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.
[note] Gem.loaded_specs
returns a Hash
including Bundler::StubSpecification
, but this test fails because Bundler::StubSpecification
is not a Gem::BasicSpecification
.
$ bundle exec ruby -e 'pp Bundler::StubSpecification.ancestors'
[Bundler::StubSpecification,
Bundler::RemoteSpecification,
Comparable,
Bundler::MatchPlatform,
Bundler::GemHelpers,
Object,
Kernel,
BasicObject]
Please tell me a better way if you know it. 🙏
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.
Looks good to skip testing. 🎿
run: | | ||
ruby -v | ||
gem install bundler | ||
gem update --system |
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.
[note] The test for Gem.plugindir
fails with Ruby 2.7 because Ruby 2.7 includes RubyGems 3.1 by default.
Error: test_plugindir(GemSingletonTest): NoMethodError: undefined method `plugindir' for Gem:Module
https://github.com/ruby/rbs/pull/605/checks?check_run_id=1937717810#step:8:1248
.plugindir
has been available since RubyGems 3.2 (see rubygems/rubygems#3163)
So, I've updated this CI configuration to use the latest RubyGems.
This way may be correct, but it seems to me that this CI update should be done on another PR.
Can you provide me feedback, please?
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.
Installing the latest rubygems looks reasonable. 👍
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.
Thank you! 💎
@soutaro Thank you so much for reviewing and merging it! I'll add more signatures for |
This change adds signatures of the
Gem
module in therubygems
gem.Note that this does not include signatures of
Gem::*
classes or modules likeGem::Version
.(because it would be a too big PR)
See also: