Skip to content

Commit

Permalink
Merge pull request #88 from essamjoubori/master
Browse files Browse the repository at this point in the history
Delete Makefile, update version, clean up code
  • Loading branch information
ebradyjobory committed Jan 18, 2015
2 parents 51e0779 + 451b8e3 commit 3b005fe
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 38 deletions.
4 changes: 0 additions & 4 deletions Makefile

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ Our [PersonifyApp](http://personify.mybluemix.net/) grabs tweets based on a keyw


## Release History
- 1.0.3 Cleaned up code, added geoList file, and updated README.md
- 1.0.2 Personify logo added
- 1.0.1 README.md updated
- 1.0.0 Initial release
Expand Down
24 changes: 19 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
{
"name": "personify",
"description": "A JavaScript based library that allows easy access to IBM Watson features utilizing Twitter data",
"version": "1.0.2",
"version": "1.0.3",
"main": "./util/twitter",
"author": {
"name": "Essam Al Joubori, Phil Elauria, Rohan Agrawal"
},
"contributors": [
{
"name" : "Essam Al Joubori",
"email" : "[email protected]",
"url" : "https://github.com/essamjoubori"
},
{
"name" : "Phil Elauria",
"email" : "[email protected]",
"url" : "https://github.com/philelauria"
},
{
"name" : "Rohan Agrawal",
"email" : "[email protected]",
"url" : "https://github.com/rohanagrawal"
}
],
"repository": {
"type": "git",
"url": "https://github.com/PersonifyJS/personify.js"
Expand Down Expand Up @@ -38,6 +52,6 @@
},
"homepage": "http://personifyjs.github.io/",
"scripts": {
"test": "make test"
"test": "./node_modules/.bin/mocha tests/* -t 70000 -R spec --bail"
}
}
48 changes: 24 additions & 24 deletions util/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ var querystring = require('querystring');

module.exports.translate = function(authenticate, data, language, outputType, callback){

// defaults for dev outside bluemix
var service_url = authenticate.translateConfig.service_url;
var service_username = authenticate.translateConfig.service_username;
var service_password = authenticate.translateConfig.service_password;
// defaults for dev outside bluemix
var service_url = authenticate.translateConfig.service_url;
var service_username = authenticate.translateConfig.service_username;
var service_password = authenticate.translateConfig.service_password;

// VCAP_SERVICES contains all the credentials of services bound to
// this application. For details of its content, please refer to
// the document or sample of each service.
if (process.env.VCAP_SERVICES) {
console.log('Parsing VCAP_SERVICES');
var services = JSON.parse(process.env.VCAP_SERVICES);
//service name, check the VCAP_SERVICES in bluemix to get the name of the services you have
var service_name = 'machine_translation';

if (services[service_name]) {
var svc = services[service_name][0].credentials;
service_url = svc.url;
service_username = svc.username;
service_password = svc.password;
} else {
console.log('The service '+service_name+' is not in the VCAP_SERVICES, did you forget to bind it?');
}

// VCAP_SERVICES contains all the credentials of services bound to
// this application. For details of its content, please refer to
// the document or sample of each service.
if (process.env.VCAP_SERVICES) {
console.log('Parsing VCAP_SERVICES');
var services = JSON.parse(process.env.VCAP_SERVICES);
//service name, check the VCAP_SERVICES in bluemix to get the name of the services you have
var service_name = 'machine_translation';

if (services[service_name]) {
var svc = services[service_name][0].credentials;
service_url = svc.url;
service_username = svc.username;
service_password = svc.password;
} else {
console.log('The service '+service_name+' is not in the VCAP_SERVICES, did you forget to bind it?');
console.log('No VCAP_SERVICES found in ENV, using defaults for local development');
}

} else {
console.log('No VCAP_SERVICES found in ENV, using defaults for local development');
}

var auth = 'Basic ' + new Buffer(service_username + ':' + service_password).toString('base64');
var auth = 'Basic ' + new Buffer(service_username + ':' + service_password).toString('base64');

var request_data = {
'txt': data,
Expand Down
6 changes: 1 addition & 5 deletions util/watson.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ var querystring = require('querystring');
var extend = require('util')._extend;
var flatten = require('../lib/flatten');

var appInfo = JSON.parse(process.env.VCAP_APPLICATION || "{}");

// exporting the watson module to be required by the end user
module.exports.watson = function(authenticate, data, callback) {

Expand Down Expand Up @@ -96,12 +94,10 @@ var create_profile_request = function(options, content, res) {
});

result.on('end', function() {

if (result.statusCode != 200) {
var error = JSON.parse(response_string);
// render error if the results are less than 100 words
// res.send({"error" : "Watson: Oh, dear. It looks like there aren't enough tweets to conduct an analysis. Kindly send me another search query."});
callback({'message': error.user_message}, null);
callback({'message': error.user_message}, null);
} else
callback(null,response_string);
});
Expand Down

0 comments on commit 3b005fe

Please sign in to comment.