From 958521f67302b1673c42dbbea78efff54df5878d Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Fri, 23 Dec 2011 18:31:11 -0500 Subject: [PATCH] Created version module to provide additional version information --- index.js | 2 +- lib/version.js | 39 +++++++++++++++++++++++++ test/VersionTest.js | 70 +++++++++++++++++++++++++++++++++++++++++++++ test/test-index.js | 4 +-- tools/combine.tpl | 2 +- 5 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 lib/version.js create mode 100644 test/VersionTest.js diff --git a/index.js b/index.js index 63f9bb7..81a89e5 100644 --- a/index.js +++ b/index.js @@ -25,5 +25,5 @@ exports.Class = require( __dirname + '/lib/class' ); exports.AbstractClass = require( __dirname + '/lib/class_abstract' ); exports.FinalClass = require( __dirname + '/lib/class_final' ); exports.Interface = require( __dirname + '/lib/interface' ); -exports.version = '0.1.0'; +exports.version = require( __dirname + '/lib/version' ); diff --git a/lib/version.js b/lib/version.js new file mode 100644 index 0000000..a1693b4 --- /dev/null +++ b/lib/version.js @@ -0,0 +1,39 @@ +/** + * Provides version information + * + * Copyright (C) 2010,2011 Mike Gerwitz + * + * This file is part of ease.js. + * + * ease.js is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * @author Mike Gerwitz + */ + +var major = 0, + minor = 1, + rev = 0, + + version = [ major, minor, rev ]; + +version.major = major; +version.minor = minor; +version.rev = rev; + +version.toString = function() +{ + return this.join( '.' ); +}; + +module.exports = version; diff --git a/test/VersionTest.js b/test/VersionTest.js new file mode 100644 index 0000000..3161c74 --- /dev/null +++ b/test/VersionTest.js @@ -0,0 +1,70 @@ +/** + * Tests version.js + * + * Copyright (C) 2010,2011 Mike Gerwitz + * + * This file is part of ease.js. + * + * ease.js is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * @author Mike Gerwitz + */ + +require( 'common' ).testCase( +{ + caseSetUp: function() + { + this.version = this.require( 'version' ); + }, + + + 'Can retrieve major version number': function() + { + this.assertOk( typeof this.version.major === 'number', + 'Major version number should be available' + ); + }, + + + 'Can retrieve minor version number': function() + { + this.assertOk( typeof this.version.minor === 'number', + 'Minor version number should be available' + ); + }, + + + 'Can retrieve revision version number': function() + { + this.assertOk( typeof this.version.rev === 'number', + 'Revision version number should be available' + ); + }, + + + 'Array of version numbers is available': function() + { + this.assertEqual( this.version.major, this.version[ 0 ] ); + this.assertEqual( this.version.minor, this.version[ 1 ] ); + this.assertEqual( this.version.rev, this.version[ 2 ] ); + }, + + + 'Version string is available': function() + { + this.assertEqual( this.version.join( '.' ), this.version.toString(), + 'Version string should be made available' + ); + }, +} ); diff --git a/test/test-index.js b/test/test-index.js index 6ee23b6..807a624 100644 --- a/test/test-index.js +++ b/test/test-index.js @@ -28,6 +28,7 @@ var common = require( './common' ), AbstractClass = common.require( 'class_abstract' ), FinalClass = common.require( 'class_final' ), Interface = common.require( 'interface' ), + version = common.require( 'version' ), index = require( '../' ); @@ -52,8 +53,7 @@ assert.ok( "Interface should be made available" ); -assert.ok( - ( typeof index.version === 'string' ), +assert.ok( ( index.version === version ), "Version information should be exported" ); diff --git a/tools/combine.tpl b/tools/combine.tpl index b8972a9..3745b56 100644 --- a/tools/combine.tpl +++ b/tools/combine.tpl @@ -63,6 +63,6 @@ var easejs = {}; ns_exports.AbstractClass = module['class_abstract'].exports; ns_exports.FinalClass = module['class_final'].exports; ns_exports.Interface = module['interface'].exports; - ns_exports.version = '0.1.0'; + ns_exports.version = module['version'].exports; } )( easejs );