Refer to Adaptor instances as 'Connection'

This commit is contained in:
Andrew Stewart 2014-11-14 10:56:45 -08:00
parent 4500824f30
commit 38bf5fdfed
5 changed files with 15 additions and 15 deletions

View File

@ -78,14 +78,14 @@ Basestar.prototype.defineAdaptorEvent = function(opts) {
return this._proxyEvents(opts, this.connector, this);
};
// Public: Creates an event handler that proxies events from an driver's
// adaptor to the driver
// Public: Creates an event handler that proxies events from a driver's
// connection to the driver
//
// opts - hash of opts to be passed to defineEvent()
//
// Returns this.connection
Basestar.prototype.defineDriverEvent = function(opts) {
return this._proxyEvents(opts, this.adaptor, this);
return this._proxyEvents(opts, this.connection, this);
};
Basestar.prototype._proxyEvents = function(opts, source, target) {

View File

@ -25,7 +25,7 @@ var Driver = module.exports = function Driver(opts) {
this.name = opts.name;
this.robot = opts.robot
this.adaptor = opts.adaptor
this.connection = opts.connection;
this.commands = {};
@ -72,7 +72,7 @@ Driver.prototype.toJSON = function() {
return {
name: this.name,
driver: this.constructor.name || this.name,
connection: this.adaptor.name,
connection: this.connection.name,
commands: Object.keys(this.commands),
details: this.details
};

View File

@ -229,10 +229,10 @@ Robot.prototype.initDevices = function(opts) {
process.emit('SIGINT');
}
device.adaptor = this.connections[device.connection];
device.connection = this.connections[device.connection];
} else {
for (var conn in this.connections) {
device.adaptor = this.connections[conn];
device.connection = this.connections[conn];
break;
}
}

View File

@ -137,7 +137,7 @@ describe('Basestar', function() {
beforeEach(function() {
basestar = new Basestar();
basestar.adaptor = new EventEmitter();
basestar.connection = new EventEmitter();
});
it("proxies events between the connection and device", function() {

View File

@ -7,16 +7,16 @@ var Driver = source("driver"),
Utils = source('utils');
describe("Driver", function() {
var adaptor, device, driver;
var connection, device, driver;
beforeEach(function() {
adaptor = {
adaptor: 'adaptor'
connection = {
connection: 'connection'
};
driver = new Driver({
name: 'driver',
adaptor: adaptor,
connection: connection,
});
});
@ -25,8 +25,8 @@ describe("Driver", function() {
expect(driver.name).to.be.eql('driver');
});
it("sets @adaptor to the provided adaptor", function() {
expect(driver.adaptor).to.be.eql(adaptor);
it("sets @connection to the provided connection", function() {
expect(driver.connection).to.be.eql(connection);
});
it("sets @commands to an empty object by default", function() {
@ -38,7 +38,7 @@ describe("Driver", function() {
driver = new Driver({
name: 'driver',
adaptor: adaptor,
connection: connection,
interval: 2000,
});