formula: add oldname method

- add Formula#oldname to get oldname for formula
- add formula_renames.rb to store information about formula renames
This commit is contained in:
Vlad Shablinsky 2015-08-09 14:46:07 +03:00 committed by Mike McQuaid
parent d88750652a
commit ae9bf4aaaa
2 changed files with 19 additions and 0 deletions

View File

@ -10,6 +10,7 @@ require "software_spec"
require "install_renamed"
require "pkg_version"
require "tap"
require "formula_renames"
# A formula provides instructions and metadata for Homebrew to install a piece
# of software. Every Homebrew formula is a {Formula}.
@ -223,6 +224,21 @@ class Formula
active_spec.resource(name)
end
# An old name for the formula
def oldname
@oldname ||= if core_formula?
if FORMULA_RENAMES && FORMULA_RENAMES.value?(name)
FORMULA_RENAMES.to_a.rassoc(name).first
end
elsif tap?
user, repo = tap.split("/")
formula_renames = Tap.new(user, repo.sub("homebrew-", "")).formula_renames
if formula_renames.value?(name)
formula_renames.to_a.rassoc(name).first
end
end
end
# The {Resource}s for the currently active {SoftwareSpec}.
def resources
active_spec.resources.values
@ -864,6 +880,7 @@ class Formula
"full_name" => full_name,
"desc" => desc,
"homepage" => homepage,
"oldname" => oldname,
"versions" => {
"stable" => (stable.version.to_s if stable),
"bottle" => bottle ? true : false,

View File

@ -0,0 +1,2 @@
FORMULA_RENAMES = {
}