Class: KegOnlyReason

Inherits:
Object
  • Object
show all
Defined in:
Library/Homebrew/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



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

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

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason



7
8
9
# File 'Library/Homebrew/formula_support.rb', line 7

def reason
  @reason
end

Instance Method Details

#to_sObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'Library/Homebrew/formula_support.rb', line 33

def to_s
  return @explanation unless @explanation.empty?
  case @reason
  when :versioned_formula then <<-EOS.undent
    this is an alternate version of another formula
  EOS
  when :provided_by_macos, :provided_by_osx then <<-EOS.undent
    macOS already provides this software and installing another version in
    parallel can cause all kinds of trouble
  EOS
  when :shadowed_by_macos, :shadowed_by_osx then <<-EOS.undent
    macOS provides similar software and installing this software in
    parallel can cause all kinds of trouble
  EOS
  when :provided_pre_mountain_lion then <<-EOS.undent
    macOS already provides this software in versions before Mountain Lion
  EOS
  when :provided_pre_mavericks then <<-EOS.undent
    macOS already provides this software in versions before Mavericks
  EOS
  when :provided_pre_el_capitan then <<-EOS.undent
    macOS already provides this software in versions before El Capitan
  EOS
  when :provided_pre_high_sierra then <<-EOS.undent
    macOS already provides this software in versions before High Sierra
  EOS
  when :provided_until_xcode43 then <<-EOS.undent
    Xcode provides this software prior to version 4.3
  EOS
  when :provided_until_xcode5 then <<-EOS.undent
    Xcode provides this software prior to version 5
  EOS
  else
    @reason
  end.strip
end

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'Library/Homebrew/formula_support.rb', line 14

def valid?
  case @reason
  when :provided_pre_mountain_lion
    MacOS.version < :mountain_lion
  when :provided_pre_mavericks
    MacOS.version < :mavericks
  when :provided_pre_el_capitan
    MacOS.version < :el_capitan
  when :provided_pre_high_sierra
    MacOS.version < :high_sierra
  when :provided_until_xcode43
    MacOS::Xcode.installed? && MacOS::Xcode.version < "4.3"
  when :provided_until_xcode5
    MacOS::Xcode.installed? && MacOS::Xcode.version < "5.0"
  else
    true
  end
end