Class: UsesFromMacOSDependency

Inherits:
Dependency show all
Defined in:
dependency.rb

Overview

A dependency that’s marked as “installed” on macOS

Constant Summary

Constants included from Dependable

Dependable::RESERVED_TAGS

Instance Attribute Summary collapse

Attributes inherited from Dependency

#env_proc, #name, #option_names, #tap

Attributes included from Dependable

#tags

Instance Method Summary collapse

Methods inherited from Dependency

#_dump, _load, action, expand, keep_but_prune_recursive_deps, merge_repeats, #missing_options, #modify_build_environment, prune, #satisfied?, skip, #to_formula, #to_s

Methods included from Cachable

#cache, #clear_cache

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(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name], bounds:) ⇒ UsesFromMacOSDependency

Returns a new instance of UsesFromMacOSDependency.



237
238
239
240
241
# File 'dependency.rb', line 237

def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name], bounds:)
  super(name, tags, env_proc, option_names)

  @bounds = bounds
end

Instance Attribute Details

#boundsObject (readonly)

Returns the value of attribute bounds.



235
236
237
# File 'dependency.rb', line 235

def bounds
  @bounds
end

Instance Method Details

#==(other) ⇒ Object



243
244
245
# File 'dependency.rb', line 243

def ==(other)
  instance_of?(other.class) && name == other.name && tags == other.tags && bounds == other.bounds
end

#dup_with_formula_name(formula) ⇒ T.self_type

Parameters:

Returns:

  • (T.self_type)


278
279
280
# File 'dependency.rb', line 278

def dup_with_formula_name(formula)
  self.class.new(formula.full_name.to_s, tags, env_proc, option_names, bounds: bounds)
end

#hashObject



247
248
249
# File 'dependency.rb', line 247

def hash
  [name, tags, bounds].hash
end

#inspectString

Returns:



283
284
285
# File 'dependency.rb', line 283

def inspect
  "#<#{self.class.name}: #{name.inspect} #{tags.inspect} #{bounds.inspect}>"
end

#installed?(minimum_version: nil) ⇒ Boolean

Returns:

  • (Boolean)


251
252
253
# File 'dependency.rb', line 251

def installed?(minimum_version: nil)
  use_macos_install? || super(minimum_version: minimum_version)
end

#use_macos_install?Boolean

Returns:

  • (Boolean)


256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'dependency.rb', line 256

def use_macos_install?
  # Check whether macOS is new enough for dependency to not be required.
  if Homebrew::SimulateSystem.simulating_or_running_on_macos?
    # Assume the oldest macOS version when simulating a generic macOS version
    return true if Homebrew::SimulateSystem.current_os == :macos && !bounds.key?(:since)

    if Homebrew::SimulateSystem.current_os != :macos
      current_os = MacOSVersion.from_symbol(Homebrew::SimulateSystem.current_os)
      since_os = MacOSVersion.from_symbol(bounds[:since]) if bounds.key?(:since)
      return true if current_os >= since_os
    end
  end

  false
end

#uses_from_macos?Boolean

Returns:

  • (Boolean)


273
274
275
# File 'dependency.rb', line 273

def uses_from_macos?
  true
end