Comparing version 2.2.3 to 2.3.0
@@ -22,3 +22,3 @@ "use strict"; | ||
function Citibike( options ) { | ||
if (!(this instanceof Citibike)) | ||
if (!(this instanceof Citibike)) | ||
return new Citibike(options); | ||
@@ -39,3 +39,2 @@ | ||
branchesURL: '/v1/branch/list', | ||
stationsURL: '/data2/stations.php' | ||
}; | ||
@@ -46,3 +45,3 @@ | ||
/** | ||
/** | ||
* Issues an HTTP Get request. | ||
@@ -94,16 +93,2 @@ * | ||
/** | ||
* Function for requesting and returning Citibike Stations data in JSON form. | ||
* | ||
* @param {Object} params Object containing query string parameters to issue in the request. | ||
* @param {Function} callback Callback function that will be called when the processing is done. | ||
*/ | ||
Citibike.prototype.getStations = function( params, callback ) { | ||
var url = this.options.restBase + this.options.stationsURL; | ||
this.get(url, params, function(data) { | ||
callback(data); | ||
}); | ||
return this; | ||
} | ||
/** | ||
* Function for requesting and returning Citibike Branch data in JSON form. | ||
@@ -136,2 +121,2 @@ * | ||
module.exports = Citibike; | ||
module.exports = Citibike; |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "2.2.3", | ||
"version": "2.3.0", | ||
"author": "Kevin Coughlin <kevintcoughlin@gmail.com>", | ||
@@ -18,0 +18,0 @@ "contributors": [ |
# Citibike [![Build Status](https://travis-ci.org/KevinTCoughlin/citibike.png)](https://travis-ci.org/KevinTCoughlin/citibike) [![Dependency Status](https://gemnasium.com/KevinTCoughlin/citibike.png)](https://gemnasium.com/KevinTCoughlin/citibike) | ||
[![NPM](https://nodei.co/npm/citibike.png)](https://nodei.co/npm/citibike/) | ||
A [node.js](http://nodejs.org/) wrapper for [Citibike](http://citibikenyc.com/)'s REST API. | ||
@@ -129,3 +131,3 @@ | ||
Citibike: Copyright (c) 2013 Kevin Coughlin | ||
Citibike: Copyright (c) 2014 Kevin Coughlin | ||
@@ -132,0 +134,0 @@ Permission is hereby granted, free of charge, to any person obtaining |
@@ -1,6 +0,6 @@ | ||
/** | ||
/** | ||
* Tests for Citibike API | ||
* Ensure that Citibike does not dramatically change data we need to access in their API | ||
* Test Framework: Mocha (http://visionmedia.github.io/mocha/) | ||
* Assertions: Should (https://github.com/visionmedia/should.js/) | ||
* Assertions: Should (https://github.com/visionmedia/should.js/) | ||
*/ | ||
@@ -29,3 +29,3 @@ | ||
// Headers | ||
res.header['content-type'].should.eql('application/json; charset=utf8'); | ||
res.header['content-type'].should.eql('application/json'); | ||
@@ -53,6 +53,6 @@ // Content | ||
sampleResult.id.should.be.a('number'); | ||
sampleResult.latitude.should.be.a('number'); | ||
sampleResult.latitude.should.be.a('number'); | ||
sampleResult.label.should.be.a('string'); | ||
sampleResult.id.should.be.type('number'); | ||
sampleResult.latitude.should.be.type('number'); | ||
sampleResult.latitude.should.be.type('number'); | ||
sampleResult.label.should.be.type('string'); | ||
@@ -74,3 +74,3 @@ done(); | ||
// Headers | ||
res.header['content-type'].should.eql('application/json; charset=utf8'); | ||
res.header['content-type'].should.eql('application/json'); | ||
@@ -99,7 +99,7 @@ // Content | ||
sampleResult.id.should.be.a('number'); | ||
sampleResult.address.should.be.a('string'); | ||
sampleResult.latitude.should.be.a('number'); | ||
sampleResult.latitude.should.be.a('number'); | ||
sampleResult.label.should.be.a('string'); | ||
sampleResult.id.should.be.type('number'); | ||
sampleResult.address.should.be.type('string'); | ||
sampleResult.latitude.should.be.type('number'); | ||
sampleResult.latitude.should.be.type('number'); | ||
sampleResult.label.should.be.type('string'); | ||
@@ -110,103 +110,1 @@ done(); | ||
}); | ||
describe('Citibike API - Stations', function () { | ||
it('responds with json and proper data', function (done) { | ||
request | ||
.get(citibike.defaults.stationsURL) | ||
.set('Accept', 'application/json') | ||
.expect(200) | ||
.end(function(err, res) { | ||
should.not.exist(err); | ||
// Headers | ||
res.header['content-type'].should.eql('application/json; charset=utf8'); | ||
// Content | ||
/* Expected Response: | ||
{ | ||
ok: true, | ||
meta: [ ], | ||
results: [ | ||
{ | ||
id: 72, | ||
status: "Active", | ||
latitude: 40.76727216, | ||
longitude: -73.99392888, | ||
label: "W 52 St & 11 Ave", | ||
stationAddress: "", | ||
availableBikes: 8, | ||
availableDocks: 26, | ||
nearbyStations: [ | ||
{ | ||
id: 480, | ||
distance: 0.17780736685282 | ||
} | ||
] | ||
} | ||
], | ||
lastUpdate: 1367853737 | ||
} */ | ||
res.body.ok.should.eql(true); | ||
res.body.results.should.not.be.empty; | ||
var sampleResult = res.body.results[0]; | ||
sampleResult.id.should.be.a('number'); | ||
sampleResult.status.should.be.a('string'); | ||
sampleResult.latitude.should.be.a('number'); | ||
sampleResult.latitude.should.be.a('number'); | ||
sampleResult.label.should.be.a('string'); | ||
sampleResult.stationAddress.should.be.a('string'); | ||
sampleResult.availableBikes.should.be.a('number'); | ||
sampleResult.availableDocks.should.be.a('number'); | ||
sampleResult.nearbyStations.should.not.be.empty; | ||
sampleResult.nearbyStations[0].id.should.be.a('number'); | ||
sampleResult.nearbyStations[0].distance.should.be.a('number'); | ||
done(); | ||
}); | ||
}); | ||
it('responds with json and only updated data', function (done) { | ||
request | ||
.get(citibike.defaults.stationsURL + '?updateOnly=true') | ||
.set('Accept', 'application/json') | ||
.expect(200) | ||
.end(function(err, res) { | ||
should.not.exist(err); | ||
// Headers | ||
res.header['content-type'].should.eql('application/json; charset=utf8'); | ||
// Content | ||
/* Expected Response: | ||
{ | ||
ok: true, | ||
meta: [ ], | ||
results: [ | ||
{ | ||
id: 72, | ||
status: "Active", | ||
availableBikes: 8, | ||
availableDocks: 26 | ||
} | ||
], | ||
lastUpdate: 1367853737 | ||
} */ | ||
res.body.ok.should.eql(true); | ||
res.body.results.should.not.be.empty; | ||
var sampleResult = res.body.results[0]; | ||
sampleResult.id.should.be.a('number'); | ||
sampleResult.status.should.be.a('string'); | ||
sampleResult.availableBikes.should.be.a('number'); | ||
sampleResult.availableDocks.should.be.a('number'); | ||
should.not.exist(sampleResult.latitude); | ||
done(); | ||
}); | ||
}); | ||
}); |
@@ -1,5 +0,5 @@ | ||
/** | ||
/** | ||
* Tests for HTTP GET requests | ||
* Test Framework: Mocha (http://visionmedia.github.io/mocha/) | ||
* Assertions: Should (https://github.com/visionmedia/should.js/) | ||
* Assertions: Should (https://github.com/visionmedia/should.js/) | ||
*/ | ||
@@ -42,22 +42,2 @@ | ||
describe('Citibike.getStations()', function () { | ||
it('should successfully complete request', function (done) { | ||
citibike.getStations({}, function(data) { | ||
should.exist(data); | ||
data.results.should.not.be.empty; | ||
done(); | ||
}); | ||
}); | ||
it('should successfully complete request with params', function (done) { | ||
citibike.getStations({updateOnly: true}, function(data) { | ||
should.exist(data); | ||
data.results.should.not.be.empty; | ||
sampleResult = data.results[0]; | ||
should.exist(sampleResult.availableBikes); | ||
should.not.exist(sampleResult.latitude); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('Citibike.getBranches()', function () { | ||
@@ -81,2 +61,2 @@ it('should successfully complete request', function (done) { | ||
}); | ||
}); | ||
}); |
@@ -1,5 +0,5 @@ | ||
/** | ||
/** | ||
* Tests for HTTP GET requests | ||
* Test Framework: Mocha (http://visionmedia.github.io/mocha/) | ||
* Assertions: Should (https://github.com/visionmedia/should.js/) | ||
* Assertions: Should (https://github.com/visionmedia/should.js/) | ||
*/ | ||
@@ -26,4 +26,3 @@ | ||
helmetsURL: '/v1/helmet/list', | ||
branchesURL: '/v1/branch/list', | ||
stationsURL: '/data2/stations.php' | ||
branchesURL: '/v1/branch/list' | ||
}; | ||
@@ -40,3 +39,2 @@ | ||
citibike.defaults.branchesURL.should.equal('/v1/branch/list'); | ||
citibike.defaults.stationsURL.should.equal('/data2/stations.php'); | ||
}); | ||
@@ -57,4 +55,3 @@ | ||
helmetsURL: '/v1/helmet/list', | ||
branchesURL: '/v1/branch/list', | ||
stationsURL: '/data2/stations.php' | ||
branchesURL: '/v1/branch/list' | ||
}, | ||
@@ -69,2 +66,2 @@ options = { | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
153
20056
14
366