Merge pull request #2490 from retokromer/patch-1

add date-based versioning
This commit is contained in:
Mike McQuaid 2017-04-24 08:52:53 +01:00 committed by GitHub
commit 5b14d731ba
2 changed files with 10 additions and 0 deletions

View File

@ -433,6 +433,11 @@ describe Version do
.to be_detected_from("https://homebrew.bintray.com/bottles/imagemagick-6.7.5-7.lion.bottle.1.tar.gz")
end
specify "date-based version style" do
expect(Version.create("2017-04-17"))
.to be_detected_from("https://example.com/dada-v2017-04-17.tar.gz")
end
specify "dash version style" do
expect(Version.create("3.4"))
.to be_detected_from("http://www.antlr.org/download/antlr-3.4-complete.jar")

View File

@ -344,6 +344,11 @@ class Version
m = /[-v]((?:\d+\.)*\d+)$/.match(spec_s)
return m.captures.first unless m.nil?
# date-based versioning
# e.g. ltopers-v2017-04-14.tar.gz
m = /-v?(\d{4}-\d{2}-\d{2})/.match(stem)
return m.captures.first unless m.nil?
# e.g. lame-398-1
m = /-((?:\d)+-\d+)/.match(stem)
return m.captures.first unless m.nil?