Permalink
Browse files

linting issues for tab/spaces resolved.

  • Loading branch information...
1 parent ba3db63 commit b7d40c17118118b33bb4e748071933fb178a2b87 @bustardcelly committed Oct 7, 2012
@@ -29,6 +29,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-jasmine-node');
// Default task.
- grunt.registerTask('default', 'jasmine_node');
+ grunt.registerTask('default', 'lint jasmine_node');
};
@@ -25,7 +25,8 @@
},
"devDependencies" : {
"grunt" : "~0.3.16",
- "jasmine-node": "*"
+ "jasmine-node": "*",
+ "forever": "0.10.1"
},
"private": "true",
"readme": "# massroute-node"
@@ -5,10 +5,10 @@ var promise = require('promise'),
return function( error ) {
response.format({
html: function(){
- response.render('error', error );
+ response.render('error', error );
},
json: function(){
- response.send( JSON.stringify(error) );
+ response.send( JSON.stringify(error) );
}
});
};
@@ -19,10 +19,10 @@ function renderRoutes( request, response ) {
return function( result ) {
response.format({
html: function(){
- response.render('routes', {routes:result});
+ response.render('routes', {routes:result});
},
json: function(){
- response.send( JSON.stringify(result) );
+ response.send( JSON.stringify(result) );
}
});
};
@@ -32,10 +32,10 @@ function renderDestinations( request, response ) {
return function( result ) {
response.format({
html: function(){
- response.render('destinations', {destinations:result});
+ response.render('destinations', {destinations:result});
},
json: function(){
- response.send( JSON.stringify(result) );
+ response.send( JSON.stringify(result) );
}
});
};
@@ -45,10 +45,10 @@ function renderStops( request, response ) {
return function( result ) {
response.format({
html: function(){
- response.render('stops', {stops:result});
+ response.render('stops', {stops:result});
},
json: function(){
- response.send( JSON.stringify(result) );
+ response.send( JSON.stringify(result) );
}
});
};
@@ -58,10 +58,10 @@ function renderPredictions( request, response ) {
return function( result ) {
response.format({
html: function(){
- response.render('predictions', {predictions:result});
+ response.render('predictions', {predictions:result});
},
json: function(){
- response.send( JSON.stringify(result) );
+ response.send( JSON.stringify(result) );
}
});
};
@@ -1,25 +1,25 @@
-var express = require('express'),
- swagger = require('swagger'),
- resources = require('./doc-resources');
+var express = require('express'),
+ swagger = require('swagger'),
+ resources = require('./doc-resources');
exports.init = function( app, url ) {
- swagger.setAppHandler(app);
- swagger.addGet( resources.requestRoutes )
- .addGet( resources.findDestinationsByRouteId );
+ swagger.setAppHandler(app);
+ swagger.addGet( resources.requestRoutes )
+ .addGet( resources.findDestinationsByRouteId );
- swagger.configure(url, "0.1");
+ swagger.configure(url, "0.1");
- // REST docs.
- var docs_handler = express.static(process.cwd() + '/doc/swagger-ui-1.1.0/');
- app.get(/^\/docs(\/.*)?$/, function(req, res, next) {
- if (req.url === '/docs') { // express static barfs on root url w/o trailing slash
- res.writeHead(302, { 'Location' : req.url + '/' });
- res.end();
- return;
- }
- // take off leading /docs so that connect locates file correctly
- req.url = req.url.substr('/docs'.length);
- return docs_handler(req, res, next);
- });
-}
+ // REST docs.
+ var docs_handler = express['static'](process.cwd() + '/doc/swagger-ui-1.1.0/');
+ app.get(/^\/docs(\/.*)?$/, function(req, res, next) {
+ if (req.url === '/docs') { // express static barfs on root url w/o trailing slash
+ res.writeHead(302, { 'Location' : req.url + '/' });
+ res.end();
+ return;
+ }
+ // take off leading /docs so that connect locates file correctly
+ req.url = req.url.substr('/docs'.length);
+ return docs_handler(req, res, next);
+ });
+};
@@ -7,62 +7,62 @@ var _ = require('lodash');
* @param {Aray} destinations
*/
exports.RouteConfiguration = function( routeID, stops, destinations ) {
- var destinationMap,
- destinationStopMap = {};
- return {
- routeID: routeID,
- stops: stops,
- destinations: destinations,
- /**
- * Returns destination from list based on id.
- * @param {String} id
- * @return {Object} Destination object
- */
- getDestinationByID: function( id ) {
- var i = 0,
- item;
- while( i < destinations.length ) {
- item = destinations[i];
- if( id === item.tag ) {
- return item;
- }
- i++;
- }
- return undefined;
- },
- /**
- * Returns mapped destinations based on Inbound/Outbound or whichever other name associated with destination(s).
- * @return {Object} Name-based map.
- */
- getDestinations: function() {
- if( !destinationMap ) {
- destinationMap = {};
- _.each(this.destinations, function(item) {
- if( !destinationMap.hasOwnProperty(item.name) ) {
- destinationMap[item.name] = [];
- }
- destinationMap[item.name].push(item);
- });
- }
- return destinationMap;
- },
- /**
- * Returns list of of Stops associated with destination id.
- * @param {String} id
- * @return {Array} List of stops.
- */
- stopsByDestination: function ( id ) {
- if( !destinationStopMap.hasOwnProperty( id ) ) {
- var list = [],
- destination = this.getDestinationByID( id );
- if( destination ) {
- _.each( destination.stop, function( item ) {
- list[list.length] = stops[item.tag];
- });
- }
- destinationStopMap[id] = list;
- }
- return destinationStopMap[id];
- }
- };
+ var destinationMap,
+ destinationStopMap = {};
+ return {
+ routeID: routeID,
+ stops: stops,
+ destinations: destinations,
+ /**
+ * Returns destination from list based on id.
+ * @param {String} id
+ * @return {Object} Destination object
+ */
+ getDestinationByID: function( id ) {
+ var i = 0,
+ item;
+ while( i < destinations.length ) {
+ item = destinations[i];
+ if( id === item.tag ) {
+ return item;
+ }
+ i++;
+ }
+ return undefined;
+ },
+ /**
+ * Returns mapped destinations based on Inbound/Outbound or whichever other name associated with destination(s).
+ * @return {Object} Name-based map.
+ */
+ getDestinations: function() {
+ if( !destinationMap ) {
+ destinationMap = {};
+ _.each(this.destinations, function(item) {
+ if( !destinationMap.hasOwnProperty(item.name) ) {
+ destinationMap[item.name] = [];
+ }
+ destinationMap[item.name].push(item);
+ });
+ }
+ return destinationMap;
+ },
+ /**
+ * Returns list of of Stops associated with destination id.
+ * @param {String} id
+ * @return {Array} List of stops.
+ */
+ stopsByDestination: function ( id ) {
+ if( !destinationStopMap.hasOwnProperty( id ) ) {
+ var list = [],
+ destination = this.getDestinationByID( id );
+ if( destination ) {
+ _.each( destination.stop, function( item ) {
+ list[list.length] = stops[item.tag];
+ });
+ }
+ destinationStopMap[id] = list;
+ }
+ return destinationStopMap[id];
+ }
+ };
};
@@ -1,6 +1,6 @@
-var _ = require('lodash'),
- log4js = require('log4js'),
- logger = log4js.getLogger('service');
+var _ = require('lodash'),
+ log4js = require('log4js'),
+ logger = log4js.getLogger('service');
/**
* Converts a list of objects to a keyed map based on provided key value.
@@ -9,66 +9,66 @@ var _ = require('lodash'),
* @return {Object} Mapped object with provided itemKey as the key and object inlist as value.
*/
exports.arrayToKeyMap = function( list, itemKey ) {
- var map = {}, ls = this.mapResult(list);
- _.each( ls, function( item ) {
- map[item[itemKey]] = item;
- });
- return map;
-}
+ var map = {}, ls = this.mapResult(list);
+ _.each( ls, function( item ) {
+ map[item[itemKey]] = item;
+ });
+ return map;
+};
/**
* Returns object represented by the @ character which is a result of the libxml-to-js parser.
* @param {Array} list List of objects that each are keyed with a @ character.
* @return {Object} Object held under the @ key.
*/
exports.mapResult = function( list ) {
- if( list instanceof Array ) {
- return _.map( list, function( value ) {
- return value["@"];
- });
- }
- else {
- return list["@"];
- }
-}
+ if( list instanceof Array ) {
+ return _.map( list, function( value ) {
+ return value["@"];
+ });
+ }
+ else {
+ return list["@"];
+ }
+};
/**
* Bases prediction item and appends the list of predictions to the object.
* @param {Object} item Parsed XML object for prediction
* @return {Object} Prediction object with properly parsed list of predictions.
*/
exports.mapPredictionResult = function( item ) {
- var prediction, predictions = [];
- prediction = item["@"];
- prediction.predictions = (item.direction) ? this.mapResult(item.direction.prediction) : [];
- return prediction;
-}
+ var prediction, predictions = [];
+ prediction = item["@"];
+ prediction.predictions = (item.direction) ? this.mapResult(item.direction.prediction) : [];
+ return prediction;
+};
/**
- * Returns a list of direction objects from either a list or map of parsed directions.
- * @param {Array|Object} list An array or object representing a list of directions.
+ * Returns a list of direction objects from either a list or map of parsed directions.
+ * @param {Array|Object} list An array or object representing a list of directions.
* @return {Array} A list of mapped directions based on parser results.
*/
exports.listDirectionsResult = function( list ) {
- var dir,
- directions = [],
- self = this;
- if( list instanceof Array ) {
- _.each( list, function( item ) {
- dir = item["@"];
- dir.stop = self.mapResult(item.stop);
- directions[directions.length] = dir;
- });
- }
- else {
- try {
- dir = list["@"];
- dir.stop = self.mapResult(list.stop);
- directions[directions.length] = dir;
- }
- catch( e ) {
- logger.error( 'Error in parsing direction. [REASON] :: ' + e.message );
- }
- }
- return directions;
-}
+ var dir,
+ directions = [],
+ self = this;
+ if( list instanceof Array ) {
+ _.each( list, function( item ) {
+ dir = item["@"];
+ dir.stop = self.mapResult(item.stop);
+ directions[directions.length] = dir;
+ });
+ }
+ else {
+ try {
+ dir = list["@"];
+ dir.stop = self.mapResult(list.stop);
+ directions[directions.length] = dir;
+ }
+ catch( e ) {
+ logger.error( 'Error in parsing direction. [REASON] :: ' + e.message );
+ }
+ }
+ return directions;
+};
Oops, something went wrong.

0 comments on commit b7d40c1

Please sign in to comment.