Class: Utils::Bottles::Tag Private

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
utils/bottles.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.

Denotes the arch and OS of a bottle.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(system:, arch:) ⇒ 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.

Parameters:



151
152
153
154
# File 'utils/bottles.rb', line 151

def initialize(system:, arch:)
  @system = system
  @arch = arch
end

Instance Attribute Details

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



129
130
131
# File 'utils/bottles.rb', line 129

def arch
  @arch
end

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



129
130
131
# File 'utils/bottles.rb', line 129

def system
  @system
end

Class Method Details

.from_symbol(value) ⇒ T.attached_class

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.

Parameters:

Returns:

  • (T.attached_class)

Raises:

  • (ArgumentError)


132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'utils/bottles.rb', line 132

def self.from_symbol(value)
  return new(system: :all, arch: :all) if value == :all

  @all_archs_regex ||= begin
    all_archs = Hardware::CPU::ALL_ARCHS.map(&:to_s)
    /
      ^((?<arch>#{Regexp.union(all_archs)})_)?
      (?<system>[\w.]+)$
    /x
  end
  match = @all_archs_regex.match(value.to_s)
  raise ArgumentError, "Invalid bottle tag symbol" unless match

  system = match[:system].to_sym
  arch = match[:arch]&.to_sym || :x86_64
  new(system: system, arch: arch)
end

Instance Method Details

#==(other) ⇒ 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.



156
157
158
159
160
161
162
# File 'utils/bottles.rb', line 156

def ==(other)
  if other.is_a?(Symbol)
    to_sym == other
  else
    self.class == other.class && system == other.system && arch == other.arch
  end
end

#default_cellarString

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:



218
219
220
221
222
223
224
225
226
# File 'utils/bottles.rb', line 218

def default_cellar
  if linux?
    Homebrew::DEFAULT_LINUX_CELLAR
  elsif arch == :arm64
    Homebrew::DEFAULT_MACOS_ARM_CELLAR
  else
    Homebrew::DEFAULT_MACOS_CELLAR
  end
end

#default_prefixString

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:



207
208
209
210
211
212
213
214
215
# File 'utils/bottles.rb', line 207

def default_prefix
  if linux?
    HOMEBREW_LINUX_DEFAULT_PREFIX
  elsif arch == :arm64
    HOMEBREW_MACOS_ARM_DEFAULT_PREFIX
  else
    HOMEBREW_DEFAULT_PREFIX
  end
end

#eql?(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.

Returns:

  • (Boolean)


164
165
166
# File 'utils/bottles.rb', line 164

def eql?(other)
  self.class == other.class && self == other
end

#hashObject

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.



168
169
170
# File 'utils/bottles.rb', line 168

def hash
  [system, arch].hash
end

#linux?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)


194
195
196
# File 'utils/bottles.rb', line 194

def linux?
  system == :linux
end

#macos?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)


199
200
201
202
203
204
# File 'utils/bottles.rb', line 199

def macos?
  to_macos_version
  true
rescue MacOSVersionError
  false
end

#to_macos_versionOS::Mac::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.

Returns:



189
190
191
# File 'utils/bottles.rb', line 189

def to_macos_version
  @to_macos_version ||= OS::Mac::Version.from_symbol(system)
end

#to_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:



184
185
186
# File 'utils/bottles.rb', line 184

def to_s
  to_sym.to_s
end

#to_symSymbol

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:



173
174
175
176
177
178
179
180
181
# File 'utils/bottles.rb', line 173

def to_sym
  if system == :all && arch == :all
    :all
  elsif macos? && arch == :x86_64
    system
  else
    "#{arch}_#{system}".to_sym
  end
end