Permalink
Browse files

Get rid of all the syntax differences, well most of them.

  • Loading branch information...
1 parent 6cf8de6 commit d9fe3bb565d6b4eb57e6ce8a645fb2861c6d1f6e @larzconwell larzconwell committed Sep 25, 2012
View
@@ -99,27 +99,33 @@ opts = parser.opts;
opts.handle = opts.handlebars || opts.handle;
// Exit the process with a message
-die = function(str) {
+die = function (str) {
console.log(str);
process.exit();
};
// Start Geddy with options
-start = function() {
+start = function () {
geddy.config(opts);
geddy.start();
};
-if(opts.help) die(usage);
-if(opts.version) die(geddy.version);
+if (opts.help) {
+ die(usage);
+}
+if (opts.version) {
+ die(geddy.version);
+}
// `geddy app foo` or `geddy resource bar` etc. -- run generators
-if(cmds.length) {
+if (cmds.length) {
// Get templates Jake file
filepath = path.normalize(path.join(__dirname, '..', 'templates', 'Jakefile'));
// Wrap quotes in case path has spaces
- if(process.platform === 'win32') filepath = '"' + filepath + '"';
+ if (process.platform === 'win32') {
+ filepath = '"' + filepath + '"';
+ }
cmd = 'jake -t -f ' + filepath + ' ';
// If command isn't secret and has no other argument
@@ -128,21 +134,21 @@ if(cmds.length) {
}
// Add engines to command
- if(opts.jade) {
+ if (opts.jade) {
engineCmd = ',' + 'jade';
- } else if(opts.handle) {
+ } else if (opts.handle) {
engineCmd = ',' + 'handlebars';
- } else if(opts.mustache) {
+ } else if (opts.mustache) {
engineCmd = ',' + 'mustache';
} else engineCmd = '';
// Get the model properties
- if(cmds.slice(2).length > 0) {
+ if (cmds.slice(2).length > 0) {
modelCmd = ',' + cmds.slice(2).join(' ');
} else modelCmd = '';
// Add Jake argument based on commands
- switch(cmds[0]) {
+ switch (cmds[0]) {
case 'db:init':
// Create DBs
cmd += '"db:init"';
@@ -180,8 +186,8 @@ if(cmds.length) {
}
//cmd += ' --quiet';
- exec(cmd, function(err, stdout, stderr) {
- if(err) {
+ exec(cmd, function (err, stdout, stderr) {
+ if (err) {
throw err;
}
if (stderr) {
@@ -195,7 +201,7 @@ if(cmds.length) {
// Just `geddy` -- start the server
else {
// Search for 'config' directory in parent directories
- utils.file.searchParentPath('config', function(err, filePath) {
+ utils.file.searchParentPath('config', function (err, filePath) {
if (err) {
die(usage);
}
View
@@ -62,7 +62,7 @@ var App = function () {
fileName = dirList[i];
// Any files ending in '.js' or '.coffee'
if (JSPAT.test(fileName)) {
- if(fileName.match(/\.coffee$/)) {
+ if (fileName.match(/\.coffee$/)) {
// fileName is a CoffeeScript file so try to require it
usingCoffee = usingCoffee || utils.file.requireLocal('coffee-script');
}
@@ -154,7 +154,7 @@ var App = function () {
, createTemplates;
// Adds a template object to templates
- addTemplate = function(noExtFile, file, origFile, fileExt, fileBaseName) {
+ addTemplate = function (noExtFile, file, origFile, fileExt, fileBaseName) {
if(!origFile) origFile = noExtFile;
templates[origFile] = {
@@ -167,17 +167,19 @@ var App = function () {
};
// Read dir list and create template objects from each file
- createTemplates = function(dir, isGeddy) {
+ createTemplates = function (dir, isGeddy) {
for (var i = 0; i < dir.length; i++) {
file = dir[i];
fileExt = path.extname(file);
fileBaseName = path.basename(file, fileExt).replace(/\.html$/, '');
- if(isGeddy) origFile = 'geddy/' + fileBaseName;
+ if (isGeddy) {
+ origFile = 'geddy/' + fileBaseName;
+ }
- if(pat.test(file)) {
+ if (pat.test(file)) {
// Strip .html and extension for easier detecting when rendering
- if(isGeddy) {
+ if (isGeddy) {
noExtFile = 'geddy/' + fileBaseName;
} else noExtFile = file.replace(/\.html.*$/, '');
@@ -208,13 +210,13 @@ var App = function () {
, fileBaseName
, i = dirList.length;
- while(--i >= 0) {
+ while (--i >= 0) {
fileName = dirList[i];
fileExt = path.extname(fileName);
fileBaseName = path.basename(fileName, fileExt);
- if(fileBaseName === 'init') {
- if(fileExt === '.coffee') {
+ if (fileBaseName === 'init') {
+ if (fileExt === '.coffee') {
// fileName is a CoffeeScript file so try to require it
usingCoffee = usingCoffee || utils.file.requireLocal('coffee-script');
}
@@ -228,7 +230,7 @@ var App = function () {
// and run anything else that needs to be run after
// the server has started listening for requests
// ================================================
- , _afterStart = function(next) {
+ , _afterStart = function (next) {
geddy.server.listeners('request');
// Load socket.io if it's enabled. This gets run after
@@ -368,7 +370,7 @@ var App = function () {
, level = parseInt(stat, 10);
// Status code representation for logging
- if(level > 499) {
+ if (level > 499) {
level = 'error';
} else level = 'access';
@@ -432,7 +434,7 @@ var App = function () {
try {
bodyParams = JSON.parse(body);
}
- catch(e) {}
+ catch (e) {}
}
geddy.mixin(params, bodyParams);
req.body = body;
@@ -542,10 +544,10 @@ var App = function () {
else {
// 405?
nonMethodRoutes = router.all(reqUrl);
- if (nonMethodRoutes.length){
+ if (nonMethodRoutes.length) {
// build a unique list of acceptable methods for this resource
acceptableMethods = {};
- nonMethodRoutes.map(function(params){
+ nonMethodRoutes.map(function (params) {
acceptableMethods[params.method] = true;
});
acceptableMethods = Object.keys(acceptableMethods);
View
@@ -555,7 +555,9 @@ controller.BaseController.prototype = new (function () {
// Error during content negotiation may result in an error response, so
// - don't continue
- if (this.completed) return;
+ if (this.completed) {
+ return;
+ }
format = negotiated.format;
contentType = negotiated.contentType;
@@ -606,7 +608,9 @@ controller.BaseController.prototype = new (function () {
}
// If options.layout is set to `false` just set it
- if (typeof opts.layout === 'boolean' && !opts.layout) this.layout = opts.layout;
+ if (typeof opts.layout === 'boolean' && !opts.layout) {
+ this.layout = opts.layout;
+ }
// Hand content off to formatting along with callback for writing out
// the formatted respnse
View
@@ -79,7 +79,7 @@ Master.prototype = new (function () {
try {
fs.renameSync(currentLog, archivedLog);
}
- catch(e) {
+ catch (e) {
// Node 0.6-0.8 renameSync works correctly(Including Windows),
// but just in case.
file.cpR(currentLog, archivedLog);
@@ -139,7 +139,7 @@ Master.prototype = new (function () {
if (!data.killed) {
self.stderrLog.warning('Process ' +
worker.pid + ' took too long to retire, killing process.');
- if (now > (data.retireAt + self.config.rotationTimeout + 5000)){
+ if (now > (data.retireAt + self.config.rotationTimeout + 5000)) {
killWorker = true;
}
}
@@ -332,7 +332,7 @@ Master.prototype = new (function () {
//try {
process.kill(pid);
//}
- //catch(e) {}
+ //catch (e) {}
// handleWorkerExit gets called on the process die/exit event.
// If for some reason it doesn't get called, we still want
// the process removed from the list of active proceses
View
@@ -141,7 +141,7 @@ Worker.prototype = new (function () {
}
}
// Squelch, the process is going down anyhow
- catch(e) {}
+ catch (e) {}
});
}
}
@@ -157,7 +157,7 @@ Worker.prototype = new (function () {
// Squelch this too, the process is going down anyhow
this.server.close();
}
- catch(e) {} // Squelch this too
+ catch (e) {} // Squelch this too
};
this.startHeartbeat = function () {
View
@@ -9,7 +9,7 @@ var i18n = new (function () {
, defaultLocaleStrings = _strings[defaultLocale] || {}
, str = currentLocaleStrings[key]
|| defaultLocaleStrings[key] || "[[" + key + "]]";
- for (p in opts){
+ for (p in opts) {
str = str.replace(new RegExp('\\{' + p + '\\}', 'g'), opts[p]);
}
return str;
View
@@ -19,7 +19,7 @@ module.exports = new (function () {
// Create action helpers based on router
var i = router.routes.length;
- while(--i >= 0) {
+ while (--i >= 0) {
actionHelpers.create(router.routes[i].params);
}
actionHelpers.add(helpers); // Add action helpers to helpers
View
@@ -30,7 +30,7 @@ module.exports = new (function () {
data = fs.readFileSync(f).toString();
data = JSON.parse(data);
}
- catch(e) {
+ catch (e) {
throw new Error('Could not parse locale-data in file: ' +
f);
}
View
@@ -28,7 +28,7 @@ var Metric = function Metrics(messagePasser, eventType, type) {
this.newMetric(type, eventType);
}
-Metric.prototype.newMetric = function(type, eventType) {
+Metric.prototype.newMetric = function (type, eventType) {
if (geddy.config.metrics.namespace) {
eventType = geddy.config.metrics.namespace + "." + eventType;
}
@@ -39,7 +39,7 @@ Metric.prototype.newMetric = function(type, eventType) {
});
}
-Metric.prototype.forwardMessage = function(method, args) {
+Metric.prototype.forwardMessage = function (method, args) {
this.messagePasser.sendMessage({
method: 'updateMetric'
, metricMethod: method
@@ -50,22 +50,22 @@ Metric.prototype.forwardMessage = function(method, args) {
});
}
-Metric.prototype.update = function(val) { return this.forwardMessage('update', [val]); }
-Metric.prototype.mark = function(n) { return this.forwardMessage('mark', [n]); }
-Metric.prototype.inc = function(n) { return this.forwardMessage('inc', [n]); }
-Metric.prototype.dec = function(n) { return this.forwardMessage('dec', [n]); }
-Metric.prototype.clear = function() { return this.forwardMessage('clear'); }
+Metric.prototype.update = function (val) { return this.forwardMessage('update', [val]); }
+Metric.prototype.mark = function (n) { return this.forwardMessage('mark', [n]); }
+Metric.prototype.inc = function (n) { return this.forwardMessage('inc', [n]); }
+Metric.prototype.dec = function (n) { return this.forwardMessage('dec', [n]); }
+Metric.prototype.clear = function () { return this.forwardMessage('clear'); }
-module.exports.Counter = function(eventName) {
+module.exports.Counter = function (eventName) {
return new Metric(geddy.worker, eventName, 'counter');
}
-module.exports.Meter = function(eventName) {
+module.exports.Meter = function (eventName) {
return new Metric(geddy.worker, eventName, 'meter');
}
-module.exports.Histogram = function(eventName) {
+module.exports.Histogram = function (eventName) {
return new Metric(geddy.worker, eventName, 'histogram');
}
-module.exports.Timer = function(eventName) {
+module.exports.Timer = function (eventName) {
return new Metric(geddy.worker, eventName, 'timer');
}
Oops, something went wrong.

0 comments on commit d9fe3bb

Please sign in to comment.