diff options
| author | Max Howell | 2010-09-11 20:22:54 +0100 |
|---|---|---|
| committer | Adam Vandenberg | 2011-03-12 11:55:02 -0800 |
| commit | 768910283a40afc2f76ef196d1464f0bbb2349cd (patch) | |
| tree | 0befe8fb3c3d8e967a34a29b11b6d85ecbfcbc9b /Library/Contributions | |
| parent | 97f654701d17c8605632a0d77570a2d9c6893ddf (diff) | |
| download | brew-768910283a40afc2f76ef196d1464f0bbb2349cd.tar.bz2 | |
Refactor the brew command into one file per command
The code was sucking. To the extent that maintenance was hard. It's a lot
easier to work with code that is sensibly split at sensible boundaries. So
now it is more like that.
But the refactor is minimal. Because we don't want you to have more merge
hell than absolutely necessary.
If you merge you will need to pay attention to brew.h.rb (as it is deleted)
and bin/brew (as command logic is gone). It will be painful, but you will just
have to help git out by moving any changes around manually.
Note compatibility.rb. It ensures that any function renames or removals don't
break anything. We're pretty serious about backwards compatibility. And that's
because we encourage you to hack around with the innards. And we couldn't do
that if we would then just make stuff disappear behind your back.
Diffstat (limited to 'Library/Contributions')
| -rwxr-xr-x | Library/Contributions/examples/brew-missing.rb | 17 | ||||
| -rwxr-xr-x | Library/Contributions/examples/brew-server | 1 | ||||
| -rwxr-xr-x | Library/Contributions/examples/brew-upgrade.rb | 10 |
3 files changed, 10 insertions, 18 deletions
diff --git a/Library/Contributions/examples/brew-missing.rb b/Library/Contributions/examples/brew-missing.rb index 68206278c..701bb1ca2 100755 --- a/Library/Contributions/examples/brew-missing.rb +++ b/Library/Contributions/examples/brew-missing.rb @@ -1,21 +1,18 @@ require "formula" -require 'formula_installer' +require "cmd/outdated" def main # Names of outdated brews; they count as installed. - outdated = outdated_brews.collect {|b| b[1]} + outdated = Homebrew.outdated_brews.collect{ |b| b[1] } - HOMEBREW_CELLAR.subdirs.each do |keg| - next unless keg.subdirs - if ((f = Formula.factory(keg.basename.to_s)).installed? rescue false) - f_deps = FormulaInstaller.expand_deps(f).collect{|g| g.name}.uniq - next if f_deps.empty? - - missing_deps = f_deps.reject do |dep_name| + HOMEBREW_CELLAR.subdirs.each do |rack| + f = Formula.factory rack.basename.to_s rescue nil + if f and f.installed? + missing_deps = f.recursive_deps.map{ |g| g.name }.uniq.reject do |dep_name| Formula.factory(dep_name).installed? or outdated.include?(dep_name) end - puts "#{f.name}: #{missing_deps.join(', ')}" unless missing_deps.empty? + puts "#{f.name}: #{missing_deps * ', '}" unless missing_deps.empty? end end end diff --git a/Library/Contributions/examples/brew-server b/Library/Contributions/examples/brew-server index b9919cf7a..5e7f80b58 100755 --- a/Library/Contributions/examples/brew-server +++ b/Library/Contributions/examples/brew-server @@ -82,7 +82,6 @@ get '/' do end get '/search' do - require 'brew.h' q = params['q'] results = search_brews(q) diff --git a/Library/Contributions/examples/brew-upgrade.rb b/Library/Contributions/examples/brew-upgrade.rb index 6c7831fde..3ffb570ac 100755 --- a/Library/Contributions/examples/brew-upgrade.rb +++ b/Library/Contributions/examples/brew-upgrade.rb @@ -1,11 +1,7 @@ # Updates all outdated brews # See: http://github.com/mxcl/homebrew/issues/issue/1324 -# patch ARGV to use all of the outdated packages as the names passed in -module HomebrewArgvExtension - def formulae - @formulae = outdated_brews.map {|_keg, name, _version| Formula.factory name} - end -end +require 'cmd/outdated' +require 'cmd/install' -brew_install +Homebrew.install_formulae Homebrew.outdated_brews.map{ |_keg, name, _version| Formula.factory name } |
