Skip to content

Commit

Permalink
removed unnecessary debugs & excluded examples folder from linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mmacai committed Aug 10, 2016
1 parent 897221a commit 3a94cdf
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 30 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ coverage/**
node_modules/**
*.log
docs/**
examples/**
4 changes: 2 additions & 2 deletions examples/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const intentA = app.intent('intentA', 'clear my calendar for {date:Date}', (slot
});

// Or use built-in amazon intents. See: `examples/built-in-intents.js`
const intentB = app.intent('intentB', 'yes', () => {
const intentB = app.intent('intentB', 'yes', (slots, attrs) => {
// Clear calendar for date `attrs.date` here
return 'Your calendar has been cleared';
});
Expand All @@ -31,7 +31,7 @@ app.action({
from: intentA,
to: intentB,
if: (slots, attrs) => attrs.date, // Note: date should be validated here
fail: () => 'Sorry, your command is invalid'
fail: (slots, attrs) => 'Sorry, your command is invalid'
});

app.defaultActionFail(() => 'Sorry, your request is invalid');
Expand Down
4 changes: 2 additions & 2 deletions examples/spech-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const app = alexia.createApp('SpeechAssetsExample');

app.customSlot('Mood', ['fine', 'meh']);

app.intent('WhatsUpIntent', 'I am doing {mood:Mood}', () => {
app.intent('WhatsUpIntent', 'I am doing {mood:Mood}', (slots, attrs) => {
return 'Whatever you say';
});

app.intent('AwesomeIntent', 'You are awesome', () => {
app.intent('AwesomeIntent', 'You are awesome', (slots, attrs) => {
return 'Yes';
});

Expand Down
14 changes: 0 additions & 14 deletions src/create-app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';
const _ = require('lodash');
const debug = require('debug')('alexia:debug');
const error = require('debug')('alexia:error');
const info = require('debug')('alexia:info');
const handleRequest = require('./handle-request');
const createIntent = require('./create-intent');
const createCustomSlot = require('./create-custom-slot');
Expand Down Expand Up @@ -39,8 +37,6 @@ module.exports = (name, options) => {
* @param {function} handler - Handler to be called when app is started without intent
*/
app.onStart = (handler) => {
info('Setted up onStart handler');
debug(`Setted up onStart handler: "${handler}"`);
handlers.onStart = handler;
};

Expand All @@ -49,8 +45,6 @@ module.exports = (name, options) => {
* @param {function} handler - Handler to be called when application is unexpectedly terminated
*/
app.onEnd = (handler) => {
info('Setted up onEnd handler');
debug(`Setted up onEnd handler: "${handler}"`);
handlers.onEnd = handler;
};

Expand All @@ -59,8 +53,6 @@ module.exports = (name, options) => {
* @param {function} handler - Default handler to be called when action can not be invoked
*/
app.defaultActionFail = (handler) => {
info('Setted up defaultActionFail handler');
debug(`Setted up defaultActionFail handler: "${handler}"`);
handlers.defaultActionFail = handler;
};

Expand All @@ -73,8 +65,6 @@ module.exports = (name, options) => {
app.intent = (name, richUtterances, handler) => {
const intent = createIntent(app.intents, name, richUtterances, handler);
app.intents[intent.name] = intent;
info(`Created intent "${intent.name}"`);
debug(`Created intent: "${JSON.stringify(intent)}"`);

return intent;
};
Expand Down Expand Up @@ -119,8 +109,6 @@ module.exports = (name, options) => {
app.customSlot = (name, samples) => {
const customSlot = createCustomSlot(app.customSlots, name, samples);
app.customSlots[name] = customSlot;
info(`Created customSlot "${name}"`);
debug(`Created customSlot: "${JSON.stringify(customSlot)}"`);
};

/**
Expand All @@ -138,8 +126,6 @@ module.exports = (name, options) => {
if: action.if,
fail: action.fail
});
info('Created action');
debug(`Created action: "${JSON.stringify(action)}"`);
};

/**
Expand Down
6 changes: 0 additions & 6 deletions src/generate-speech-assets.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';
const _ = require('lodash');
const debug = require('debug')('alexia:debug');
const info = require('debug')('alexia:info');

module.exports = (app) => {
let assets = {
Expand All @@ -12,7 +10,6 @@ module.exports = (app) => {

assets.toString = createStringifyAssets(assets);

info('Assets created');
return assets;
};

Expand Down Expand Up @@ -65,7 +62,6 @@ const genIntentSchema = (intents) => {
intentSchema.intents.push(currentSchema);
});

debug(`Generated intentSchema: "${JSON.stringify(intentSchema)}"`); // TODO
return JSON.stringify(intentSchema, null, 2);
};

Expand All @@ -84,7 +80,6 @@ const genUtterances = (intents) => {
});
});

debug(`Generated utterances: "${JSON.stringify(sampleUtterances)}"`); // TODO
return sampleUtterances.join('\n');
};

Expand All @@ -99,6 +94,5 @@ const genCustomSlots = (customSlots) => {
allCustomSlotSamples[customSlot.name] = customSlot.samples;
});

debug(`Generated customSlots: "${JSON.stringify(allCustomSlotSamples)}"`); // TODO
return allCustomSlotSamples;
};
9 changes: 3 additions & 6 deletions src/handle-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,29 @@ module.exports = (app, request, handlers, done) => {

const requestType = request.request.type;

info(`Handling request: "${requestType}"`);
debug(`Request payload: ${JSON.stringify(request, null, 2)}`);
switch (requestType) {

case 'LaunchRequest':
callHandler(handlers.onStart, null, request.session.attributes, app, done);
info(`Request "${requestType}" handled`);
debug(`Request "${requestType}" handled: "${JSON.stringify(request)}"`);
break;

case 'IntentRequest':
const intentName = request.request.intent.name;
const intent = app.intents[request.request.intent.name];

info(`Handling intent: "${intentName}"`);
if(!intent) {
error(`Request NOT handled - unsupported intent: "${intentName}"`);
throw new Error(`Unsupported intent: '${intentName}'`);
}

checkActionsAndHandle(intent, request.request.intent.slots, request.session.attributes, app, handlers, done);
info(`Request "${requestType}" handled`);
debug(`Request "${requestType}" handled: "${JSON.stringify(request)}"`);
break;

case 'SessionEndedRequest':
callHandler(handlers.onEnd, null, request.session.attributes, app, done);
info(`Request "${requestType}" handled`);
debug(`Request "${requestType}" handled: "${JSON.stringify(request)}"`);
break;

default:
Expand Down

0 comments on commit 3a94cdf

Please sign in to comment.