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

#name, #tap

Attributes included from Dependable

#tags

Instance Method Summary collapse

Methods inherited from Dependency

action, expand, keep_but_prune_recursive_deps, merge_repeats, #missing_options, #option_names, 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 = [], bounds:) ⇒ void

Parameters:



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

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

  @bounds = bounds
end

Instance Attribute Details

#boundsObject (readonly)

Returns the value of attribute bounds.



233
234
235
# File 'dependency.rb', line 233

def bounds
  @bounds
end

Instance Method Details

#==(other) ⇒ Object



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

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, bounds: bounds)
end

#hashObject



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

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, minimum_revision: nil) ⇒ Boolean

Parameters:

  • minimum_version (Version, nil) (defaults to: nil)
  • minimum_revision (Integer, nil) (defaults to: nil)

Returns:

  • (Boolean)


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

def installed?(minimum_version: nil, minimum_revision: nil)
  use_macos_install? || super(minimum_version: minimum_version, minimum_revision: minimum_revision)
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