add Formulary.core_path method, deprecate Formula.path

This commit is contained in:
Xu Cheng 2015-05-08 18:59:08 +08:00
parent 3108fb5d22
commit 3a3a49bd93
4 changed files with 12 additions and 7 deletions

View File

@ -662,11 +662,12 @@ class Formula
# True if this formula is provided by Homebrew itself
def core_formula?
path == Formula.path(name)
path == Formulary.core_path(name)
end
# @deprecated
def self.path name
Pathname.new("#{HOMEBREW_LIBRARY}/Formula/#{name.downcase}.rb")
Formulary.core_path(name)
end
def env

View File

@ -182,7 +182,7 @@ class Formulary
class NullLoader < FormulaLoader
def initialize(name)
super name, Formula.path(name)
super name, Formulary.core_path(name)
end
def get_formula(spec)
@ -222,7 +222,7 @@ class Formulary
return FromPathLoader.new(ref)
end
formula_with_that_name = Formula.path(ref)
formula_with_that_name = core_path(ref)
if formula_with_that_name.file?
return FormulaLoader.new(ref, formula_with_that_name)
end
@ -239,4 +239,8 @@ class Formulary
return NullLoader.new(ref)
end
def self.core_path(name)
Pathname.new("#{HOMEBREW_LIBRARY}/Formula/#{name.downcase}.rb")
end
end

View File

@ -5,7 +5,7 @@ class FormulaTests < Homebrew::TestCase
def test_formula_instantiation
klass = Class.new(Formula) { url "http://example.com/foo-1.0.tar.gz" }
name = "formula_name"
path = Formula.path(name)
path = Formulary.core_path(name)
spec = :stable
f = klass.new(name, path, spec)
@ -174,7 +174,7 @@ class FormulaTests < Homebrew::TestCase
def test_path
name = 'foo-bar'
assert_equal Pathname.new("#{HOMEBREW_LIBRARY}/Formula/#{name}.rb"), Formula.path(name)
assert_equal Pathname.new("#{HOMEBREW_LIBRARY}/Formula/#{name}.rb"), Formulary.core_path(name)
end
def test_factory

View File

@ -67,7 +67,7 @@ module Homebrew
TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
def formula(name="formula_name", path=Formula.path(name), spec=:stable, &block)
def formula(name="formula_name", path=Formulary.core_path(name), spec=:stable, &block)
@_f = Class.new(Formula, &block).new(name, path, spec)
end