Class: KegOnlyReason

Inherits:
Object
  • Object
show all
Defined in:
brew/Library/Homebrew/formula_support.rb,
brew/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 'brew/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 'brew/Library/Homebrew/formula_support.rb', line 9

def reason
  @reason
end

Instance Method Details

#to_sObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'brew/Library/Homebrew/formula_support.rb', line 20

def to_s
  return @explanation unless @explanation.empty?

  case @reason
  when :versioned_formula
    <<~EOS
      this is an alternate version of another formula
    EOS
  when :provided_by_macos
    <<~EOS
      macOS already provides this software and installing another version in
      parallel can cause all kinds of trouble
    EOS
  when :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

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  ![:provided_by_macos, :provided_by_osx, :shadowed_by_macos].include?(@reason)
end