[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: New lib: semver.lua
- From: Enrique Garcia Cota <kikito@...>
- Date: Mon, 16 Jan 2012 10:55:12 +0100
(I don't know if it's ok to announce new libs on this list. If not, please accept my apologies)
I was looking for a way to handle semantic versions as specified in http://semver.org/
I could not find a lib that did that, so I created my own - It's available at https://github.com/kikito/semver.lua
Quick sneak peek:
local v = require 'semver'
local v1 = v(1,0,0)
local v1_5 = v('1.5.0')
local v2 = v'2.0.0' -- parents are optional for strings ...
local v2_alpha = v'2.0.0-alpha'
local v1_5_build_1 = v'1.5.0+build.1'
v1_5.major -- 1
v1_5.minor -- 5
v1_5.patch -- 0
v1_5_build_1.build -- 'build.1'
v1 < v1_5 -- true
v1 ^ v1_5 -- true, it's "safe to upgrade" from 1.0.0 to 1.5.0
v2_alpha < v2 -- true, prereleases go before official releases
v1_5 < v1_5_build_1 -- true, official releases go after builds
Most of the code in the lib is there to deal with the edge cases of handling and parsing prereleases and builds. The tests are inside the spec/ folder.
Let me know if you have any feedback/issues with it!