Class: KegOnlyReason

Inherits:
Object
  • Object
show all
Defined in:
Library/Homebrew/formula_support.rb,
Library/Homebrew/extend/os/mac/formula_support.rb

Overview

Used to annotate formulae that duplicate macOS provided software or cause conflicts when linked in.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, explanation) ⇒ KegOnlyReason

Returns a new instance of KegOnlyReason.


11
12
13
14
# File 'Library/Homebrew/formula_support.rb', line 11

def initialize(reason, explanation)
  @reason = reason
  @explanation = explanation
end

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason


9
10
11
# File 'Library/Homebrew/formula_support.rb', line 9

def reason
  @reason
end

Instance Method Details

#applicable?Boolean

Returns:

  • (Boolean)

32
33
34
35
36
# File 'Library/Homebrew/formula_support.rb', line 32

def applicable?
  # macOS reasons aren't applicable on other OSs
  # (see extend/os/mac/formula_support for override on macOS)
  !by_macos?
end

#by_macos?Boolean

Returns:

  • (Boolean)

28
29
30
# File 'Library/Homebrew/formula_support.rb', line 28

def by_macos?
  provided_by_macos? || shadowed_by_macos?
end

#provided_by_macos?Boolean

Returns:

  • (Boolean)

20
21
22
# File 'Library/Homebrew/formula_support.rb', line 20

def provided_by_macos?
  @reason == :provided_by_macos
end

#shadowed_by_macos?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'Library/Homebrew/formula_support.rb', line 24

def shadowed_by_macos?
  @reason == :shadowed_by_macos
end

#to_sObject


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'Library/Homebrew/formula_support.rb', line 38

def to_s
  return @explanation unless @explanation.empty?

  if versioned_formula?
    <<~EOS
      this is an alternate version of another formula
    EOS
  elsif provided_by_macos?
    <<~EOS
      macOS already provides this software and installing another version in
      parallel can cause all kinds of trouble
    EOS
  elsif shadowed_by_macos?
    <<~EOS
      macOS provides similar software and installing this software in
      parallel can cause all kinds of trouble
    EOS
  else
    @reason
  end.strip
end

#versioned_formula?Boolean

Returns:

  • (Boolean)

16
17
18
# File 'Library/Homebrew/formula_support.rb', line 16

def versioned_formula?
  @reason == :versioned_formula
end