2012-01-26 09:36:14 +00:00
|
|
|
var fs = require('fs');
|
2012-03-27 14:22:24 +00:00
|
|
|
var path = require('path');
|
2012-01-26 09:36:14 +00:00
|
|
|
|
2011-10-10 13:22:51 +00:00
|
|
|
exports.Schema = require('./lib/schema').Schema;
|
2013-03-24 21:35:08 +00:00
|
|
|
exports.AbstractClass = require('./lib/model.js').AbstractClass;
|
|
|
|
exports.Validatable = require('./lib/validations.js').Validatable;
|
2013-01-22 16:27:49 +00:00
|
|
|
|
|
|
|
var baseSQL = './lib/sql';
|
|
|
|
|
|
|
|
exports.__defineGetter__('BaseSQL', function () {
|
|
|
|
return require(baseSQL);
|
|
|
|
});
|
2012-01-10 13:26:24 +00:00
|
|
|
|
2012-10-28 23:21:51 +00:00
|
|
|
exports.init = function (rw) {
|
2012-12-16 12:50:30 +00:00
|
|
|
if (global.railway) {
|
2013-02-01 14:07:00 +00:00
|
|
|
global.railway.orm = exports;
|
2012-10-28 23:21:51 +00:00
|
|
|
} else {
|
|
|
|
rw.orm = {Schema: exports.Schema, AbstractClass: exports.AbstractClass};
|
|
|
|
}
|
2013-01-22 16:27:49 +00:00
|
|
|
var railway = './lib/railway';
|
2013-03-11 09:21:05 +00:00
|
|
|
|
|
|
|
if (rw.version > '1.1.5-15') {
|
|
|
|
rw.on('after routes', initialize);
|
|
|
|
} else {
|
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
function initialize() {
|
|
|
|
try {
|
|
|
|
var init = require(railway);
|
|
|
|
} catch (e) {}
|
|
|
|
if (init) init(rw);
|
|
|
|
}
|
2012-03-27 14:22:24 +00:00
|
|
|
};
|
|
|
|
|
2013-02-22 20:29:18 +00:00
|
|
|
exports.__defineGetter__('version', function () {
|
|
|
|
return JSON.parse(fs.readFileSync(__dirname + '/package.json')).version;
|
|
|
|
});
|
2012-04-18 23:20:44 +00:00
|
|
|
|
2013-01-22 16:27:49 +00:00
|
|
|
var commonTest = './test/common_test';
|
|
|
|
exports.__defineGetter__('test', function () {
|
|
|
|
return require(commonTest);
|
|
|
|
});
|