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 signatures for Gem module in rubygems gem #605

Merged
merged 2 commits into from
Feb 24, 2021
Merged

Add signatures for Gem module in rubygems gem #605

merged 2 commits into from
Feb 24, 2021

Conversation

ybiquitous
Copy link
Contributor

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:

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
Copy link
Contributor Author

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:

See also https://github.com/rubygems/rubygems/blob/6ca677a0eb8f985235d67563fc0f978ef77d7bad/lib/rubygems.rb#L392.

Copy link
Member

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.

Copy link
Contributor Author

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"
Copy link
Contributor Author

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"
Copy link
Contributor Author

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. 🙏

Copy link
Member

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
Copy link
Contributor Author

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?

Copy link
Member

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. 👍

@ybiquitous ybiquitous marked this pull request as ready for review February 19, 2021 19:25
Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 💎

@soutaro soutaro merged commit ecf1ba4 into ruby:master Feb 24, 2021
@ybiquitous ybiquitous deleted the add-rubygems-signatures branch February 25, 2021 00:41
@ybiquitous
Copy link
Contributor Author

@soutaro Thank you so much for reviewing and merging it! I'll add more signatures for rubygems with another PR. 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants