Permalink
Browse files

Modularize blacklists

  • Loading branch information...
etehtsea committed May 14, 2012
1 parent 035db4f commit 3e101756d1051b152454707a9a6d24428fea5399
Showing with 71 additions and 67 deletions.
  1. +60 −56 lib/homebrew/blacklist.rb
  2. +3 −3 lib/homebrew/cmd/create.rb
  3. +4 −4 lib/homebrew/cmd/install.rb
  4. +4 −4 lib/homebrew/cmd/search.rb
View
@@ -1,64 +1,68 @@
-def blacklisted? name
- case name.downcase
- when /^vim?$/, 'screen', /^rubygems?$/ then <<-EOS.undent
- Apple distributes #{name} with OS X, you can find it in /usr/bin.
- EOS
- when 'libarchive', 'libpcap' then <<-EOS.undent
- Apple distributes #{name} with OS X, you can find it in /usr/lib.
- EOS
- when 'libiconv' then <<-EOS.undent
- Apple distributes #{name} with OS X, you can find it in /usr/lib.
- Some build scripts fail to detect it correctly, please check existing
- formulae for solutions.
- EOS
- when 'libxml', 'libxlst' then <<-EOS.undent
- Apple distributes #{name} with OS X, you can find it in /usr/lib.
- However not all build scripts look for these hard enough, so you may need
- to call ENV.libxml2 in your formula's install function.
- EOS
- when 'freetype', 'libpng' then <<-EOS.undent
- Apple distributes #{name} with OS X, you can find it in /usr/X11/lib.
- However not all build scripts look here, so you may need to call ENV.x11
- in your formula's install function.
- EOS
- when 'wxwidgets' then <<-EOS.undent
- An old version of wxWidgets can be found in /usr/X11/lib. However, Homebrew
- does provide a newer version, 2.8.10:
+module Homebrew
+ module Blacklist
+ def self.include?(name)
+ case name.downcase
+ when /^vim?$/, 'screen', /^rubygems?$/; <<-EOS.undent
+ Apple distributes #{name} with OS X, you can find it in /usr/bin.
+ EOS
+ when 'libarchive', 'libpcap'; <<-EOS.undent
+ Apple distributes #{name} with OS X, you can find it in /usr/lib.
+ EOS
+ when 'libiconv'; <<-EOS.undent
+ Apple distributes #{name} with OS X, you can find it in /usr/lib.
+ Some build scripts fail to detect it correctly, please check existing
+ formulae for solutions.
+ EOS
+ when 'libxml', 'libxlst'; <<-EOS.undent
+ Apple distributes #{name} with OS X, you can find it in /usr/lib.
+ However not all build scripts look for these hard enough, so you may need
+ to call ENV.libxml2 in your formula's install function.
+ EOS
+ when 'freetype', 'libpng'; <<-EOS.undent
+ Apple distributes #{name} with OS X, you can find it in /usr/X11/lib.
+ However not all build scripts look here, so you may need to call ENV.x11
+ in your formula's install function.
+ EOS
+ when 'wxwidgets'; <<-EOS.undent
+ An old version of wxWidgets can be found in /usr/X11/lib. However, Homebrew
+ does provide a newer version, 2.8.10:
- brew install wxmac
- EOS
- when 'tex', 'tex-live', 'texlive' then <<-EOS.undent
- Installing TeX from source is weird and gross, requires a lot of patches,
- and only builds 32-bit (and thus can't use Homebrew deps on Snow Leopard.)
+ brew install wxmac
+ EOS
+ when 'tex', 'tex-live', 'texlive'; <<-EOS.undent
+ Installing TeX from source is weird and gross, requires a lot of patches,
+ and only builds 32-bit (and thus can't use Homebrew deps on Snow Leopard.)
- We recommend using a MacTeX distribution: http://www.tug.org/mactex/
- EOS
- when 'pip' then <<-EOS.undent
- Install pip with easy_install:
+ We recommend using a MacTeX distribution: http://www.tug.org/mactex/
+ EOS
+ when 'pip'; <<-EOS.undent
+ Install pip with easy_install:
- easy_install pip
- EOS
- when 'macruby' then <<-EOS.undent
- MacRuby works better when you install their package:
- http://www.macruby.org/downloads.html
+ easy_install pip
+ EOS
+ when 'macruby'; <<-EOS.undent
+ MacRuby works better when you install their package:
+ http://www.macruby.org/downloads.html
- Although if you prefer, there is a formula in homebrew-alt.
- EOS
- when 'npm' then <<-EOS.undent
- npm can be installed thusly by following the instructions at
- http://npmjs.org/
+ Although if you prefer, there is a formula in homebrew-alt.
+ EOS
+ when 'npm'; <<-EOS.undent
+ npm can be installed thusly by following the instructions at
+ http://npmjs.org/
- To do it in one line, use this command:
- curl http://npmjs.org/install.sh | sh
- EOS
- when /(lib)?lzma/
- "lzma is now part of the xz formula."
- when 'xcode' then <<-EOS.undent
- Xcode can be installed via the App Store (on Lion), or from:
- http://connect.apple.com/
+ To do it in one line, use this command:
+ curl http://npmjs.org/install.sh | sh
+ EOS
+ when /(lib)?lzma/
+ "lzma is now part of the xz formula."
+ when 'xcode'; <<-EOS.undent
+ Xcode can be installed via the App Store (on Lion), or from:
+ http://connect.apple.com/
- If you download from the App Store, make sure you run the installer
- placed in /Applications after the download completes.
- EOS
+ If you download from the App Store, make sure you run the installer
+ placed in /Applications after the download completes.
+ EOS
+ end
+ end
end
end
@@ -1,5 +1,5 @@
-require 'formula'
-require 'blacklist'
+require 'homebrew/formula'
+require 'homebrew/blacklist'
module Homebrew
module Cmd
@@ -30,7 +30,7 @@ def create
end
unless ARGV.force?
- if msg = blacklisted?(fc.name)
+ if msg = Blacklist.include?(fc.name)
raise "#{fc.name} is blacklisted for creation.\n#{msg}\nIf you really want to create this formula use --force."
end
@@ -1,6 +1,6 @@
-require 'formula_installer'
-require 'blacklist'
-require 'doctor'
+require 'homebrew/formula_installer'
+require 'homebrew/blacklist'
+require 'homebrew/doctor'
module Homebrew
module Cmd
@@ -9,7 +9,7 @@ def install
raise FormulaUnspecifiedError if ARGV.named.empty?
ARGV.named.each do |name|
- msg = blacklisted? name
+ msg = Blacklist.include? name
raise "No available formula for #{name}\n#{msg}" if msg
end unless ARGV.force?
@@ -1,5 +1,5 @@
-require "formula"
-require "blacklist"
+require 'homebrew/formula'
+require 'homebrew/blacklist'
module Homebrew
module Cmd
@@ -21,7 +21,7 @@ def search
search_results = search_brews rx
puts_columns search_results
- if not query.to_s.empty? and $stdout.tty? and msg = blacklisted?(query)
+ if not query.to_s.empty? and $stdout.tty? and msg = Blacklist.include?(query)
unless search_results.empty?
puts
puts "If you meant `#{query}' precisely:"
@@ -30,7 +30,7 @@ def search
puts msg
end
- if search_results.empty? and not blacklisted? query
+ if search_results.empty? and not Blacklist.include?(query)
puts "No formula found for \"#{query}\". Searching open pull requests..."
GitHub.find_pull_requests(rx) { |pull| puts pull }
end

0 comments on commit 3e10175

Please sign in to comment.