Class: Caveats Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
Library/Homebrew/caveats.rb,
Library/Homebrew/extend/os/mac/caveats.rb

Overview

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

A formula's caveats.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(f) ⇒ Caveats

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 a new instance of Caveats.


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

def initialize(f)
  @f = f
end

Instance Attribute Details

#fObject (readonly)

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.


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

def f
  @f
end

Instance Method Details

#caveatsObject

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.


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'Library/Homebrew/caveats.rb', line 17

def caveats
  caveats = []
  begin
    build = f.build
    f.build = Tab.for_formula(f)
    s = f.caveats.to_s
    caveats << "#{s.chomp}\n" unless s.empty?
  ensure
    f.build = build
  end
  caveats << keg_only_text
  caveats << function_completion_caveats(:bash)
  caveats << function_completion_caveats(:zsh)
  caveats << function_completion_caveats(:fish)
  caveats << plist_caveats
  caveats << elisp_caveats
  caveats.compact.join("\n")
end

#keg_only_text(skip_reason: false) ⇒ Object

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.


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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'Library/Homebrew/caveats.rb', line 38

def keg_only_text(skip_reason: false)
  return unless f.keg_only?

  s = if skip_reason
    ""
  else
    <<~EOS
      #{f.name} is keg-only, which means it was not symlinked into #{HOMEBREW_PREFIX},
      because #{f.keg_only_reason.to_s.chomp}.
    EOS
  end.dup

  if f.bin.directory? || f.sbin.directory?
    s << <<~EOS

      If you need to have #{f.name} first in your PATH run:
    EOS
    s << "  #{Utils::Shell.prepend_path_in_profile(f.opt_bin.to_s)}\n" if f.bin.directory?
    s << "  #{Utils::Shell.prepend_path_in_profile(f.opt_sbin.to_s)}\n" if f.sbin.directory?
  end

  if f.lib.directory? || f.include.directory?
    s << <<~EOS

      For compilers to find #{f.name} you may need to set:
    EOS

    s << "  #{Utils::Shell.export_value("LDFLAGS", "-L#{f.opt_lib}")}\n" if f.lib.directory?

    s << "  #{Utils::Shell.export_value("CPPFLAGS", "-I#{f.opt_include}")}\n" if f.include.directory?

    if which("pkg-config", ENV["HOMEBREW_PATH"]) &&
       ((f.lib/"pkgconfig").directory? || (f.share/"pkgconfig").directory?)
      s << <<~EOS

        For pkg-config to find #{f.name} you may need to set:
      EOS

      if (f.lib/"pkgconfig").directory?
        s << "  #{Utils::Shell.export_value("PKG_CONFIG_PATH", "#{f.opt_lib}/pkgconfig")}\n"
      end

      if (f.share/"pkgconfig").directory?
        s << "  #{Utils::Shell.export_value("PKG_CONFIG_PATH", "#{f.opt_share}/pkgconfig")}\n"
      end
    end
  end
  s << "\n"
end

#plist_caveatsObject

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.


142
143
144
145
146
147
148
149
150
151
# File 'Library/Homebrew/caveats.rb', line 142

def plist_caveats
  return unless f.plist_manual

  # Default to brew services not being supported. macOS overrides this behavior.
  <<~EOS
    #{Formatter.warning("Warning:")} #{f.name} provides a launchd plist which can only be used on macOS!
    You can manually execute the service instead with:
      #{f.plist_manual}
  EOS
end