Class: MacOSRequirement Private
- Inherits:
-
Requirement
- Object
- Requirement
- MacOSRequirement
- Defined in:
- requirements/macos_requirement.rb,
sorbet/rbi/dsl/mac_os_requirement.rbi
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.
TODO:when Yosemite is removed here, keep these around as empty arrays so we
can keep the deprecation/disabling code the same.
[ :yosemite, ].freeze
- 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.
[].freeze
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.
- #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 Attrable
Methods included from Dependable
#build?, #implicit?, #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.
19 20 21 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 |
# File 'requirements/macos_requirement.rb', line 19 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.
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'requirements/macos_requirement.rb', line 71 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.
125 126 127 128 129 130 131 132 133 134 135 |
# File 'requirements/macos_requirement.rb', line 125 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 |
#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.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'requirements/macos_requirement.rb', line 84 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.
64 65 66 67 68 69 |
# File 'requirements/macos_requirement.rb', line 64 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.
137 138 139 140 141 142 |
# File 'requirements/macos_requirement.rb', line 137 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.
51 52 53 |
# File 'requirements/macos_requirement.rb', line 51 def version_specified? @version.present? end |