RubyGems Registry Adapter
Relevant source files
The following files were used as context for generating this wiki page:
The RubyGems Registry Adapter is a specialized ecosystem implementation within the regxa project designed to interface with the RubyGems API. Its primary purpose is to fetch, normalize, and return gem metadata, version history, dependencies, and ownership information in a format consistent with the project's core data models.
This adapter implements the Registry contract defined in the core layer, allowing the universal client to handle RubyGems packages using the gem ecosystem key. It utilizes the central Client for HTTP requests, ensuring that retry logic and rate limiting are applied consistently across all registry interactions.
Sources: src/registries/rubygems.ts:40-42, src/registries/AGENTS.md:1-12, README.md:12-20
Architecture and Integration
The RubyGems adapter follows a plugin-based architecture where it registers itself with the global registry factory upon import. It serves as a translation layer between the RubyGems JSON API and the normalized regxa interfaces.
The diagram above illustrates the data flow from the core factory through the adapter to the external RubyGems API.
Sources: src/registries/rubygems.ts:200-205, src/core/AGENTS.md:14-22, src/registries/AGENTS.md:24-30
Key Data Structures
The adapter defines internal interfaces to map the specific JSON structures returned by the RubyGems API endpoints.
Internal API Mappings
| Interface | Purpose | Key Fields |
|---|---|---|
RubyGemsGemResponse | Maps gem metadata and dependencies | name, version, licenses, dependencies |
RubyGemsVersionResponse | Maps version history data | number, sha, created_at, yanked |
RubyGemsOwnerResponse | Maps gem ownership/maintainer data | handle, email |
Sources: src/registries/rubygems.ts:13-38
Core Functionality
Package Metadata Retrieval
The fetchPackage method targets the /api/v1/gems/${name}.json endpoint. It normalizes licenses using combineLicenses and normalizeLicense, and cleanses repository URLs using normalizeRepositoryURL. If a package is not found, it catches HTTPError and re-throws a project-specific NotFoundError.
Sources: src/registries/rubygems.ts:54-91, test/unit/registries.test.ts:474-486
Dependency Resolution
The adapter uses the RubyGems v2 API for version-specific dependency lookups, specifically hitting the path /api/v2/rubygems/${name}/versions/${version}.json. This allows for accurate retrieval of both runtime and development dependencies for a precise gem version.
Version and Maintainer Management
- Versions: Fetched from
/api/v1/versions/${name}.json. The adapter converts theshafield into asha256-prefixed integrity string and maps theyankedboolean to a "yanked" status string. - Maintainers: Fetched from
/api/v1/gems/${name}/owners.json. RubyGems "owners" are normalized into theMaintainertype, using thehandlefor both login and name fields.
Sources: src/registries/rubygems.ts:93-120, src/registries/rubygems.ts:161-184, test/unit/registries.test.ts:503-524
URL Generation
The adapter provides a URLBuilder (via the urls() method) to generate various links related to a gem.
| URL Type | Format / Destination |
|---|---|
| Registry | https://rubygems.org/gems/${name}/versions/${version} |
| Download | https://rubygems.org/downloads/${name}-${version}.gem |
| Documentation | https://www.rubydoc.info/gems/${name}/${version} |
| PURL | pkg:gem/${name}@${version} (standardized via buildPURL) |
Sources: src/registries/rubygems.ts:186-210, test/unit/registries.test.ts:457-463
Summary
The RubyGems Registry Adapter serves as a critical bridge between the Ruby ecosystem and the regxa universal client. By leveraging both v1 and v2 RubyGems APIs, it provides comprehensive metadata coverage—including deep dependency trees and version integrity—while maintaining the project's strict normalization standards.