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.
[ :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
-
#==(other) ⇒ Object
(also: #eql?)
private
-
#display_s ⇒ String
private
-
#hash ⇒ Object
private
-
#initialize(tags = [], comparator: ">=") ⇒ MacOSRequirement
constructor
private
A new instance of MacOSRequirement.
-
#inspect ⇒ String
private
-
#message(type: :formula) ⇒ Object
private
-
#to_json(options) ⇒ Object
private
-
#version_specified? ⇒ Boolean
private
Methods inherited from Requirement
#env, env, #env_proc, expand, #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 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.
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 50 51 |
# File 'requirements/macos_requirement.rb', line 21 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.
12 13 14 |
# File 'requirements/macos_requirement.rb', line 12 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.
12 13 14 |
# File 'requirements/macos_requirement.rb', line 12 def version @version end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
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.
92 93 94 |
# File 'requirements/macos_requirement.rb', line 92 def ==(other) super(other) && comparator == other.comparator && version == other.version 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.
107 108 109 110 111 112 113 114 115 116 117 |
# File 'requirements/macos_requirement.rb', line 107 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 |
#hash ⇒ 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.
97 98 99 |
# File 'requirements/macos_requirement.rb', line 97 def hash [super, comparator, version].hash end |
#inspect ⇒ 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.
102 103 104 |
# File 'requirements/macos_requirement.rb', line 102 def inspect "#<#{self.class.name}: version#{@comparator}#{@version.to_s.inspect} #{.inspect}>" 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.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'requirements/macos_requirement.rb', line 66 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 |
#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.
119 120 121 122 123 124 |
# File 'requirements/macos_requirement.rb', line 119 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.
53 54 55 |
# File 'requirements/macos_requirement.rb', line 53 def version_specified? @version.present? end |