Clean up initialization methods for adaptors/drivers

This commit is contained in:
Andrew Stewart 2014-02-28 20:50:45 -08:00
parent 5650ce1d60
commit ef3aaf6591
1 changed files with 15 additions and 16 deletions

View File

@ -252,24 +252,23 @@ namespace("Cylon", function() {
//
// Returns the adaptor
Robot.prototype.initAdaptor = function(adaptorName, connection, opts) {
var realAdaptor, testAdaptor;
if (opts == null) {
opts = {};
}
realAdaptor = this.robot.requireAdaptor(adaptorName).adaptor({
if (opts == null) { opts = {}; }
var adaptor = this.robot.requireAdaptor(adaptorName).adaptor({
name: adaptorName,
connection: connection,
extraParams: opts
});
if (CylonConfig.testing_mode) {
testAdaptor = this.robot.requireAdaptor('test').adaptor({
var testAdaptor = this.robot.requireAdaptor('test').adaptor({
name: adaptorName,
connection: connection,
extraParams: opts
});
return proxyTestStubs(realAdaptor.commands(), testAdaptor);
return proxyTestStubs(adaptor.commands(), testAdaptor);
} else {
return realAdaptor;
return adaptor;
}
};
@ -306,24 +305,24 @@ namespace("Cylon", function() {
//
// Returns the new driver
Robot.prototype.initDriver = function(driverName, device, opts) {
var realDriver, testDriver;
if (opts == null) {
opts = {};
}
realDriver = this.robot.requireDriver(driverName).driver({
if (opts == null) { opts = {}; }
var driver = this.robot.requireDriver(driverName).driver({
name: driverName,
device: device,
extraParams: opts
});
if (CylonConfig.testing_mode) {
testDriver = this.robot.requireDriver('test').driver({
var testDriver = this.robot.requireDriver('test').driver({
name: driverName,
device: device,
extraParams: opts
});
return proxyTestStubs(realDriver.commands(), testDriver);
return proxyTestStubs(driver.commands(), testDriver);
} else {
return realDriver;
return driver;
}
};