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
 | 
			
		||||
 | 
			
		||||
  def initialize(name, path)
 | 
			
		||||
  def initialize(name, path, spec)
 | 
			
		||||
    @name = name
 | 
			
		||||
    @path = path
 | 
			
		||||
    @homepage = self.class.homepage
 | 
			
		||||
 | 
			
		||||
@ -46,8 +46,8 @@ class Formulary
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Gets the formula instance.
 | 
			
		||||
    def get_formula
 | 
			
		||||
      klass.new(name, path)
 | 
			
		||||
    def get_formula(spec)
 | 
			
		||||
      klass.new(name, path, spec)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Return the Class for this formula, `require`-ing it if
 | 
			
		||||
@ -98,7 +98,7 @@ class Formulary
 | 
			
		||||
      super name, Formula.path(name)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def get_formula
 | 
			
		||||
    def get_formula(spec)
 | 
			
		||||
      formula = super
 | 
			
		||||
      formula.local_bottle_path = @bottle_filename
 | 
			
		||||
      formula
 | 
			
		||||
@ -154,7 +154,7 @@ class Formulary
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def get_formula
 | 
			
		||||
    def get_formula(spec)
 | 
			
		||||
      fetch
 | 
			
		||||
      super
 | 
			
		||||
    end
 | 
			
		||||
@ -181,7 +181,7 @@ class Formulary
 | 
			
		||||
      super name, path
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def get_formula
 | 
			
		||||
    def get_formula(spec)
 | 
			
		||||
      super
 | 
			
		||||
    rescue FormulaUnavailableError
 | 
			
		||||
      raise TapFormulaUnavailableError.new(tapped_name)
 | 
			
		||||
@ -194,8 +194,8 @@ class Formulary
 | 
			
		||||
  # * a formula pathname
 | 
			
		||||
  # * a formula URL
 | 
			
		||||
  # * a local bottle reference
 | 
			
		||||
  def self.factory ref
 | 
			
		||||
    loader_for(ref).get_formula
 | 
			
		||||
  def self.factory(ref, spec=:stable)
 | 
			
		||||
    loader_for(ref).get_formula(spec)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  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" }
 | 
			
		||||
    name = "formula_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 path, f.path
 | 
			
		||||
    assert_raises(ArgumentError) { klass.new }
 | 
			
		||||
@ -168,7 +169,7 @@ class FormulaTests < Homebrew::TestCase
 | 
			
		||||
      bottle { sha1 TEST_SHA1 => bottle_tag }
 | 
			
		||||
 | 
			
		||||
      def initialize
 | 
			
		||||
        super "test", Pathname.new(__FILE__).expand_path
 | 
			
		||||
        super "test", Pathname.new(__FILE__).expand_path, :stable
 | 
			
		||||
      end
 | 
			
		||||
    end.new
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -59,7 +59,7 @@ class InstallTests < Homebrew::TestCase
 | 
			
		||||
      url "file://#{File.expand_path(__FILE__)}"
 | 
			
		||||
      version "1"
 | 
			
		||||
      def initialize
 | 
			
		||||
        super "test_script_formula", Pathname.new(__FILE__).expand_path
 | 
			
		||||
        super "test_script_formula", Pathname.new(__FILE__).expand_path, :stable
 | 
			
		||||
      end
 | 
			
		||||
    end.new
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
require '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
 | 
			
		||||
      stable.url "file://#{TEST_DIRECTORY}/tarballs/testball-0.1.tbz"
 | 
			
		||||
      stable.sha1 "482e737739d946b7c8cbaf127d9ee9c148b999f5"
 | 
			
		||||
 | 
			
		||||
@ -95,8 +95,8 @@ module Homebrew
 | 
			
		||||
    TEST_SHA1   = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
 | 
			
		||||
    TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
 | 
			
		||||
 | 
			
		||||
    def formula(name="formula_name", path=Formula.path(name), &block)
 | 
			
		||||
      @_f = Class.new(Formula, &block).new(name, path)
 | 
			
		||||
    def formula(name="formula_name", path=Formula.path(name), spec=:stable, &block)
 | 
			
		||||
      @_f = Class.new(Formula, &block).new(name, path, spec)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def shutup
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user