Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed deprecated ormDriver function from generators code #174

Merged
merged 1 commit into from Jun 4, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 5 additions & 17 deletions lib/generators.js
Expand Up @@ -203,7 +203,7 @@ exports.list = function () {
}
var fileExtension = options.coffee ? '.coffee' : '.js';
var Model = model[0].toUpperCase() + model.slice(1);
var attrs = [], result = [], driver = ormDriver();
var attrs = [], result = [];
options.forEach(function (arg) {
var property = arg.split(':')[0],
plainType = arg.split(':')[1],
Expand Down Expand Up @@ -331,7 +331,6 @@ exports.list = function () {
* @api public
*/
function crudGenerator(args) {
var driver = ormDriver();
var model = args[0].split('.').pop();
var parents = args[0].split('.').slice(0, -1);
var models = pluralize(model).toLowerCase();
Expand All @@ -351,7 +350,7 @@ exports.list = function () {
var result = modelGenerator.apply(this, Array.prototype.slice.call(arguments));

var fileExtension = options.coffee ? '.coffee' : '.js';
createFile('app/controllers/' + models + '_controller' + fileExtension, controllerCode(args[0], driver, result));
createFile('app/controllers/' + models + '_controller' + fileExtension, controllerCode(args[0], result));

createDir('app/helpers/');
createParents(ns, 'app/helpers/');
Expand Down Expand Up @@ -421,7 +420,7 @@ exports.list = function () {
* Get controller code
* @private
*/
function controllerCode(model, driver, result) {
function controllerCode(model, result) {
var fileExtension = options.coffee ? '.coffee' : '.js';
var code;
var parents = model.split('.').slice(0, -1);
Expand Down Expand Up @@ -690,26 +689,15 @@ exports.list = function () {
catch(e) {}
});
if (config != null) return config;
throw new Error( sys.format('Can not find configuration file by path template"%s"', filename) );
throw new Error( sys.format('Can not find configuration file by path template "%s"', filename) );
break;
case 'json':
return JSON.parse(require('fs').readFileSync(filename, 'utf8'));
return JSON.parse(fs.readFileSync(filename, 'utf8'));
case 'yml':
return require(filename).shift();
default:
throw new Error( sys.format('Unknown configuration file name extension "%s"', filenameExt) );
}
};

/**
* Return default ORM driver, based on config/database.json
* @deprecated
*/
function ormDriver() {
if (!ormDriver.config) {
ormDriver.config = loadConfig(process.cwd() + '/config/database.~').development;
}
return ormDriver.config.driver;
}

})();