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

Support the latest_specs endpoint #131

Merged

Conversation

randycoulman
Copy link
Contributor

This adds support for the latest_specs.4.8.gz endpoint that is required for several gem commands to work properly (e.g. gem install and gem search without the -a flag). See #129 for more details.

There might be a more efficient way to implement the database query. I'm not aware of a way to do proper gem version comparisons in the DB, so it seemed to just pull all of the versions and do the latest version selection in Ruby.

If a gem has platform-specific versions, the latest version for each platform will be returned by this code. That seems to match what the latest_specs.4.8.gz endpoint on rubygems.org does.

I added several unit tests and one new integration test that shows the difference in behavior between gem search -a and gem search.

It might be worth adding integration tests for the gem install command, but I wasn't sure what kind of test infrastructure that would require. I'd be happy to write such a spec if someone can give me a little guidance there.

Fixes #129

@indirect
Copy link
Member

Awesome, thanks for writing this!

As you noticed, only specs.4.8.gz is actively used by Bundler, and only when the --full-index option is passed. Today, Bundler tries to use the compact index provided at /versions and /info/GEMNAME, then falls back on the dependency API available at /api/v1/dependencies and only if that is not available will it fall back on specs.4.8.gz.

I believe these three files are the only ones currently used by RubyGems: https://github.com/rubygems/rubygems.org/blob/cb09831cd8e827a821b8cdc203fecd8bbab6b722/app/middleware/hostess.rb#L6-L8.

@randycoulman
Copy link
Contributor Author

@indirect I'm not sure I understand your meaning. Are you saying that this PR isn't needed because Bundler doesn't use this endpoint any more? Or are you saying it is needed because RubyGems still uses it?

@indirect
Copy link
Member

Sorry for the confusion! It is needed, because rubygems uses it. :)

@smellsblue
Copy link
Contributor

@randycoulman Thanks so much for the work! Sorry for being MIA, but I'm going to try to backport this to the 1.0 branch and get it released ASAP. I'll also try to add the integration test you mentioned.

@smellsblue smellsblue merged commit 04372d8 into rubygems:master Jan 23, 2017
@randycoulman
Copy link
Contributor Author

@smellsblue Awesome, thanks! Let me know if I can be any help with the backport or the integration test.

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

Successfully merging this pull request may close these issues.

3 participants