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:



15
16
17
18
19
20
# File 'utils/cpan.rb', line 15

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:



28
29
30
31
# File 'utils/cpan.rb', line 28

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:



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

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:



23
24
25
# File 'utils/cpan.rb', line 23

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)


34
35
36
# File 'utils/cpan.rb', line 34

def valid_cpan_package?
  @is_cpan_url
end