This repository has been archived by the owner on May 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed CRLF files problem trough linter
- Loading branch information
RONTEIX
committed
Jun 5, 2018
1 parent
9de2563
commit 2b74b37
Showing
4 changed files
with
94 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}; |