Small fixes to robot.js

This commit is contained in:
Andrew Stewart 2014-10-02 11:35:33 -07:00
parent a4498d0281
commit e74675d65a
1 changed files with 8 additions and 7 deletions

View File

@ -79,7 +79,7 @@ var Robot = module.exports = function Robot(opts) {
this.work = opts.work || opts.play; this.work = opts.work || opts.play;
if (!this.work) { if (!this.work) {
this.work = function() { Logger.debug("No work yet."); } this.work = function() { Logger.debug("No work yet."); };
} }
this.registerDefaults(); this.registerDefaults();
@ -153,13 +153,14 @@ Robot.randomName = function() {
// Returns an Object containing Robot data // Returns an Object containing Robot data
Robot.prototype.toJSON = function() { Robot.prototype.toJSON = function() {
var devices = [], var devices = [],
connections = []; connections = [],
n;
for (var n in this.connections) { for (n in this.connections) {
connections.push(this.connections[n]); connections.push(this.connections[n]);
} }
for (var n in this.devices) { for (n in this.devices) {
devices.push(this.devices[n]); devices.push(this.devices[n]);
} }
@ -257,7 +258,7 @@ Robot.prototype.start = function() {
if (!!err) { if (!!err) {
Logger.fatal("An error occured while trying to start the robot:"); Logger.fatal("An error occured while trying to start the robot:");
Logger.fatal(err); Logger.fatal(err);
if (typoef(this.error) === 'function') { if (typeof(this.error) === 'function') {
this.error.call(this, err); this.error.call(this, err);
} }
this.emit('error', err); this.emit('error', err);
@ -366,11 +367,11 @@ Robot.prototype.initAdaptor = function(adaptorName, connection, opts) {
extraParams: opts extraParams: opts
}); });
return Utils.proxyTestStubs(adaptor.commands, testAdaptor); Utils.proxyTestStubs(adaptor.commands, testAdaptor);
for (var prop in adaptor) { for (var prop in adaptor) {
if (typeof adaptor[prop] === 'function' && !testAdaptor[prop]) { if (typeof adaptor[prop] === 'function' && !testAdaptor[prop]) {
testAdaptor[prop] = function() { return true; } testAdaptor[prop] = function() { return true; };
} }
} }