aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/caveats.rb
diff options
context:
space:
mode:
authorJack Nagel2013-01-12 13:08:29 -0600
committerJack Nagel2013-01-14 14:57:42 -0600
commit870f095c69df18d321a568b3d21cef09508ac4fd (patch)
treeb189f4249894cd34e14021807fd6150301078763 /Library/Homebrew/caveats.rb
parent2a4a3c3a9550e2f5170d92c37d0847374e877acf (diff)
downloadbrew-870f095c69df18d321a568b3d21cef09508ac4fd.tar.bz2
Restore keg-only caveats
Fixes Homebrew/homebrew#16989.
Diffstat (limited to 'Library/Homebrew/caveats.rb')
-rw-r--r--Library/Homebrew/caveats.rb64
1 files changed, 40 insertions, 24 deletions
diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb
index 411acac84..584904791 100644
--- a/Library/Homebrew/caveats.rb
+++ b/Library/Homebrew/caveats.rb
@@ -1,34 +1,51 @@
class Caveats
- def self.print f
- s = []
+ attr_reader :f
- unless f.caveats.to_s.strip.empty?
- s << f.caveats
- end
+ def initialize(f)
+ @f = f
+ end
+
+ def caveats
+ caveats = []
+ caveats << f.caveats
+ caveats << f.keg_only_text rescue nil if f.keg_only?
+ caveats << bash_completion_caveats
+ caveats << zsh_completion_caveats
+ caveats << plist_caveats
+ caveats.compact.join("\n")
+ end
+
+ def empty?
+ caveats.empty?
+ end
- keg = Keg.new(f.prefix) rescue nil
- keg ||= Keg.new(f.opt_prefix.realpath) rescue nil
- keg ||= Keg.new(f.linked_keg.realpath) rescue nil
+ private
- if keg and keg.completion_installed? :bash
- s << "\n" unless s.empty?
- s << <<-EOS.undent
- Bash completion has been installed to:
- #{HOMEBREW_PREFIX}/etc/bash_completion.d
- EOS
+ def keg
+ @keg ||= [f.prefix, f.opt_prefix, f.linked_keg].map do |d|
+ Keg.new(d.realpath) rescue nil
+ end.compact.first
+ end
+
+ def bash_completion_caveats
+ if keg and keg.completion_installed? :bash then <<-EOS.undent
+ Bash completion has been installed to:
+ #{HOMEBREW_PREFIX}/etc/bash_completion.d
+ EOS
end
+ end
- if keg and keg.completion_installed? :zsh
- s << "\n" unless s.empty?
- s << <<-EOS.undent
- zsh completion has been installed to:
- #{HOMEBREW_PREFIX}/share/zsh/site-functions
- EOS
+ def zsh_completion_caveats
+ if keg and keg.completion_installed? :zsh then <<-EOS.undent
+ zsh completion has been installed to:
+ #{HOMEBREW_PREFIX}/share/zsh/site-functions
+ EOS
end
+ end
+ def plist_caveats
+ s = []
if f.plist or (keg and keg.plist_installed?)
- s << "\n" unless s.empty?
-
destination = f.plist_startup ? '/Library/LaunchDaemons' \
: '~/Library/LaunchAgents'
@@ -79,7 +96,6 @@ class Caveats
end
end
end
-
- ohai 'Caveats', s unless s.empty?
+ s.join("\n") unless s.empty?
end
end