Module: StillActive::ArtifactoryClient

Extended by:
ArtifactoryClient
Included in:
ArtifactoryClient
Defined in:
lib/still_active/artifactory_client.rb

Defined Under Namespace

Modules: AqlClient, RubygemsClient

Instance Method Summary collapse

Instance Method Details

#artifactory_uri?(uri) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/still_active/artifactory_client.rb', line 15

def artifactory_uri?(uri)
  # Hostnames are case-insensitive, so downcase before the suffix check; an
  # uppercase jfrog host would otherwise be misread as an unqueryable source.
  uri.is_a?(String) && URI(uri).host&.downcase&.end_with?(".jfrog.io")
rescue URI::InvalidURIError
  false
end

#versions(gem_name:, source_uri:) ⇒ Object

Version sources in precedence order:

1. the compact index, the only endpoint that lists what the repo can
 actually resolve (#142)
2. the versions API, for hosts that serve no compact index
3. AQL, a cache inventory, when neither answers

The compact index carries no timestamps, so a compact-index list is dated from the versions API.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/still_active/artifactory_client.rb', line 30

def versions(gem_name:, source_uri:)
  headers = auth_headers(gem_name: gem_name, source_uri: source_uri)
  compact = CompactIndexClient.versions(gem_name: gem_name, source_uri: source_uri, headers: headers)
  return dated(compact, gem_name: gem_name, source_uri: source_uri, headers: headers) unless compact.empty?

  vs = RubygemsClient.versions(gem_name: gem_name, source_uri: source_uri, headers: headers)
  return vs unless vs.empty?

  AqlClient.versions(gem_name: gem_name, source_uri: source_uri, headers: headers)
rescue Errno::ECONNRESET, Errno::ECONNREFUSED, Net::OpenTimeout, Net::ReadTimeout, SocketError
  []
end