Class: MacOSRequirement Private

Inherits:
Requirement show all
Extended by:
T::Sig
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

Constants included from Dependable

Dependable::RESERVED_TAGS

Instance Attribute Summary collapse

Attributes inherited from Requirement

#cask, #download, #name, #tags

Instance Method Summary collapse

Methods inherited from Requirement

#==, #env, env, #env_proc, expand, #fatal?, #hash, #mktemp, #modify_build_environment, #option_names, prune, prune?, #satisfied?, #satisfied_result_parent, satisfy

Methods included from BuildEnvironment::DSL

#env

Methods included from Cachable

#cache, #clear_cache

Methods included from Dependable

#build?, #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.



16
17
18
19
20
21
22
23
24
25
# File 'requirements/macos_requirement.rb', line 16

def initialize(tags = [], comparator: ">=")
  @version = if comparator == "==" && tags.first.respond_to?(:map)
    tags.shift.map { |s| MacOS::Version.from_symbol(s) }
  else
    MacOS::Version.from_symbol(tags.shift) unless tags.empty?
  end

  @comparator = comparator
  super(tags)
end

Instance Attribute Details

#comparatorObject (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.



14
15
16
# File 'requirements/macos_requirement.rb', line 14

def comparator
  @comparator
end

#versionObject (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.



14
15
16
# File 'requirements/macos_requirement.rb', line 14

def version
  @version
end

Instance Method Details

#display_sString

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:



71
72
73
74
75
76
77
78
79
80
81
# File 'requirements/macos_requirement.rb', line 71

def display_s
  if version_specified?
    if @version.respond_to?(:to_ary)
      "macOS #{@comparator} #{version.join(" / ")}"
    else
      "macOS #{@comparator} #{@version}"
    end
  else
    "macOS"
  end
end

#inspectString

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:



66
67
68
# File 'requirements/macos_requirement.rb', line 66

def inspect
  "#<#{self.class.name}: version#{@comparator}#{@version.to_s.inspect} #{tags.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.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'requirements/macos_requirement.rb', line 39

def message(type: :formula)
  return "macOS is required for this software." unless version_specified?

  case @comparator
  when ">="
    "macOS #{@version.pretty_name} or newer is required for this software."
  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 "macOS #{versions.join(", ")} or #{last} is required for this software."
    end

    "macOS #{@version.pretty_name} is required for this software."
  end
end

#to_json(*args) ⇒ 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.



83
84
85
86
87
88
# File 'requirements/macos_requirement.rb', line 83

def to_json(*args)
  comp = @comparator.to_s
  return { comp => @version.map(&:to_s) }.to_json(*args) if @version.is_a?(Array)

  { comp => [@version.to_s] }.to_json(*args)
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.

Returns:

  • (Boolean)


27
28
29
# File 'requirements/macos_requirement.rb', line 27

def version_specified?
  OS.mac? && @version
end