Skip to content

Commit

Permalink
Created version module to provide additional version information
Browse files Browse the repository at this point in the history
  • Loading branch information
mikegerwitz committed Dec 23, 2011
1 parent 4627958 commit 958521f
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -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' );

39 changes: 39 additions & 0 deletions 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 <http://www.gnu.org/licenses/>.
*
* @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;
70 changes: 70 additions & 0 deletions 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 <http://www.gnu.org/licenses/>.
*
* @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'
);
},
} );
4 changes: 2 additions & 2 deletions test/test-index.js
Expand Up @@ -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( '../' );

Expand All @@ -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"
);

2 changes: 1 addition & 1 deletion tools/combine.tpl
Expand Up @@ -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 );

0 comments on commit 958521f

Please sign in to comment.