aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-02-11 20:50:52 -0600
committerJack Nagel2013-02-11 20:52:07 -0600
commitd39678612f1ce6d8971e764a01680dd92bc62b48 (patch)
tree95a73d4f9beb2c1fe0a576b0e2361df9ab7158a4 /Library
parent35c8a0c7fb3dc701b6c5eeafdb7623e20fbdc7b7 (diff)
downloadhomebrew-d39678612f1ce6d8971e764a01680dd92bc62b48.tar.bz2
Avoid nil in URL specs
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/download_strategy.rb8
-rw-r--r--Library/Homebrew/formula.rb4
-rw-r--r--Library/Homebrew/formula_support.rb9
-rw-r--r--Library/Homebrew/test/test_formula.rb6
4 files changed, 10 insertions, 17 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 7d6f97262..37fb3cfc6 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 d17bcb7b8..c007ac6c0 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 0a5a62bb7..10be6ff63 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 0836dddd9..50176a967 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