Class: KegOnlyReason

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
extend/os/mac/formula_support.rb,
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.



14
15
16
17
# File 'formula_support.rb', line 14

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

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason.



12
13
14
# File 'formula_support.rb', line 12

def reason
  @reason
end

Instance Method Details

#applicable?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'extend/os/mac/formula_support.rb', line 7

def applicable?
  true
end

#by_macos?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'formula_support.rb', line 31

def by_macos?
  provided_by_macos? || shadowed_by_macos?
end

#provided_by_macos?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'formula_support.rb', line 23

def provided_by_macos?
  @reason == :provided_by_macos
end

#shadowed_by_macos?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'formula_support.rb', line 27

def shadowed_by_macos?
  @reason == :shadowed_by_macos
end

#to_sObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'formula_support.rb', line 42

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)


19
20
21
# File 'formula_support.rb', line 19

def versioned_formula?
  @reason == :versioned_formula
end