climate-data-crawler
Advanced tools
Comparing version 2.0.0 to 2.1.1
@@ -9,4 +9,7 @@ "use strict"; | ||
if (response.statusCode != 200){ | ||
errorCallback('Http status code: ' | ||
+ response.statusCode + ': ' + response.statusMessage); | ||
console.log(response.statusCode); | ||
if (errorCallback){ | ||
errorCallback('Http status code: ' | ||
+ response.statusCode + ': ' + response.statusMessage); | ||
} | ||
} | ||
@@ -31,3 +34,5 @@ | ||
request.on('error', function(error){ | ||
errorCallback(error.message); | ||
if (errorCallback){ | ||
errorCallback(error.message); | ||
} | ||
}); | ||
@@ -34,0 +39,0 @@ |
{ | ||
"name": "climate-data-crawler", | ||
"version": "2.0.0", | ||
"version": "2.1.1", | ||
"description": "Data Crawler for CDO (Climate Data Online) web services", | ||
@@ -10,3 +10,3 @@ "main": "app.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha ./tests/*" | ||
}, | ||
@@ -30,6 +30,8 @@ "repository": { | ||
"command-line-args": "^0.5.9", | ||
"mocha": "^2.2.1", | ||
"readline-sync": "^1.2.15", | ||
"sinon": "^1.14.1" | ||
"readline-sync": "^1.2.15" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.2.5", | ||
"sinon": "^1.15.4" | ||
} | ||
} |
@@ -136,3 +136,3 @@ # Climate Data Crawler - CDO (Climate Data Online) data crawler | ||
### CdoApiClient | ||
Use the CdoApiClient to get Brisbane's monthly mean temperatures between 01 January 2014 and 31 December 2014: | ||
Get Brisbane's monthly mean temperatures between 01 January 2014 and 31 December 2014: | ||
``` | ||
@@ -161,2 +161,15 @@ var CdoApiClient = require('./node_modules/climate-data-crawler/cdoApiClient'); | ||
Retrieve details of all registered stations: | ||
``` | ||
var fs = require('fs'); | ||
var CdoApiClient = require('./node_modules/climate-data-crawler/cdoApiClient'); | ||
var queryPath = '/cdo-web/api/v2/stations?limit=1000'; | ||
var client = CdoApiClient.createInstance(queryPath); | ||
client.query(function(result){ | ||
console.log(result); | ||
fs.appendFileSync('./stations.json', JSON.stringify(result) + '\r\n'); | ||
}); | ||
``` | ||
## Error handling | ||
@@ -182,3 +195,3 @@ | ||
GHCNDMS - Global Historical Climatology Network-Monthly data set: | ||
GHCNDMS - Global Historical Climatology Network-Monthly Summaries data set: | ||
@@ -202,1 +215,3 @@ * MNTM - Monthly mean temperature | ||
[Wikipedia: Global Historical Climatology Network](http://en.wikipedia.org/wiki/Global_Historical_Climatology_Network) | ||
[GHCND Global Historical Climatology Network)-Monthly Summaries documentation](http://www1.ncdc.noaa.gov/pub/data/cdo/documentation/GHCNDMS_documentation.pdf) |
@@ -37,3 +37,3 @@ "use strict"; | ||
it('should raise done even also when api only returns an empty object', function(done){ | ||
it('should raise done event also when api only returns an empty object', function(done){ | ||
// arrange | ||
@@ -44,4 +44,4 @@ this.timeout(120 * 1000); | ||
var dataset = 'GHCNDMS'; | ||
var startDate = '2000-01-01'; | ||
var endDate = '2000-12-31'; | ||
var startDate = '1900-01-01'; | ||
var endDate = '1900-12-31'; | ||
var datatypeid = 'MNTM'; | ||
@@ -48,0 +48,0 @@ |
@@ -10,21 +10,11 @@ "use strict"; | ||
var options = { | ||
host : 'www.ncdc.noaa.gov', | ||
host : 'www.bt.no', | ||
port : 80, | ||
path : '/cdo-web/api/v2/locations/CITY:BR000023', | ||
method : 'GET', | ||
headers: {'token': 'xdZVZowcEuqclhVhBdziSjGXgHUVKHTD'} | ||
method : 'GET' | ||
}; | ||
var expected = { | ||
"id": "CITY:BR000023", | ||
"name": "Rio de Janeiro, BR", | ||
"datacoverage": 1, | ||
"mindate": "1938-01-01", | ||
"maxdate": "1999-12-31" | ||
}; | ||
var client = new HttpClient(); | ||
client.request(options, function(result){ | ||
assert.equal(result, JSON.stringify(expected)); | ||
assert.equal(!!result, true); | ||
done(); | ||
@@ -39,4 +29,3 @@ }); | ||
path : '/undefined', | ||
method : 'GET', | ||
headers: {'token': 'xdZVZowcEuqclhVhBdziSjGXgHUVKHTD'} | ||
method : 'GET' | ||
}; | ||
@@ -43,0 +32,0 @@ |
@@ -10,3 +10,2 @@ "use strict"; | ||
var Timer = require('../../helpers/timer'); | ||
var fs = require('fs'); | ||
@@ -41,3 +40,3 @@ describe('CdoDataProbingQuery', function(){ | ||
timer = new Timer(); | ||
sinon.stub(timer, 'setTimeout', function(callback, delay){ | ||
sinon.stub(timer, 'setTimeout', function(callback){ | ||
callback(); | ||
@@ -124,3 +123,18 @@ }); | ||
// arrange | ||
var resultFromApi = JSON.parse(fs.readFileSync('test-resources/dataset.json', {encoding: 'utf8'})); | ||
var resultFromApi = [ | ||
{ | ||
"station": "GHCND:BR000083743", | ||
"value": 268, | ||
"attributes": "19,6", | ||
"datatype": "MNTM", | ||
"date": "2014-01-01T00:00:00" | ||
}, | ||
{ | ||
"station": "GHCND:BR000083743", | ||
"value": 278, | ||
"attributes": "16,7", | ||
"datatype": "MNTM", | ||
"date": "2014-02-01T00:00:00" | ||
} | ||
]; | ||
var results = null; | ||
@@ -154,3 +168,18 @@ | ||
// arrange | ||
var runResults = JSON.parse(fs.readFileSync('test-resources/dataset.json', {encoding: 'utf8'})); | ||
var runResults = [ | ||
{ | ||
"station": "GHCND:BR000083743", | ||
"value": 268, | ||
"attributes": "19,6", | ||
"datatype": "MNTM", | ||
"date": "2014-01-01T00:00:00" | ||
}, | ||
{ | ||
"station": "GHCND:BR000083743", | ||
"value": 278, | ||
"attributes": "16,7", | ||
"datatype": "MNTM", | ||
"date": "2014-02-01T00:00:00" | ||
} | ||
] | ||
@@ -157,0 +186,0 @@ sinon.stub(api, 'query', function(onApiCallComplete){ |
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
2
0
214
5
60340
2
1524
+ Addedminimist@0.0.10(transitive)
- Removedmocha@^2.2.1
- Removedsinon@^1.14.1
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removedcommander@0.6.12.3.0(transitive)
- Removeddebug@2.2.0(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddiff@1.4.0(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedescape-string-regexp@1.0.2(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedformatio@1.1.1(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.6(transitive)
- Removedglob@3.2.11(transitive)
- Removedgopd@1.2.0(transitive)
- Removedgrowl@1.9.2(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-arguments@1.2.0(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-generator-function@1.0.10(transitive)
- Removedis-typed-array@1.1.15(transitive)
- Removedjade@0.26.3(transitive)
- Removedlolex@1.3.2(transitive)
- Removedlru-cache@2.7.3(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedminimatch@0.3.0(transitive)
- Removedminimist@0.0.8(transitive)
- Removedmkdirp@0.3.00.5.1(transitive)
- Removedmocha@2.5.3(transitive)
- Removedms@0.7.1(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedsamsam@1.1.2(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedsigmund@1.0.1(transitive)
- Removedsinon@1.17.7(transitive)
- Removedsupports-color@1.2.0(transitive)
- Removedto-iso-string@0.0.2(transitive)
- Removedutil@0.12.5(transitive)
- Removedwhich-typed-array@1.1.18(transitive)