Formula.Enumerable
Deprecated Formula.all, replaced usage with more appropriate enumerable options. Just check out how much nicer `brew audit` runs now.
This commit is contained in:
parent
c5266654ff
commit
9274f7cda1
@ -6,7 +6,7 @@ require 'formula'
|
|||||||
|
|
||||||
def get_used_by
|
def get_used_by
|
||||||
used_by = {}
|
used_by = {}
|
||||||
Formula.all.each do |f|
|
Formula.each do |f|
|
||||||
next if f.deps == nil
|
next if f.deps == nil
|
||||||
|
|
||||||
f.deps.each do |dep|
|
f.deps.each do |dep|
|
||||||
|
@ -151,7 +151,7 @@ get '/formula/:name' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
used_by = Formula.all.select{|ff| ff.deps.include?(klass.name)}.map{|f| f.name}.flatten.uniq.sort
|
used_by = Formula.select{|ff| ff.deps.include?(klass.name)}.map{|f| f.name}.flatten.uniq.sort
|
||||||
unless used_by.empty?
|
unless used_by.empty?
|
||||||
s << <<-HTML
|
s << <<-HTML
|
||||||
<dt>Used by</td>
|
<dt>Used by</td>
|
||||||
@ -174,7 +174,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
def installed_formulas
|
def installed_formulas
|
||||||
Formula.all.select{|formula| formula.installed?}
|
Formula.select{|formula| formula.installed?}
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/installed' do
|
get '/installed' do
|
||||||
|
@ -8,7 +8,7 @@ module Homebrew extend self
|
|||||||
problem_count = 0
|
problem_count = 0
|
||||||
|
|
||||||
ff = if ARGV.named.empty?
|
ff = if ARGV.named.empty?
|
||||||
Formula.all
|
Formula
|
||||||
else
|
else
|
||||||
ARGV.formulae
|
ARGV.formulae
|
||||||
end
|
end
|
||||||
|
@ -707,7 +707,7 @@ def check_for_linked_keg_only_brews
|
|||||||
|
|
||||||
warnings = Hash.new
|
warnings = Hash.new
|
||||||
|
|
||||||
Formula.all.each do |f|
|
Formula.each do |f|
|
||||||
next unless f.keg_only? and f.installed?
|
next unless f.keg_only? and f.installed?
|
||||||
links = __check_linked_brew f
|
links = __check_linked_brew f
|
||||||
warnings[f.name] = links unless links.empty?
|
warnings[f.name] = links unless links.empty?
|
||||||
|
@ -3,11 +3,11 @@ require 'cmd/outdated'
|
|||||||
|
|
||||||
def ff
|
def ff
|
||||||
if ARGV.include? "--all"
|
if ARGV.include? "--all"
|
||||||
Formula.all
|
Formula
|
||||||
elsif ARGV.include? "--installed"
|
elsif ARGV.include? "--installed"
|
||||||
# outdated brews count as installed
|
# outdated brews count as installed
|
||||||
outdated = Homebrew.outdated_brews.collect{ |b| b.name }
|
outdated = Homebrew.outdated_brews.collect{ |b| b.name }
|
||||||
Formula.all.select do |f|
|
Formula.select do |f|
|
||||||
f.installed? or outdated.include? f.name
|
f.installed? or outdated.include? f.name
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -9,7 +9,7 @@ module Homebrew extend self
|
|||||||
def uses
|
def uses
|
||||||
raise FormulaUnspecifiedError if ARGV.named.empty?
|
raise FormulaUnspecifiedError if ARGV.named.empty?
|
||||||
|
|
||||||
uses = Formula.all.select do |f|
|
uses = Formula.select do |f|
|
||||||
ARGV.formulae.all? do |ff|
|
ARGV.formulae.all? do |ff|
|
||||||
if ARGV.flag? '--recursive'
|
if ARGV.flag? '--recursive'
|
||||||
f.recursive_deps.include? ff
|
f.recursive_deps.include? ff
|
||||||
|
@ -289,30 +289,23 @@ class Formula
|
|||||||
Dir["#{HOMEBREW_REPOSITORY}/Library/Formula/*.rb"].map{ |f| File.basename f, '.rb' }.sort
|
Dir["#{HOMEBREW_REPOSITORY}/Library/Formula/*.rb"].map{ |f| File.basename f, '.rb' }.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
# an array of all Formula, instantiated
|
|
||||||
def self.all
|
|
||||||
map{ |f| f }
|
|
||||||
end
|
|
||||||
def self.map
|
|
||||||
rv = []
|
|
||||||
each{ |f| rv << yield(f) }
|
|
||||||
rv
|
|
||||||
end
|
|
||||||
def self.each
|
def self.each
|
||||||
names.each do |n|
|
names.each do |name|
|
||||||
begin
|
yield begin
|
||||||
yield Formula.factory(n)
|
Formula.factory(name)
|
||||||
rescue
|
rescue => e
|
||||||
# Don't let one broken formula break commands. But do complain.
|
# Don't let one broken formula break commands. But do complain.
|
||||||
onoe "Formula #{n} will not import."
|
onoe "Failed to import: #{name}"
|
||||||
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
class << self
|
||||||
def self.select
|
include Enumerable
|
||||||
ff = []
|
end
|
||||||
each{ |f| ff << f if yield(f) }
|
def self.all
|
||||||
ff
|
opoo "Formula.all is deprecated, simply use Formula.map"
|
||||||
|
map
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.installed
|
def self.installed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user