Class: Gem::Guardian::ChecksumProvider::SourceScoped
- Inherits:
-
Object
- Object
- Gem::Guardian::ChecksumProvider::SourceScoped
- Defined in:
- lib/gem/guardian/checksum_provider.rb
Overview
Restricts another checksum provider to dependencies resolved from a matching gem source.
This lets project configuration attach publisher checksum URLs to a
private registry without probing that URL for every public gem. Source
matching is prefix-based after trailing slashes are normalized, so a
configured source such as https://gems.contribsys.com/ matches locked
dependency sources under that registry.
Instance Method Summary collapse
-
#checksum_for(dependency, client:) ⇒ Result?
Delegated checksum result when the source matches, otherwise +nil+.
-
#initialize(source:, provider:) ⇒ SourceScoped
constructor
A new instance of SourceScoped.
Constructor Details
#initialize(source:, provider:) ⇒ SourceScoped
Returns a new instance of SourceScoped.
72 73 74 75 |
# File 'lib/gem/guardian/checksum_provider.rb', line 72 def initialize(source:, provider:) @source = normalize_source(source) @provider = provider end |
Instance Method Details
#checksum_for(dependency, client:) ⇒ Result?
Returns delegated checksum result when the source matches, otherwise +nil+.
80 81 82 83 84 |
# File 'lib/gem/guardian/checksum_provider.rb', line 80 def checksum_for(dependency, client:) return unless source_matches?(dependency.source) @provider.checksum_for(dependency, client:) end |