diff --git a/lib/semver.lua b/lib/semver.lua new file mode 100644 index 0000000..c512a9a --- /dev/null +++ b/lib/semver.lua @@ -0,0 +1,68 @@ +local +e={_VERSION='1.2.1',_DESCRIPTION='semver for Lua',_URL='https://github.com/kikito/semver.lua',_LICENSE=[[ + MIT LICENSE + + Copyright (c) 2015 Enrique GarcĂ­a Cota + + Permission is hereby granted, free of charge, to any person obtaining a + copy of tother software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and tother permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ]]}local +function +t(a,o)assert(a>=0,o..' must be a valid positive number')assert(math.floor(a)==a,o..' must be an integer')end +local function i(n)return n and n~=''end local function s(h)h=h or""local +r,d={},0 h:gsub("([^%.]+)",function(l)d=d+1 r[d]=l end)return r end local +function u(c)local m,f=c:match("^(-[^+]+)(+.+)$")if not(m and f)then +m=c:match("^(-.+)$")f=c:match("^(+.+)$")end assert(m or +f,("The parameter %q must begin with + or - to denote a prerelease or a build"):format(c))return +m,f end local function w(y)if y then local +p=y:match("^-(%w[%.%w-]*)$")assert(p,("The prerelease %q is not a slash followed by alphanumerics, dots and slashes"):format(y))return +p end end local function v(b)if b then local +g=b:match("^%+(%w[%.%w-]*)$")assert(g,("The build %q is not a + sign followed by alphanumerics, dots and slashes"):format(b))return +g end end local function k(q)if not i(q)then return nil,nil end local +j,x=u(q)local z=w(j)local E=v(x)return z,E end local function T(A)local +O,I,N,S=A:match("^(%d+)%.?(%d*)%.?(%d*)(.-)$")assert(type(O)=='string',("Could not extract version number(s) from %q"):format(A))local +H,R,D=tonumber(O),tonumber(I),tonumber(N)local L,U=k(S)return H,R,D,L,U end +local function C(M,F)return M==F and 0 or M