Don't return a version that equals the basename

Return nil instead
This commit is contained in:
Max Howell 2009-08-22 15:53:35 +01:00
parent c532d11e7a
commit f9d7b34945
2 changed files with 8 additions and 1 deletions

View File

@ -98,7 +98,7 @@ class Pathname
# we only support numbered tagged downloads # we only support numbered tagged downloads
%r[github.com/.*/tarball/((\d\.)+\d)$].match to_s %r[github.com/.*/tarball/((\d\.)+\d)$].match to_s
return $1 if $1 return $1 if $1
# eg. boost_1_39_0 # eg. boost_1_39_0
/((\d+_)+\d+)$/.match stem /((\d+_)+\d+)$/.match stem
return $1.gsub('_', '.') if $1 return $1.gsub('_', '.') if $1
@ -128,6 +128,8 @@ class Pathname
stem.scan /_([^_]+)/ do |match| stem.scan /_([^_]+)/ do |match|
return match.first if /\d/.match $1 return match.first if /\d/.match $1
end end
nil
end end
end end

View File

@ -196,6 +196,11 @@ class BeerTasting <Test::Unit::TestCase
end end
end end
def test_no_version
assert_nil Pathname.new("http://example.com/blah.tar").version
assert_nil Pathname.new("arse").version
end
def test_bad_version def test_bad_version
assert_raises(RuntimeError) {f=TestBadVersion.new} assert_raises(RuntimeError) {f=TestBadVersion.new}
end end