aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2015-04-01 21:06:03 -0400
committerJack Nagel2015-04-01 21:15:18 -0400
commit7de2d56f5282de4a46452ea15da4f6063c1bbbb5 (patch)
treef0e4a916f86455a4fc5470f111f486f2f039c5fc /Library
parentf51439329ba86ae6bbb9c513b03ec4f3eb23ef43 (diff)
downloadbrew-7de2d56f5282de4a46452ea15da4f6063c1bbbb5.tar.bz2
Simplify versions code
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula_versions.rb31
1 files changed, 11 insertions, 20 deletions
diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb
index eb4334a62..563961b7f 100644
--- a/Library/Homebrew/formula_versions.rb
+++ b/Library/Homebrew/formula_versions.rb
@@ -7,22 +7,12 @@ class FormulaVersions
ErrorDuringExecution, LoadError,
]
- attr_reader :f
+ attr_reader :name, :repository, :entry_name
- def initialize(f)
- @f = f
- end
-
- def repository
- @repository ||= if f.tap?
- HOMEBREW_LIBRARY.join("Taps", f.tap)
- else
- HOMEBREW_REPOSITORY
- end
- end
-
- def entry_name
- @entry_name ||= f.path.relative_path_from(repository).to_s
+ def initialize(formula)
+ @name = formula.name
+ @repository = formula.tap? ? HOMEBREW_LIBRARY.join("Taps", formula.tap) : HOMEBREW_REPOSITORY
+ @entry_name = formula.path.relative_path_from(repository).to_s
end
def rev_list(branch="HEAD")
@@ -38,21 +28,22 @@ class FormulaVersions
end
def formula_at_revision(rev)
- FileUtils.mktemp(f.name) do
- path = Pathname.pwd.join("#{f.name}.rb")
+ FileUtils.mktemp(name) do
+ path = Pathname.pwd.join("#{name}.rb")
path.write file_contents_at_revision(rev)
+ old_const = Formulary.unload_formula(name)
+
begin
- old_const = Formulary.unload_formula(f.name)
nostdout { yield Formulary.factory(path.to_s) }
rescue *IGNORED_EXCEPTIONS => e
# We rescue these so that we can skip bad versions and
# continue walking the history
- ohai "#{e} in #{f.name} at revision #{rev}", e.backtrace if ARGV.debug?
+ ohai "#{e} in #{name} at revision #{rev}", e.backtrace if ARGV.debug?
rescue FormulaUnavailableError
# Suppress this error
ensure
- Formulary.restore_formula(f.name, old_const)
+ Formulary.restore_formula(name, old_const)
end
end
end