Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added support for a _VERSION

  • Loading branch information...
commit 9236b3a6bc0af0448999bb6834c4de50ab5079d0 1 parent 7cd8dbe
@kikito authored
Showing with 14 additions and 5 deletions.
  1. +7 −5 semver.lua
  2. +7 −0 spec/semver_spec.lua
View
12 semver.lua
@@ -1,10 +1,10 @@
--- semver.lua - v1.0 (2012-01)
+-- semver.lua - v1.1.0 (2012-01)
-- Copyright (c) 2012 Enrique García Cota
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this 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 this 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.
-- See http://semver.org for details
-local version
+local version = {}
local function checkPositiveInteger(number, name)
assert(number >= 0, name .. ' must be a valid positive number')
@@ -149,9 +149,7 @@ function mt:__tostring()
return table.concat(buffer)
end
-
--- defined as local at the begining of the file
-version = function(major, minor, patch, prerelease, build)
+local function new(major, minor, patch, prerelease, build)
assert(major, "At least one parameter is needed")
if type(major) == 'string' then
@@ -168,4 +166,8 @@ version = function(major, minor, patch, prerelease, build)
return setmetatable(result, mt)
end
+setmetatable(version, { __call = function(_, ...) return new(...) end })
+
+version._VERSION = version('1.1.0')
+
return version
View
7 spec/semver_spec.lua
@@ -257,4 +257,11 @@ context('semver', function()
end)
end)
+ describe("_VERSION", function()
+ it("can be extracted from the lib", function()
+ local x = v._VERSION
+ assert_equal('table', type(x))
+ end)
+ end)
+
end)
Please sign in to comment.
Something went wrong with that request. Please try again.