Module: Dependable Private

Included in:
Dependency, Requirement
Defined in:
Library/Homebrew/dependable.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Shared functions for classes which can be depended upon.

Constant Summary collapse

RESERVED_TAGS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

:run and :linked are no longer used but keep them here to avoid them being misused in future.

[:build, :optional, :recommended, :run, :test, :linked].freeze

Instance Method Summary collapse

Instance Method Details

#build?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

13
14
15
# File 'Library/Homebrew/dependable.rb', line 13

def build?
  tags.include? :build
end

#option_tagsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


33
34
35
# File 'Library/Homebrew/dependable.rb', line 33

def option_tags
  tags - RESERVED_TAGS
end

#optional?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

17
18
19
# File 'Library/Homebrew/dependable.rb', line 17

def optional?
  tags.include? :optional
end

#optionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


37
38
39
# File 'Library/Homebrew/dependable.rb', line 37

def options
  Options.create(option_tags)
end

#prune_from_option?(build) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

41
42
43
44
45
# File 'Library/Homebrew/dependable.rb', line 41

def prune_from_option?(build)
  return if !optional? && !recommended?

  build.without?(self)
end

#prune_if_build_and_not_dependent?(dependent, formula = nil) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

47
48
49
50
51
52
# File 'Library/Homebrew/dependable.rb', line 47

def prune_if_build_and_not_dependent?(dependent, formula = nil)
  return false unless build?
  return dependent.installed? unless formula

  dependent != formula
end

#recommended?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

21
22
23
# File 'Library/Homebrew/dependable.rb', line 21

def recommended?
  tags.include? :recommended
end

#required?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

29
30
31
# File 'Library/Homebrew/dependable.rb', line 29

def required?
  !build? && !test? && !optional? && !recommended?
end

#test?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

25
26
27
# File 'Library/Homebrew/dependable.rb', line 25

def test?
  tags.include? :test
end