diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 7d6f972621..37fb3cfc67 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -4,13 +4,7 @@ require 'vendor/multi_json' class AbstractDownloadStrategy def initialize name, package @url = package.url - @specs = package.specs - - case @specs - when Hash - @spec = @specs.keys.first # only use first spec - @ref = @specs.values.first - end + @spec, @ref = package.specs.dup.shift end def expand_safe_system_args args diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index d17bcb7b80..c007ac6c09 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -698,7 +698,7 @@ private @build ||= BuildOptions.new(ARGV.options_only) end - def url val=nil, specs=nil + def url val=nil, specs={} if val.nil? return @stable.url if @stable return @url if @url @@ -724,7 +724,7 @@ private @devel.instance_eval(&block) end - def head val=nil, specs=nil + def head val=nil, specs={} return @head if val.nil? @head ||= HeadSoftwareSpec.new @head.url(val, specs) diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index 0a5a62bb71..10be6ff635 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -9,6 +9,7 @@ class SoftwareSpec @url = url @version = version @mirrors = [] + @specs = {} end def download_strategy @@ -42,13 +43,11 @@ class SoftwareSpec } end - def url val=nil, specs=nil + def url val=nil, specs={} return @url if val.nil? @url = val - unless specs.nil? - @using = specs.delete :using - @specs = specs - end + @using = specs.delete(:using) + @specs.merge!(specs) end def version val=nil diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 0836dddd9d..50176a967e 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -82,9 +82,9 @@ class FormulaTests < Test::Unit::TestCase assert_equal 'file:///foo.com/testball-0.2.tbz', f.devel.url assert_equal 'https://github.com/mxcl/homebrew.git', f.head.url - assert_nil f.stable.specs - assert_nil f.bottle.specs - assert_nil f.devel.specs + assert_empty f.stable.specs + assert_empty f.bottle.specs + assert_empty f.devel.specs assert_equal({ :tag => 'foo' }, f.head.specs) assert_equal CurlDownloadStrategy, f.stable.download_strategy