rubygems

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package rubygems exposes rubygems.org as a kit Domain.

A multi-domain host (ant) enables it with a single blank import:

import _ "github.com/tamnd/rubygems-cli/rubygems"

The same Domain also builds the standalone rubygems binary.

Package rubygems is the library behind the rubygems command line: the HTTP client, request shaping, and the typed data models for rubygems.org.

The Client paces requests, sets an honest User-Agent, and retries transient failures (429 and 5xx). No API key is required.

Index

Constants

View Source
const DefaultUserAgent = "rubygems/dev (+https://github.com/tamnd/rubygems-cli)"

DefaultUserAgent identifies the client to RubyGems.

View Source
const Host = "rubygems.org"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to RubyGems over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) GemInfo added in v0.1.1

func (c *Client) GemInfo(ctx context.Context, name string) (Gem, error)

GemInfo fetches info for a single gem by name.

func (*Client) ReverseDeps added in v0.1.1

func (c *Client) ReverseDeps(ctx context.Context, name string, limit int) ([]ReverseDep, error)

ReverseDeps lists gems that depend on the given gem. The API returns a flat array of gem name strings; the client converts them to ReverseDep. limit clips the result; 0 means return all.

func (*Client) Search added in v0.1.1

func (c *Client) Search(ctx context.Context, query string, limit int) ([]Gem, error)

Search finds gems matching query. It returns at most limit items (pass 0 for default 10).

func (*Client) Versions added in v0.1.1

func (c *Client) Versions(ctx context.Context, name string, limit int) ([]Version, error)

Versions fetches version history for a gem. It returns at most limit items (pass 0 for all).

type Config added in v0.1.1

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds all tunable parameters for the Client.

func DefaultConfig added in v0.1.1

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Domain

type Domain struct{}

Domain is the rubygems driver.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify maps a gem name to (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, hostnames, and binary identity.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the rubygems.org page URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and operations onto app.

type Gem added in v0.1.1

type Gem struct {
	Rank        int    `json:"rank"`
	Name        string `json:"name"`
	Version     string `json:"version"`
	Downloads   int64  `json:"downloads"`
	Authors     string `json:"authors"`
	Info        string `json:"info"`
	HomepageURI string `json:"homepage_uri"`
	SourceURI   string `json:"source_uri"`
}

Gem is one Ruby gem record from rubygems.org.

type ReverseDep added in v0.1.1

type ReverseDep struct {
	Rank int    `json:"rank"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

ReverseDep is a gem that reverse-depends on the queried gem.

type Version added in v0.1.1

type Version struct {
	Rank      int    `json:"rank"`
	Number    string `json:"number"`
	CreatedAt string `json:"created_at"`
	Downloads int64  `json:"downloads"`
	RubyVer   string `json:"ruby_version"`
}

Version is one version record for a Ruby gem.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL