Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

Commit

Permalink
Avoid nil in URL specs
Browse files Browse the repository at this point in the history
  • Loading branch information
jacknagel committed Feb 12, 2013
1 parent 35c8a0c commit d396786
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
8 changes: 1 addition & 7 deletions Library/Homebrew/download_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
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
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ def build
@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
Expand All @@ -724,7 +724,7 @@ def devel &block
@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)
Expand Down
9 changes: 4 additions & 5 deletions Library/Homebrew/formula_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def initialize url=nil, version=nil
@url = url
@version = version
@mirrors = []
@specs = {}
end

def download_strategy
Expand Down Expand Up @@ -42,13 +43,11 @@ def #{cksum}(val=nil)
}
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
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/test/test_formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def test_formula_specs
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
Expand Down

0 comments on commit d396786

Please sign in to comment.