Skip to content

Commit

Permalink
utilized new function from utils to generate a regexp based on a max …
Browse files Browse the repository at this point in the history
…number supplied. resolves #8
  • Loading branch information
CiaranHannigan committed Aug 18, 2016
1 parent 1735740 commit 2e53be1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/scripts/service.bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = (robot) => {
prompt += '\n' + (i + 1) + ' - ' + serviceInstances[i].name;
}

var regex = new RegExp('([1-' + serviceInstances.length + ']+)');
var regex = utils.generateRegExpForNumberedList(serviceInstances.length);
utils.getExpectedResponse(res, robot, switchBoard, prompt, regex).then((selectionRes) => {
var selection = parseInt(selectionRes.match[1], 10);
var serviceInstanceIndex = parseInt(selection, 10);
Expand All @@ -107,7 +107,7 @@ module.exports = (robot) => {
}

// Prompt the user to select which app to unbind.
var regex = new RegExp('([1-' + apps.length + ']+)');
var regex = utils.generateRegExpForNumberedList(apps.length);
utils.getExpectedResponse(res, robot, switchBoard, prompt, regex).then((selectionRes) => {
selection = parseInt(selectionRes.match[1], 10);
var app = apps[selection - 1];
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/service.create.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module.exports = (robot) => {
prompt += '\n' + (i + 1) + ' - ' + plans[i].entity.name;
}

let regex = new RegExp('([1-' + plans.length + ']+)');
let regex = utils.generateRegExpForNumberedList(plans.length);
utils.getExpectedResponse(res, robot, switchBoard, prompt, regex).then((response) => {
var planIndex = parseInt(response.match[1], 10);

Expand Down Expand Up @@ -145,7 +145,7 @@ module.exports = (robot) => {
for (var i = 0; i < apps.length; i++) {
prompt += '\n' + (i + 1) + ' - ' + apps[i].name;
}
let regex = new RegExp('([1-' + apps.length + ']+)');
let regex = utils.generateRegExpForNumberedList(apps.length);
utils.getExpectedResponse(res, robot, switchBoard, prompt, regex).then((response) => {
// Selection made.
var appIndex = parseInt(response.match[1], 10);
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/service.unbind.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = (robot) => {
return;
}

var regex = new RegExp('([1-' + boundServices.length + ']+)');
var regex = utils.generateRegExpForNumberedList(boundServices.length);
utils.getExpectedResponse(res, robot, switchBoard, prompt, regex).then((response) => {
var selection = parseInt(response.match[1], 10);
var serviceInstanceIndex = parseInt(selection, 10);
Expand All @@ -127,7 +127,7 @@ module.exports = (robot) => {
}

// Prompt the user to select which app to unbind.
var regex = new RegExp('([1-' + appsBound.length + ']+)');
var regex = utils.generateRegExpForNumberedList(appsBound.length);
utils.getExpectedResponse(res, robot, switchBoard, prompt, regex).then((response) => {
selection = parseInt(response.match[1], 10);
var app = appsBound[selection - 1];
Expand Down

0 comments on commit 2e53be1

Please sign in to comment.