Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
fixed CRLF files problem trough linter
Browse files Browse the repository at this point in the history
  • Loading branch information
RONTEIX committed Jun 5, 2018
1 parent 9de2563 commit 2b74b37
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 93 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ module.exports = {
"semi": ["error", "always"],
"operator-linebreak": ["error", "before"],
"comma-dangle": ["error", "only-multiline"],
"linebreak-style": ["error", "unix"]
}
};
136 changes: 68 additions & 68 deletions lib/Command/Command.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
const CommandResponse = require('./CommandResponse');

module.exports = class Command {
constructor (name, logger) {
this.name = name;
this.logger = logger.child({subject: this.constructor.name});
}

isFake () {
return false;
}

getFullName () {
return this.name;
}

/**
* returns the connectors that supports the command. null for all commands.
* @return {ConnectorIO[]}
* @private
*/
getAvailableConnectors () {
return null;
}

/**
* returns true if this Command can handle the request.
* @param {CommandExchange} commandExchange
* @return boolean
*/
supports (commandExchange) {
return commandExchange.name === this.name;
}

/**
* verifies arguments of the command.
* @param {CommandExchange} commandExchange
* @return boolean
*/
validate (commandExchange) {
return false;
}

/**
* handles the command and writes to the connector output.
* @param {CommandExchange} commandExchange
*/
handle (commandExchange) {}

/**
* returns the usage message of the command.
* @return string
*/
usage () {
return this.name;
}

displayUsage (commandExchange) {
commandExchange.connector.write(
new CommandResponse(
`Usage : ${this.usage()}`,
commandExchange.sourceType,
commandExchange.recipient,
commandExchange.context
)
);
}
};
const CommandResponse = require('./CommandResponse');

module.exports = class Command {
constructor (name, logger) {
this.name = name;
this.logger = logger.child({subject: this.constructor.name});
}

isFake () {
return false;
}

getFullName () {
return this.name;
}

/**
* returns the connectors that supports the command. null for all commands.
* @return {ConnectorIO[]}
* @private
*/
getAvailableConnectors () {
return null;
}

/**
* returns true if this Command can handle the request.
* @param {CommandExchange} commandExchange
* @return boolean
*/
supports (commandExchange) {
return commandExchange.name === this.name;
}

/**
* verifies arguments of the command.
* @param {CommandExchange} commandExchange
* @return boolean
*/
validate (commandExchange) {
return false;
}

/**
* handles the command and writes to the connector output.
* @param {CommandExchange} commandExchange
*/
handle (commandExchange) {}

/**
* returns the usage message of the command.
* @return string
*/
usage () {
return this.name;
}

displayUsage (commandExchange) {
commandExchange.connector.write(
new CommandResponse(
`Usage : ${this.usage()}`,
commandExchange.sourceType,
commandExchange.recipient,
commandExchange.context
)
);
}
};
20 changes: 10 additions & 10 deletions lib/Command/CommandExchange.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module.exports = class CommandExchange {
constructor (name, args, connector, sourceType = null, recipient = null, context = {}) {
this.name = name;
this.args = args;
this.connector = connector;
this.sourceType = sourceType;
this.recipient = recipient;
this.context = context;
}
};
module.exports = class CommandExchange {
constructor (name, args, connector, sourceType = null, recipient = null, context = {}) {
this.name = name;
this.args = args;
this.connector = connector;
this.sourceType = sourceType;
this.recipient = recipient;
this.context = context;
}
};
30 changes: 15 additions & 15 deletions lib/Connector/ConnectorManager.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const EventEmitter = require('events');
const CommandExchange = require('../Command/CommandExchange');

module.exports = class ConnectorManager extends EventEmitter {
addConnector (connector) {
connector.setManager(this);
}

newCommand (commandExchange) {
if (!(commandExchange instanceof CommandExchange)) {
throw new Error();
}
this.emit('command', commandExchange);
}
};
const EventEmitter = require('events');
const CommandExchange = require('../Command/CommandExchange');

module.exports = class ConnectorManager extends EventEmitter {
addConnector (connector) {
connector.setManager(this);
}

newCommand (commandExchange) {
if (!(commandExchange instanceof CommandExchange)) {
throw new Error();
}
this.emit('command', commandExchange);
}
};

0 comments on commit 2b74b37

Please sign in to comment.