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

オープン
#9,834 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
ruby
領域
tooling

調査の方向性

まず、Gem::CompactIndexClient::InfoRow と Gem::QueryUtils::VersionPlatforms を、その呼び出し元を通して追跡します。これには、並列ハッシュを渡す 6 つのメソッドも含まれます。INFO_* との互換性と、Bundler とともに配布された古いクライアントのサポートを維持しながら、issue で説明されている名前付きインターフェースを導入します。完了の条件は、対応するパラメーターと、ネストされたハッシュを繰り返し走査する処理が削除されていることです。

索引モデルが issue の本文から書いたものです。

説明

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 = 0 … INFO_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.

主要言語
Ruby
スター
4k
フォーク
2k
平均マージ
1日 22時間
マージ済み PR(30日)
59

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ruby/rubygems のほかの issue

ruby/rubygems の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。