Class: Homebrew::BumpVersionParser Private

Inherits:
Object
  • Object
show all
Defined in:
bump_version_parser.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.

Class handling architecture-specific version information.

Constant Summary collapse

VERSION_SYMBOLS =

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

[:general, :arm, :intel].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(general: nil, arm: nil, intel: nil) ⇒ 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:

Raises:



17
18
19
20
21
22
23
24
# File 'bump_version_parser.rb', line 17

def initialize(general: nil, arm: nil, intel: nil)
  @general = T.let(parse_version(general), T.nilable(T.any(Version, Cask::DSL::Version))) if general.present?
  @arm = T.let(parse_version(arm), T.nilable(T.any(Version, Cask::DSL::Version))) if arm.present?
  @intel = T.let(parse_version(intel), T.nilable(T.any(Version, Cask::DSL::Version))) if intel.present?

  return if @general.present?
  raise UsageError, "`--version` must not be empty." if arm.blank? && intel.blank?
end

Instance Attribute Details

#armVersion, ... (readonly)

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:



10
11
12
# File 'bump_version_parser.rb', line 10

def arm
  @arm
end

#generalVersion, ... (readonly)

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:



10
11
12
# File 'bump_version_parser.rb', line 10

def general
  @general
end

#intelVersion, ... (readonly)

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:



10
11
12
# File 'bump_version_parser.rb', line 10

def intel
  @intel
end

Instance Method Details

#blank?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)


52
53
54
# File 'bump_version_parser.rb', line 52

def blank?
  @general.blank? && @arm.blank? && @intel.blank?
end

#parse_cask_version(version) ⇒ Cask::DSL::Version?

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:

Returns:



43
44
45
46
47
48
49
# File 'bump_version_parser.rb', line 43

def parse_cask_version(version)
  if version == "latest"
    Cask::DSL::Version.new(:latest)
  else
    Cask::DSL::Version.new(version)
  end
end

#parse_version(version) ⇒ Version, ...

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:

Returns:



30
31
32
33
34
35
36
37
38
39
40
# File 'bump_version_parser.rb', line 30

def parse_version(version)
  if version.is_a?(Version)
    version
  elsif version.is_a?(String)
    parse_cask_version(version)
  else
    # :nocov:
    T.absurd(version)
    # :nocov:
  end
end