ruby / ruby/rubygems

[Content Addressable Gems] Replace hash/array manipulation with named classes

Open
#9,834 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
4k
Forks
1.9k
Avg merge
1d 2h
Merged PRs (30d)
81

Description

Context

In (ruby/rubygems#9773), there was a suggestion giving some of the hashes and arrays names — i.e. making concrete classes with names.

The branch has a lot of pre exisiting hash and array manipulation: positional rows indexed by magic constants, composite array keys, and parallel nested hashes threaded through long method chains. Two ideas to start:

1. Gem::CompactIndexClient::InfoRow

Compact index info rows are 5-element arrays indexed via INFO_NAME = 0INFO_REQS = 4. Wrap them in a Struct with named accessors (#version, #suffix, #ruby_requirement, #platform_requirement, #created_at) and convert at the consumption boundary via InfoRow.wrap, so older Bundler-shipped copies of the client (which return plain arrays behind the load guard) keep working. Parser hot path is unchanged; INFO_* constants stay for compatibility.

2. Gem::QueryUtils::VersionPlatforms

gem list/search/info build two parallel auto-vivifying hashes (platforms and platform_ruby_abis) and pass them together through six methods. Replace both with one presenter exposing #versions, #platforms_for(version), #ruby_abis_for(version, platform), and #ruby_abi_metadata?, dropping the paired parameters and the repeated values.any? { .values.any?(&:any?) } crawls.

There are more candidates (e.g. the throwaway row arrays and composite keys in Gem::Source#decode_content_addressable_tuples, the stub-target: hash in StubSpecification), which can follow the same pattern later.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Gem::CompactIndexClient::InfoRow and Gem::QueryUtils::VersionPlatforms through their callers, including the six methods that pass the parallel hashes. Introduce the named interfaces described in the issue while preserving INFO_* compatibility and support for older Bundler-shipped clients; done means the paired parameters and repeated nested-hash traversal are removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.