Skip to content
Browse files

Return Formula objects from `outdated_brews`

Previously, `outdated_brews` returned a list of lists---each containing three
components of a Formula object:

  - f.rack
  - f.name
  - f.version

Frequently more information is required which necessitates back-casting from
`name` to a Formula object---simpy returning formula objects removes this step.
  • Loading branch information...
1 parent 06fbecb commit 00cd16f866fb341dcbcef6d8333d6bb030f03fee @Sharpie Sharpie committed Sep 11, 2011
Showing with 12 additions and 13 deletions.
  1. +6 −6 Library/Homebrew/cmd/outdated.rb
  2. +6 −7 Library/Homebrew/cmd/upgrade.rb
View
12 Library/Homebrew/cmd/outdated.rb
@@ -2,12 +2,12 @@
module Homebrew extend self
def outdated
- outdated_brews.each do |keg, name, version|
+ outdated_brews.each do |f|
if $stdout.tty? and not ARGV.flag? '--quiet'
- versions = keg.cd{ Dir['*'] }.join(', ')
- puts "#{name} (#{versions} < #{version})"
+ versions = f.rack.cd{ Dir['*'] }.join(', ')
+ puts "#{f.name} (#{versions} < #{f.version})"
else
- puts name
+ puts f.name
end
end
end
@@ -22,7 +22,7 @@ def outdated_brews
name = rack.basename.to_s
f = Formula.factory name rescue nil
- [rack, name, f.version] if f and not f.installed?
+ f if f and not f.installed?
end.compact
end
-end
+end
View
13 Library/Homebrew/cmd/upgrade.rb
@@ -14,24 +14,23 @@ def upgrade
outdated = if ARGV.named.empty?
Homebrew.outdated_brews
else
- ARGV.formulae.map do |f|
+ ARGV.formulae.each do |f|
raise "#{f} already upgraded" if f.installed?
raise "#{f} not installed" unless f.rack.exist? and not f.rack.children.empty?
- [f.rack, f.name, f.version]
end
end
if outdated.length > 1
oh1 "Upgrading #{outdated.length} outdated package#{outdated.length.plural_s}, with result:"
- puts outdated.map{ |_, name, version| "#{name} #{version}" } * ", "
+ puts outdated.map{ |f| "#{f.name} #{f.version}" } * ", "
end
- outdated.each do |rack, name, version|
- installer = FormulaInstaller.new(Formula.factory(name))
+ outdated.each do |f|
+ installer = FormulaInstaller.new f
installer.show_header = false
- oh1 "Upgrading #{name}"
+ oh1 "Upgrading #{f.name}"
installer.install
- Keg.new("#{rack}/#{version}").unlink
+ Keg.new("#{f.rack}/#{f.version}").unlink
installer.caveats
installer.finish # includes link step
end

0 comments on commit 00cd16f

Please sign in to comment.
Something went wrong with that request. Please try again.