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.

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:



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

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?
  raise UsageError, "`--version-arm` must not be empty." if arm.blank?
  raise UsageError, "`--version-intel` must not be empty." if 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:



8
9
10
# File 'bump_version_parser.rb', line 8

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:



8
9
10
# File 'bump_version_parser.rb', line 8

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:



8
9
10
# File 'bump_version_parser.rb', line 8

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)


48
49
50
# File 'bump_version_parser.rb', line 48

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:



39
40
41
42
43
44
45
# File 'bump_version_parser.rb', line 39

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
# 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)
  end
end