Pass the requested spec into the formula instance
This commit is contained in:
parent
db9f16e2cd
commit
5beaa512e6
@ -26,7 +26,7 @@ class Formula
|
|||||||
|
|
||||||
attr_accessor :local_bottle_path
|
attr_accessor :local_bottle_path
|
||||||
|
|
||||||
def initialize(name, path)
|
def initialize(name, path, spec)
|
||||||
@name = name
|
@name = name
|
||||||
@path = path
|
@path = path
|
||||||
@homepage = self.class.homepage
|
@homepage = self.class.homepage
|
||||||
|
|||||||
@ -46,8 +46,8 @@ class Formulary
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Gets the formula instance.
|
# Gets the formula instance.
|
||||||
def get_formula
|
def get_formula(spec)
|
||||||
klass.new(name, path)
|
klass.new(name, path, spec)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return the Class for this formula, `require`-ing it if
|
# Return the Class for this formula, `require`-ing it if
|
||||||
@ -98,7 +98,7 @@ class Formulary
|
|||||||
super name, Formula.path(name)
|
super name, Formula.path(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_formula
|
def get_formula(spec)
|
||||||
formula = super
|
formula = super
|
||||||
formula.local_bottle_path = @bottle_filename
|
formula.local_bottle_path = @bottle_filename
|
||||||
formula
|
formula
|
||||||
@ -154,7 +154,7 @@ class Formulary
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_formula
|
def get_formula(spec)
|
||||||
fetch
|
fetch
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
@ -181,7 +181,7 @@ class Formulary
|
|||||||
super name, path
|
super name, path
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_formula
|
def get_formula(spec)
|
||||||
super
|
super
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
raise TapFormulaUnavailableError.new(tapped_name)
|
raise TapFormulaUnavailableError.new(tapped_name)
|
||||||
@ -194,8 +194,8 @@ class Formulary
|
|||||||
# * a formula pathname
|
# * a formula pathname
|
||||||
# * a formula URL
|
# * a formula URL
|
||||||
# * a local bottle reference
|
# * a local bottle reference
|
||||||
def self.factory ref
|
def self.factory(ref, spec=:stable)
|
||||||
loader_for(ref).get_formula
|
loader_for(ref).get_formula(spec)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.canonical_name(ref)
|
def self.canonical_name(ref)
|
||||||
|
|||||||
@ -6,8 +6,9 @@ class FormulaTests < Homebrew::TestCase
|
|||||||
klass = Class.new(Formula) { url "http://example.com/foo-1.0.tar.gz" }
|
klass = Class.new(Formula) { url "http://example.com/foo-1.0.tar.gz" }
|
||||||
name = "formula_name"
|
name = "formula_name"
|
||||||
path = Formula.path(name)
|
path = Formula.path(name)
|
||||||
|
spec = :stable
|
||||||
|
|
||||||
f = klass.new(name, path)
|
f = klass.new(name, path, spec)
|
||||||
assert_equal name, f.name
|
assert_equal name, f.name
|
||||||
assert_equal path, f.path
|
assert_equal path, f.path
|
||||||
assert_raises(ArgumentError) { klass.new }
|
assert_raises(ArgumentError) { klass.new }
|
||||||
@ -168,7 +169,7 @@ class FormulaTests < Homebrew::TestCase
|
|||||||
bottle { sha1 TEST_SHA1 => bottle_tag }
|
bottle { sha1 TEST_SHA1 => bottle_tag }
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
super "test", Pathname.new(__FILE__).expand_path
|
super "test", Pathname.new(__FILE__).expand_path, :stable
|
||||||
end
|
end
|
||||||
end.new
|
end.new
|
||||||
|
|
||||||
|
|||||||
@ -59,7 +59,7 @@ class InstallTests < Homebrew::TestCase
|
|||||||
url "file://#{File.expand_path(__FILE__)}"
|
url "file://#{File.expand_path(__FILE__)}"
|
||||||
version "1"
|
version "1"
|
||||||
def initialize
|
def initialize
|
||||||
super "test_script_formula", Pathname.new(__FILE__).expand_path
|
super "test_script_formula", Pathname.new(__FILE__).expand_path, :stable
|
||||||
end
|
end
|
||||||
end.new
|
end.new
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
require 'formula'
|
require 'formula'
|
||||||
|
|
||||||
class TestBall < Formula
|
class TestBall < Formula
|
||||||
def initialize(name="test_ball", path=Pathname.new(__FILE__).expand_path)
|
def initialize(name="test_ball", path=Pathname.new(__FILE__).expand_path, spec=:stable)
|
||||||
self.class.instance_eval do
|
self.class.instance_eval do
|
||||||
stable.url "file://#{TEST_DIRECTORY}/tarballs/testball-0.1.tbz"
|
stable.url "file://#{TEST_DIRECTORY}/tarballs/testball-0.1.tbz"
|
||||||
stable.sha1 "482e737739d946b7c8cbaf127d9ee9c148b999f5"
|
stable.sha1 "482e737739d946b7c8cbaf127d9ee9c148b999f5"
|
||||||
|
|||||||
@ -95,8 +95,8 @@ module Homebrew
|
|||||||
TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
|
TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
|
||||||
TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
|
TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
|
||||||
|
|
||||||
def formula(name="formula_name", path=Formula.path(name), &block)
|
def formula(name="formula_name", path=Formula.path(name), spec=:stable, &block)
|
||||||
@_f = Class.new(Formula, &block).new(name, path)
|
@_f = Class.new(Formula, &block).new(name, path, spec)
|
||||||
end
|
end
|
||||||
|
|
||||||
def shutup
|
def shutup
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user