globi-data 0.0.57 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/globi-data.js +7 -9
- package/package.json +5 -14
- package/test/retrieveData.js +1 -1
package/globi-data.js
CHANGED
|
@@ -3,7 +3,6 @@ var extend = require('extend');
|
|
|
3
3
|
var hash = require('object-hash');
|
|
4
4
|
var querystring = require('querystring');
|
|
5
5
|
var citation = require('./citation.js');
|
|
6
|
-
var request = require('request');
|
|
7
6
|
var globiData = {};
|
|
8
7
|
|
|
9
8
|
var urlPrefix = 'https://api.globalbioticinteractions.org';
|
|
@@ -146,13 +145,11 @@ globiData.findSources = function (callback) {
|
|
|
146
145
|
|
|
147
146
|
globiData.findSourceNames = function (callback) {
|
|
148
147
|
function lookupSources(path, callback) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (!error && response.statusCode == 200) {
|
|
155
|
-
var sources = JSON.parse(body);
|
|
148
|
+
var req = createReq();
|
|
149
|
+
req.open('GET', urlPrefix + path, true);
|
|
150
|
+
req.onreadystatechange = function () {
|
|
151
|
+
if (req.readyState === 4 && req.status === 200) {
|
|
152
|
+
var sources = JSON.parse(req.responseText);
|
|
156
153
|
var sourceNames = sources.map(function (source) {
|
|
157
154
|
if (source.study_source_id !== undefined) {
|
|
158
155
|
source.name = source.study_source_id.replace('globi:', '');
|
|
@@ -164,7 +161,8 @@ globiData.findSourceNames = function (callback) {
|
|
|
164
161
|
});
|
|
165
162
|
callback(sourceNames);
|
|
166
163
|
}
|
|
167
|
-
}
|
|
164
|
+
};
|
|
165
|
+
req.send(null);
|
|
168
166
|
}
|
|
169
167
|
|
|
170
168
|
lookupSources('/source/?type=json.v2', function(sourceNames) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "globi-data",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Find out who eats who in the world: what do rats (Rattus rattus) eat?, or what do hardhead catfish (Ariopsis felis) eat?. Data provided via Global Biotic Interactions (GloBI, https://globalbioticinteractions.org) .",
|
|
5
5
|
"main": "globi-data.js",
|
|
6
6
|
"directories": {
|
|
@@ -10,24 +10,15 @@
|
|
|
10
10
|
"extend": "^3.0.0",
|
|
11
11
|
"object-hash": "^1.1.2",
|
|
12
12
|
"querystring": "^0.2.0",
|
|
13
|
-
"request": "^2.79.0",
|
|
14
13
|
"xmlhttprequest": "~1.8.0"
|
|
15
14
|
},
|
|
16
15
|
"devDependencies": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
},
|
|
20
|
-
"testling": {
|
|
21
|
-
"files": "test/*.js",
|
|
22
|
-
"browsers": [
|
|
23
|
-
"opera",
|
|
24
|
-
"ff",
|
|
25
|
-
"chrome"
|
|
26
|
-
]
|
|
16
|
+
"browserify": "~17.0.1",
|
|
17
|
+
"tape": "~5.9.0"
|
|
27
18
|
},
|
|
28
19
|
"scripts": {
|
|
29
|
-
"test": "
|
|
30
|
-
"
|
|
20
|
+
"test": "tape test/*.js",
|
|
21
|
+
"build": "browserify . --standalone globi-data -o globi-data-dist.js"
|
|
31
22
|
},
|
|
32
23
|
"repository": {
|
|
33
24
|
"type": "git",
|
package/test/retrieveData.js
CHANGED
|
@@ -74,7 +74,7 @@ test('close match no path', function (t) {
|
|
|
74
74
|
test('get information for two taxon names', function (t) {
|
|
75
75
|
t.plan(2);
|
|
76
76
|
var callback = function (taxonInfo) {
|
|
77
|
-
t.equal(taxonInfo[0].commonName, 'human', 'should have a common name');
|
|
77
|
+
t.equal(taxonInfo[0].commonName.toLowerCase(), 'human', 'should have a common name');
|
|
78
78
|
t.equal('Homo sapiens', taxonInfo[0].scientificName, 'should have a scientific name');
|
|
79
79
|
};
|
|
80
80
|
globiData.findTaxaInfo(['EOL:327955', 'Ariopsis felis'], callback);
|