add "split-version"

db4
Maximilian Lupke 2010-02-22 20:53:29 +01:00
parent 282f284515
commit b969f35e01
3 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1 @@
Maximilian Lupke

View File

@ -0,0 +1,5 @@
USING: semantic-versioning tools.test ;
IN: semantic-versioning.tests
[ { 1 0 0 "dev1" } ] [ "1.0.0dev1" split-version ] unit-test
[ { 1 2 3 } ] [ "1.2.3" split-version ] unit-test

View File

@ -0,0 +1,10 @@
! Copyright (C) 2010 Maximilian Lupke.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays ascii kernel math.parser sequences splitting ;
IN: semantic-versioning
: split-version ( string -- array )
"." split first3 dup [ digit? not ] find
[ cut [ [ string>number ] tri@ ] dip 4array ]
[ drop [ string>number ] tri@ 3array ]
if ;