Skip to content

Commit c28a679

Browse files
committed
patch up code logic to handle dynamic core types (this will fix tests)
1 parent 4341b90 commit c28a679

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

main/autobot.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ var Handler = require('./autobot/handler');
22
var access = require('./lib/resource_accessor').access;
33
var Adapters = require('./autobot/adapters');
44
var googleCore = require('./autobot/core/core').google;
5+
var defaultCore = require('./autobot/core/core').default;
56

67
class Autobot {
7-
constructor(adapter) {
8+
constructor(adapter, coreType = 'default') {
89
var adapterClass = access(Adapters, adapter);
9-
this.adapter = new adapterClass(googleCore);
10+
if(coreType == 'google') { this.adapter = new adapterClass(googleCore); }
11+
else { this.adapter = new adapterClass(defaultCore); }
1012
}
1113

1214
receive(input, callback) {

main/autobot/adapters/cli.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class Cli extends Adapter {
3030
for more intelligent mapping.
3131
*/
3232
parse(input) {
33-
return parsePlankTimes(input);
34-
/*
35-
var tokens = input.trim().split(' ');
36-
return { command: tokens[0], args: tokens.slice(1) }
37-
*/
33+
if(this.core.type() == 'google') { return parsePlankTimes(input); }
34+
else if(this.core.type() == 'default') {
35+
var tokens = input.trim().split(' ');
36+
return { command: tokens[0], args: tokens.slice(1) }
37+
}
3838
}
3939

4040

main/autobot/core/core.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ class Core {
3333
return cmd(args);
3434
}
3535
}
36+
37+
type() {
38+
return access(this.commands, 'type').bind(this).call();
39+
}
3640
}
3741

3842
var defaultCommands = {
43+
type: function() { return 'default'; },
3944
/*
4045
A simple echo call.
4146
@@ -68,6 +73,8 @@ var defaultCommands = {
6873
}
6974

7075
var googleCommands = {
76+
type: function() { return 'google';},
77+
7178
get: function(args) {
7279
return this.resource.get(args);
7380
},

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"scripts": {
1818
"start": "node ./main/autobot/cli.js",
1919
"pretest": "rsync -av --ignore-existing ./configs/jira_credentials.js.example ./configs/jira_credentials.js",
20+
"pretest": "rsync -av --ignore-existing ./configs/user_mappings.js.example ./configs/user_mappings.js",
2021
"test": "mocha --recursive"
2122
},
2223
"dependencies": {

0 commit comments

Comments
 (0)