2012-06-11 12:57:51 -07:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
module Homebrew extend self
|
|
|
|
def installed_brews
|
|
|
|
formulae = []
|
|
|
|
HOMEBREW_CELLAR.subdirs.each do |rack|
|
|
|
|
f = Formula.factory rack.basename.to_s rescue nil
|
2012-08-14 11:57:10 -05:00
|
|
|
formulae << f if f and f.rack.exist? and f.rack.subdirs.length > 0
|
2012-06-11 12:57:51 -07:00
|
|
|
end
|
|
|
|
formulae
|
|
|
|
end
|
|
|
|
|
2012-08-14 11:57:10 -05:00
|
|
|
def missing_deps ff
|
|
|
|
missing = {}
|
|
|
|
ff.each do |f|
|
|
|
|
missing_deps = f.recursive_deps.uniq.reject do |dep|
|
|
|
|
dep.rack.exist? and dep.rack.subdirs.length > 0
|
|
|
|
end
|
2012-06-11 12:57:51 -07:00
|
|
|
|
|
|
|
unless missing_deps.empty?
|
2012-08-14 11:57:10 -05:00
|
|
|
yield f.name, missing_deps if block_given?
|
|
|
|
missing[f.name] = missing_deps
|
2012-06-11 12:57:51 -07:00
|
|
|
end
|
|
|
|
end
|
2012-08-14 11:57:10 -05:00
|
|
|
missing
|
2012-06-11 12:57:51 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def missing
|
|
|
|
return unless HOMEBREW_CELLAR.exist?
|
|
|
|
|
2012-08-14 11:57:10 -05:00
|
|
|
ff = if ARGV.named.empty?
|
2012-06-11 12:57:51 -07:00
|
|
|
installed_brews
|
|
|
|
else
|
|
|
|
ARGV.formulae
|
|
|
|
end
|
|
|
|
|
2012-08-14 11:57:10 -05:00
|
|
|
missing_deps(ff) do |name, missing|
|
|
|
|
print "#{name}: " if ff.size > 1
|
2012-06-11 12:57:51 -07:00
|
|
|
puts "#{missing * ' '}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|