Class: MacOSRequirement Private
- Inherits:
-
Requirement
- Object
- Requirement
- MacOSRequirement
- Defined in:
- requirements/macos_requirement.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.
A requirement on macOS.
Constant Summary collapse
- DISABLED_MACOS_VERSIONS =
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.
Keep these around as empty arrays so we can keep the deprecation/disabling code the same. Treat these like odeprecated/odisabled in terms of deprecation/disabling.
T.let([].freeze, T::Array[Symbol])
- DEPRECATED_MACOS_VERSIONS =
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([ :mojave, :high_sierra, :sierra, :el_capitan, ].freeze, T::Array[Symbol])
Constants included from Dependable
Instance Attribute Summary collapse
- #comparator ⇒ Object readonly private
- #version ⇒ Object readonly private
Attributes inherited from Requirement
Attributes included from Dependable
Instance Method Summary collapse
- #allows?(other) ⇒ Boolean private
- #display_s ⇒ String private
-
#initialize(tags = [], comparator: ">=") ⇒ MacOSRequirement
constructor
private
A new instance of MacOSRequirement.
- #maximum_version ⇒ Object private
- #message(type: :formula) ⇒ Object private
- #minimum_version ⇒ Object private
- #to_json(options) ⇒ Object private
- #version_specified? ⇒ Boolean private
Methods inherited from Requirement
cask, download, #env, env, #env_proc, expand, fatal, #fatal?, #mktemp, #modify_build_environment, #option_names, prune, prune?, #satisfied?, #satisfied_result_parent, satisfy
Methods included from BuildEnvironment::DSL
Methods included from Cachable
Methods included from Utils::Output::Mixin
#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled
Methods included from Dependable
#build?, #implicit?, #no_linkage?, #option_names, #option_tags, #optional?, #options, #prune_from_option?, #prune_if_build_and_not_dependent?, #recommended?, #required?, #test?
Constructor Details
#initialize(tags = [], comparator: ">=") ⇒ MacOSRequirement
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 a new instance of MacOSRequirement.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'requirements/macos_requirement.rb', line 22 def initialize( = [], comparator: ">=") @version = begin if comparator == "==" && .first.respond_to?(:map) .first.map { |s| MacOSVersion.from_symbol(s) } else MacOSVersion.from_symbol(.first) unless .empty? end rescue MacOSVersion::Error => e if DISABLED_MACOS_VERSIONS.include?(e.version) # This odisabled should stick around indefinitely. odisabled "`depends_on macos: :#{e.version}`" elsif DEPRECATED_MACOS_VERSIONS.include?(e.version) # This odeprecated should stick around indefinitely. odeprecated "`depends_on macos: :#{e.version}`" else raise end # Array of versions: remove the bad ones and try again. if .first.respond_to?(:reject) = [.first.reject { |s| s == e.version }, [1..]] retry end # Otherwise fallback to the oldest allowed if comparator is >=. MacOSVersion.new(HOMEBREW_MACOS_OLDEST_ALLOWED) if comparator == ">=" end @comparator = comparator super(.drop(1)) end |
Instance Attribute Details
#comparator ⇒ Object (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.
10 11 12 |
# File 'requirements/macos_requirement.rb', line 10 def comparator @comparator end |
#version ⇒ Object (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.
10 11 12 |
# File 'requirements/macos_requirement.rb', line 10 def version @version end |
Instance Method Details
#allows?(other) ⇒ 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.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'requirements/macos_requirement.rb', line 81 def allows?(other) return true unless version_specified? case @comparator when ">=" then other >= @version when "<=" then other <= @version else return @version.include?(other) if @version.respond_to?(:to_ary) @version == other end end |
#display_s ⇒ 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.
135 136 137 138 139 140 141 142 143 144 145 |
# File 'requirements/macos_requirement.rb', line 135 def display_s if version_specified? if @version.respond_to?(:to_ary) "macOS #{@comparator} #{version.join(" / ")} (or Linux)" else "macOS #{@comparator} #{@version} (or Linux)" end else "macOS" end end |
#maximum_version ⇒ Object
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.
74 75 76 77 78 79 |
# File 'requirements/macos_requirement.rb', line 74 def maximum_version return MacOSVersion.new(HOMEBREW_MACOS_NEWEST_UNSUPPORTED) if @comparator == ">=" || !version_specified? return @version.max if @version.respond_to?(:to_ary) @version end |
#message(type: :formula) ⇒ Object
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.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'requirements/macos_requirement.rb', line 94 def (type: :formula) return "macOS is required for this software." unless version_specified? case @comparator when ">=" "This software does not run on macOS versions older than #{@version.pretty_name}." when "<=" case type when :formula <<~EOS This formula either does not compile or function as expected on macOS versions newer than #{@version.pretty_name} due to an upstream incompatibility. EOS when :cask "This cask does not run on macOS versions newer than #{@version.pretty_name}." end else if @version.respond_to?(:to_ary) *versions, last = @version.map(&:pretty_name) return "This software does not run on macOS versions other than #{versions.join(", ")} and #{last}." end "This software does not run on macOS versions other than #{@version.pretty_name}." end end |
#minimum_version ⇒ Object
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.
67 68 69 70 71 72 |
# File 'requirements/macos_requirement.rb', line 67 def minimum_version return MacOSVersion.new(HOMEBREW_MACOS_OLDEST_ALLOWED) if @comparator == "<=" || !version_specified? return @version.min if @version.respond_to?(:to_ary) @version end |
#to_json(options) ⇒ Object
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.
147 148 149 150 151 152 |
# File 'requirements/macos_requirement.rb', line 147 def to_json() comp = @comparator.to_s return { comp => @version.map(&:to_s) }.to_json() if @version.is_a?(Array) { comp => [@version.to_s] }.to_json() end |
#version_specified? ⇒ 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.
54 55 56 |
# File 'requirements/macos_requirement.rb', line 54 def version_specified? @version.present? end |