From 3a3a49bd93ee3a5a39019bb972a2a851ba2ab2f6 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Fri, 8 May 2015 18:59:08 +0800 Subject: [PATCH] add Formulary.core_path method, deprecate Formula.path --- Library/Homebrew/formula.rb | 5 +++-- Library/Homebrew/formulary.rb | 8 ++++++-- Library/Homebrew/test/test_formula.rb | 4 ++-- Library/Homebrew/test/testing_env.rb | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 285b47ff4b..822f17509f 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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 diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index f69912c9ff..e59a25cc71 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -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 diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index fbac071096..47f807333e 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -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 diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index 5f0406fb1b..d960d35d5a 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -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