Class: Gem::Guardian::Registry
- Inherits:
-
Object
- Object
- Gem::Guardian::Registry
- Defined in:
- lib/gem/guardian/registry.rb
Overview
Enumerates gems visible through RubyGems-compatible registry sources.
This is intentionally a small library API rather than a supported CLI command.
It is useful for research scripts that want to inspect the latest gem entries
visible from the current Gem.sources configuration, including private
RubyGems-compatible registries such as GitHub Packages, Gemfury, CodeArtifact,
or self-hosted gem servers.
Defined Under Namespace
Classes: Entry
Instance Method Summary collapse
-
#each_latest_spec(limit: nil) ⇒ Object
Yields latest gem entries visible from the configured sources.
-
#initialize(sources: Gem.sources, spec_fetcher: nil) ⇒ Registry
constructor
A new instance of Registry.
-
#latest_specs(limit: nil) ⇒ Object
Returns latest gem entries visible from the configured sources.
Constructor Details
#initialize(sources: Gem.sources, spec_fetcher: nil) ⇒ Registry
Returns a new instance of Registry.
26 27 28 29 |
# File 'lib/gem/guardian/registry.rb', line 26 def initialize(sources: Gem.sources, spec_fetcher: nil) @sources = normalize_sources(sources) @spec_fetcher = spec_fetcher || Gem::SpecFetcher.new(@sources) end |
Instance Method Details
#each_latest_spec(limit: nil) ⇒ Object
Yields latest gem entries visible from the configured sources.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/gem/guardian/registry.rb', line 32 def each_latest_spec(limit: nil) return enum_for(:each_latest_spec, limit:) unless block_given? count = 0 latest_spec_tuples.each do |spec, source| break if limit && count >= limit yield build_entry(spec, source) count += 1 end end |
#latest_specs(limit: nil) ⇒ Object
Returns latest gem entries visible from the configured sources.
45 46 47 |
# File 'lib/gem/guardian/registry.rb', line 45 def latest_specs(limit: nil) each_latest_spec(limit:).to_a end |