Fix lame version, eg. 398-2

Included test this time!
This commit is contained in:
Max Howell 2009-09-11 12:51:36 +01:00
parent 111a75d262
commit d62fd87436
2 changed files with 13 additions and 1 deletions

View File

@ -96,6 +96,9 @@ class Pathname
out<<`du -hd0 #{to_s} | cut -d"\t" -f1`.strip
end
# attempts to retrieve the version component of this path, so generally
# you'll call it on tarballs or extracted tarball directories, if you add
# to this please provide amend the unittest
def version
if directory?
# directories don't have extnames
@ -118,6 +121,10 @@ class Pathname
/-((\d+\.)*\d\.\d+-p?\d+)$/.match stem
return $1 if $1
# eg. lame-398-1
/-((\d)+-\d)/.match stem
return $1 if $1
# eg. foobar-4.5.1
/-((\d+\.)*\d+)$/.match stem
return $1 if $1

View File

@ -374,6 +374,11 @@ class BeerTasting <Test::Unit::TestCase
assert_equal '0.1.9', d.version
end
def test_lame_version_style
f=MockFormula.new 'http://kent.dl.sourceforge.net/sourceforge/lame/lame-398-2.tar.gz'
assert_equal '398-2', f.version
end
def test_ruby_version_style
f=MockFormula.new 'ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz'
assert_equal '1.9.1-p243', f.version