aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorMike McQuaid2013-09-21 15:14:20 +0100
committerMike McQuaid2013-09-22 09:52:05 +0100
commit4702774616017af53d4f28bedad52e4a422c511e (patch)
tree1217f6f5d7d029d6bb71d854de1c2a93a57aea95 /Library/Homebrew/cmd
parent7531dfc21994a005a2d832b8c83eaa7ddd67a007 (diff)
downloadbrew-4702774616017af53d4f28bedad52e4a422c511e.tar.bz2
versions: split version_for_sha and use yield.
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/versions.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/Library/Homebrew/cmd/versions.rb b/Library/Homebrew/cmd/versions.rb
index 164222092..1dbe1a64a 100644
--- a/Library/Homebrew/cmd/versions.rb
+++ b/Library/Homebrew/cmd/versions.rb
@@ -81,6 +81,10 @@ class Formula
ArgumentError, FormulaSpecificationError]
def version_for_sha sha
+ formula_for_sha(sha) {|f| f.version }
+ end
+
+ def formula_for_sha sha, &block
mktemp do
path = Pathname.new(Pathname.pwd+"#{name}.rb")
path.write text_from_sha(sha)
@@ -88,7 +92,7 @@ class Formula
# Unload the class so Formula#version returns the correct value
begin
Formulary.unload_formula name
- nostdout { Formula.factory(path.to_s).version }
+ nostdout { yield Formula.factory(path.to_s) }
rescue *IGNORED_EXCEPTIONS => e
# We rescue these so that we can skip bad versions and
# continue walking the history