Skip to content

Commit

Permalink
Making the linter happy in a couple cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dallonf committed Sep 6, 2012
1 parent 155b3f3 commit cab4d47
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ var Server = require('./lib/server');

module.exports = function (config) {
return new Server(config);
}
};
16 changes: 8 additions & 8 deletions lib/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var parse = require('url').parse
, Script = require('./script');

/**
* A `Resource` handles incoming requests at a matched url. The base class is designed
* A `Resource` handles incoming requests at a matched url. The base class is designed
* to be extended by overriding methods that will be called by a `Router`.
*
* A `Resource` is also an `EventEmitter`. The following events are available.
Expand Down Expand Up @@ -58,9 +58,9 @@ function Resource(name, options) {
if(typeof instance.constructor.external[key] == 'function') {
instance.external[key] = function () {
instance.constructor.external[key].apply(instance, arguments);
}
};
}
})
});
}
}

Expand Down Expand Up @@ -99,7 +99,7 @@ Resource.prototype.parse = function (url) {
}

return parsed;
}
};

Resource.prototype.load = function (fn) {
var resource = this
Expand All @@ -126,7 +126,7 @@ Resource.prototype.load = function (fn) {
} else {
fn();
}
}
};

/**
* Handle an incoming request. This gets called by the router.
Expand Down Expand Up @@ -154,10 +154,10 @@ Resource.prototype.load = function (fn) {

Resource.prototype.handle = function (ctx, next) {
ctx.end();
}
};

/**
* Turn a resource constructor into an object ready
* Turn a resource constructor into an object ready
* for JSON. It should atleast include the `type`
* and `defaultPath`.
*/
Expand All @@ -167,7 +167,7 @@ Resource.toJSON = function() {
type: this.name,
defaultPath: '/my-resource'
};
}
};

/*!
* If true, generates utility functions for this resource in dpd.js
Expand Down
24 changes: 12 additions & 12 deletions lib/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var vm = require('vm')

function Script(src, path) {
try {
this.compiled = vm.createScript('(function() {' + src + '\n}).call(_this)', path);
this.compiled = vm.createScript('(function() {' + src + '\n}).call(_this)', path);
} catch(ex) {
this.error = ex;
}
Expand All @@ -35,11 +35,11 @@ Script.prototype.run = function (ctx, domain, fn) {
, events;

var scriptContext = {
this: {},
'this': {},
cancel: function(msg, status) {
if (!req.isRoot) {
var err = {message: msg, statusCode: status};
throw err;
throw err;
}
},
me: session && session.user,
Expand All @@ -55,9 +55,9 @@ Script.prototype.run = function (ctx, domain, fn) {
if(session.emitToAll) session.emitToAll(event, data);
}
}
}
};

scriptContext._this = scriptContext.this;
scriptContext._this = scriptContext['this'];
scriptContext._error = undefined;

events = new EventEmitter();
Expand Down Expand Up @@ -94,9 +94,9 @@ Script.prototype.run = function (ctx, domain, fn) {
// otherwise just merge the domain
Object.keys(domain).forEach(function (key) {
scriptContext[key] = domain[key];
})
});
}
scriptContext.this = scriptContext._this = domain.data;
scriptContext['this'] = scriptContext._this = domain.data;
}

var err;
Expand All @@ -112,8 +112,8 @@ Script.prototype.run = function (ctx, domain, fn) {
if (callbackCount <= 0) {
done(err);
}
})
}
});
};

Script.load = function(path, fn) {
fs.readFile(path, 'utf-8', function(err, val) {
Expand All @@ -123,11 +123,11 @@ Script.load = function(path, fn) {
fn(err);
}
});
}
};

function wrapError(err) {
if (err && err.__proto__ && global[err.__proto__.name]) {
err.__proto__ = global[err.__proto__.name].prototype;
err.__proto__ = global[err.__proto__.name].prototype;
}
return err;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ function wrapAsyncFunctions(asyncFunctions, sandbox, events, done, sandboxRoot)
if (sandboxRoot._error) return;
try {
callback.apply(sandboxRoot._this, arguments);
events.emit('finishCallback');
events.emit('finishCallback');
} catch (err) {
err = wrapError(err);
sandbox._error = err;
Expand Down
16 changes: 8 additions & 8 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ function extend(origin, add) {
* - `port` the server's port
*
* Properties:
*
*
* - `sessions` the servers `SessionStore`
* - `sockets` raw socket.io sockets
* - `db` the servers `Db` instance
*
* Example:
*
* var server = new Server({port: 3000, db: {host: 'localhost', port: 27015, name: 'my-db'}});
*
*
* server.listen();
*
* @param {Object} options
Expand Down Expand Up @@ -106,7 +106,7 @@ function Server(options) {
server.router = router;

server.resources = resourcesInstances;
router.route(req, res);
router.route(req, res);
});
}

Expand Down Expand Up @@ -144,15 +144,15 @@ util.inherits(Server, http.Server);

Server.prototype.listen = function(port, host) {
var server = this;
config.loadConfig('./', server, function(err, resourcesInstances) {
if (err) {
config.loadConfig('./', server, function(err, resourcesInstances) {
if (err) {
console.log();
console.log("Error loading resources: ");
console.log(err.stack || err);
process.exit();
} else {
server.resources = resourcesInstances;
http.Server.prototype.listen.call(server, port || server.options.port, host || server.options.host);
http.Server.prototype.listen.call(server, port || server.options.port, host || server.options.host);
}

});
Expand All @@ -166,11 +166,11 @@ Server.prototype.listen = function(port, host) {
*
* // Create a new server
* var server = new Server({port: 3000, db: {host: 'localhost', port: 27015, name: 'my-db'}});
*
*
* // Attach a store to the server
* var todos = server.createStore('todos');
*
* // Use the store to CRUD data
* // Use the store to CRUD data
* todos.insert({name: 'go to the store', done: true}, ...); // see `Store` for more info
*
* @param {String} namespace
Expand Down
6 changes: 3 additions & 3 deletions make.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var less = require('less');

target.all = function() {
target.dashboard();
}
};

target.dashboard = function() {
cd(__dirname);
Expand All @@ -18,7 +18,7 @@ target.dashboard = function() {
});

parser.parse(lessSource, function (e, tree) {
if (e) return console.error(e.message);
if (e) return console.error(e.message);
tree.toCSS().to('lib/resources/dashboard/stylesheets/style.css');
});

Expand All @@ -31,4 +31,4 @@ target.dashboard = function() {
// } else {
// result.output.to('lib/resources/dashboard/stylesheets/style.css')
// }
}
};

0 comments on commit cab4d47

Please sign in to comment.