From 007b9e72d513c515f216cde4ae59ea37f826277b Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Sun, 9 Jan 2011 22:41:03 -0500 Subject: Adding version detection to sf.net /download urls SourceForge links can end with /download which appears to be part of what is used to drive mirror selection. Modifying the version detection extension of pathname.rb to detect this case for both sourceforge.net and sf.net download selections. This is sufficient for version detection but may not be sufficient for other uses of /download links. I have not found any problems with links that use /download, though. Signed-off-by: Adam Vandenberg --- Library/Homebrew/extend/pathname.rb | 7 ++++++- Library/Homebrew/test/test_versions.rb | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 5534cd752..1436e2e8e 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -105,7 +105,12 @@ class Pathname # directories don't have extnames stem=basename.to_s else - stem=self.stem + # sourceforge /download + if %r[((?:sourceforge.net|sf.net)/.*)/download$].match to_s + stem=Pathname.new(dirname).stem + else + stem=self.stem + end end # github tarballs, like v1.2.3 diff --git a/Library/Homebrew/test/test_versions.rb b/Library/Homebrew/test/test_versions.rb index 8010cf1c5..5e8783232 100644 --- a/Library/Homebrew/test/test_versions.rb +++ b/Library/Homebrew/test/test_versions.rb @@ -98,6 +98,11 @@ class VersionTests < Test::Unit::TestCase check "http://example.com/foo_bar-1.21.tar.gz", '1.21' end + def test_version_sourceforge_download + check "http://sourceforge.net/foo_bar-1.21.tar.gz/download", '1.21' + check "http://sf.net/foo_bar-1.21.tar.gz/download", '1.21' + end + def test_version_github check "http://github.com/lloyd/yajl/tarball/1.0.5", '1.0.5' end -- cgit v1.2.3