Class: CPAN::Package Private

Inherits:
Object show all
Defined in:
utils/cpan.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Represents a Perl package from an existing resource.

Instance Method Summary collapse

Constructor Details

#initialize(resource_name, resource_url) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:



18
19
20
21
22
23
# File 'utils/cpan.rb', line 18

def initialize(resource_name, resource_url)
  @cpan_info = T.let(nil, T.nilable(T::Array[String]))
  @resource_name = resource_name
  @resource_url = resource_url
  @is_cpan_url = T.let(resource_url.start_with?(METACPAN_URL_PREFIX), T::Boolean)
end

Instance Method Details

#current_versionString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



31
32
33
34
# File 'utils/cpan.rb', line 31

def current_version
  extract_version_from_url if @current_version.blank?
  @current_version
end

#latest_cpan_infoArray<String>?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Get latest release information from MetaCPAN API.

Returns:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'utils/cpan.rb', line 43

def latest_cpan_info
  return @cpan_info if @cpan_info.present?
  return unless valid_cpan_package?

   = "https://fastapi.metacpan.org/v1/download_url/#{@resource_name}"
  result = Utils::Curl.curl_output(, "--location", "--fail")
  return unless result.status.success?

  begin
    json = JSON.parse(result.stdout)
  rescue JSON::ParserError
    return
  end

  download_url = json["download_url"]
  return unless download_url

  checksum = json["checksum_sha256"]
  return unless checksum

  @cpan_info = [@resource_name, download_url, checksum, json["version"]]
end

#nameString

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



26
27
28
# File 'utils/cpan.rb', line 26

def name
  @resource_name
end

#valid_cpan_package?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


37
38
39
# File 'utils/cpan.rb', line 37

def valid_cpan_package?
  @is_cpan_url
end