Class: Homebrew::BumpVersionParser Private
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 platform-specific version information.
Constant Summary collapse
- VERSION_PLATFORMS =
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.
T.let({ arm: [:macos, :arm], intel: [:macos, :intel], linux_arm: [:linux, :arm], linux_intel: [:linux, :intel], }.freeze, T::Hash[Symbol, [Symbol, Symbol]])
- 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.
T.let([:general, *VERSION_PLATFORMS.keys].freeze, T::Array[Symbol])
- ParsedVersion =
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.
T.type_alias { T.nilable(T.any(Version, Cask::DSL::Version)) }
Instance Attribute Summary collapse
- #arm ⇒ ParsedVersion readonly private
- #general ⇒ ParsedVersion readonly private
- #intel ⇒ ParsedVersion readonly private
- #linux_arm ⇒ ParsedVersion readonly private
- #linux_intel ⇒ ParsedVersion readonly private
Instance Method Summary collapse
- #blank? ⇒ Boolean private
- #initialize(general: nil, arm: nil, intel: nil, linux_arm: nil, linux_intel: nil) ⇒ void constructor private
- #parse_cask_version(version) ⇒ Cask::DSL::Version? private
- #parse_version(version) ⇒ ParsedVersion private
Constructor Details
#initialize(general: nil, arm: nil, intel: nil, linux_arm: nil, linux_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.
26 27 28 29 30 31 32 33 34 35 |
# File 'bump_version_parser.rb', line 26 def initialize(general: nil, arm: nil, intel: nil, linux_arm: nil, linux_intel: nil) @general = T.let(parse_version(general), ParsedVersion) if general.present? @arm = T.let(parse_version(arm), ParsedVersion) if arm.present? @intel = T.let(parse_version(intel), ParsedVersion) if intel.present? @linux_arm = T.let(parse_version(linux_arm), ParsedVersion) if linux_arm.present? @linux_intel = T.let(parse_version(linux_intel), ParsedVersion) if linux_intel.present? return if @general.present? raise UsageError, "`--version` must not be empty." if [arm, intel, linux_arm, linux_intel].all?(&:blank?) end |
Instance Attribute Details
#arm ⇒ ParsedVersion (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.
17 18 19 |
# File 'bump_version_parser.rb', line 17 def arm @arm end |
#general ⇒ ParsedVersion (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.
17 18 19 |
# File 'bump_version_parser.rb', line 17 def general @general end |
#intel ⇒ ParsedVersion (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.
17 18 19 |
# File 'bump_version_parser.rb', line 17 def intel @intel end |
#linux_arm ⇒ ParsedVersion (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.
17 18 19 |
# File 'bump_version_parser.rb', line 17 def linux_arm @linux_arm end |
#linux_intel ⇒ ParsedVersion (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.
17 18 19 |
# File 'bump_version_parser.rb', line 17 def linux_intel @linux_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.
63 64 65 |
# File 'bump_version_parser.rb', line 63 def blank? @general.blank? && @arm.blank? && @intel.blank? && @linux_arm.blank? && @linux_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.
54 55 56 57 58 59 60 |
# File 'bump_version_parser.rb', line 54 def parse_cask_version(version) if version == "latest" Cask::DSL::Version.new(:latest) else Cask::DSL::Version.new(version) end end |
#parse_version(version) ⇒ ParsedVersion
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.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'bump_version_parser.rb', line 41 def parse_version(version) if version.is_a?(Version) version elsif version.is_a?(String) parse_cask_version(version) else # simplecov:disable T.absurd(version) # simplecov:enable end end |