basic search test, usage example in readme
This commit is contained in:
parent
fdd415c459
commit
4b8a1baaac
54
README.md
54
README.md
@ -16,11 +16,59 @@ representative recording. Methods also provide summary statistics about
|
|||||||
listings relevant to the species named in the request."
|
listings relevant to the species named in the request."
|
||||||
(Source: [Xeno-canto website](http://xeno-canto.org/))
|
(Source: [Xeno-canto website](http://xeno-canto.org/))
|
||||||
|
|
||||||
## /!\ No code released yet /!\ ##
|
## Installation
|
||||||
Just started. Please be patient.
|
```
|
||||||
|
$ npm install xeno-canto
|
||||||
|
```
|
||||||
|
## Usage
|
||||||
|
```javascript
|
||||||
|
|
||||||
|
/** Dependencies */
|
||||||
|
var XenoCanto = require('xeno-canto');
|
||||||
|
|
||||||
|
|
||||||
|
/** A simple search with English common name*/
|
||||||
|
var xeno_canto = new XenoCanto();
|
||||||
|
|
||||||
|
/* the callback is passed a reference of the instance, when search is complete;
|
||||||
|
the response json object is stored in the instance's property .entity */
|
||||||
|
|
||||||
|
xeno_canto.search("bearded bellbird", function(self){
|
||||||
|
console.log(self.entity.numRecordings == "28");
|
||||||
|
console.log(self.entity.numSpecies == "1");
|
||||||
|
// inspect more properties ..
|
||||||
|
});
|
||||||
|
|
||||||
|
```
|
||||||
|
**Response Properties**
|
||||||
|
|
||||||
|
- numRecordings: the total number of recordings found for this query
|
||||||
|
- numSpecies: the total number of species found for this query
|
||||||
|
- page: the page number of the results page that is being displayed
|
||||||
|
- numPages: the total number of pages available for this query
|
||||||
|
- recordings: an array of recording objects, described in detail below
|
||||||
|
|
||||||
|
**Recording object properties
|
||||||
|
|
||||||
|
- id: the catalogue number of the recording on xeno-canto
|
||||||
|
- gen: the generic name of the species
|
||||||
|
- sp: the specific name of the species
|
||||||
|
- en: the English name of the species
|
||||||
|
- rec: the name of the recordist
|
||||||
|
- cnt: the country where the recording was made
|
||||||
|
- loc: the name of the locality
|
||||||
|
- lat: the latitude of the recording in decimal coordinates
|
||||||
|
- lng: the longitude of the recording in decimal coordinates
|
||||||
|
- type: the sound type of the recording (e.g. 'call', 'song', etc). This is generally a comma-separated list of sound types.
|
||||||
|
- file: the URL to the audio file
|
||||||
|
- lic: the URL describing the license of this recording
|
||||||
|
- url: the URL specifying the details of this recording
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Release History
|
### Release History
|
||||||
12/11/13 xeno-canto inception
|
12/11/13 xeno-canto inception, basic search 0.0.1
|
||||||
|
|
||||||
|
|
||||||
### License
|
### License
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
{
|
{
|
||||||
"name": "xeno-canto",
|
"name": "xeno-canto",
|
||||||
"description": "Node.js API for xeno-canto database webservices",
|
"description": "Node.js API for xeno-canto database webservices",
|
||||||
"version": "0.0.0",
|
"version": "0.0.1",
|
||||||
"homepage": "",
|
"homepage": "",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Patrick De Marta",
|
"name": "tripitakit",
|
||||||
"email": "patrick.demarta@gmail.com"
|
"email": "patrick.demarta@gmail.com"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github/tripitakit/xeno-canto.git"
|
"url": "https://github.com/tripitakit/xeno-canto"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/tripitakit/xeno-canto/issues"
|
"url": "https://github.com/tripitakit/xeno-canto/issues"
|
||||||
},
|
},
|
||||||
"licenses": [
|
"licenses": [
|
||||||
{
|
{
|
||||||
"type": "MIT",
|
"type": "GNU GPL",
|
||||||
"url": "http://www.gnu.org/licenses/"
|
"url": "http://www.gnu.org/licenses/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var xeno_canto = require('../lib/xeno-canto.js');
|
var XenoCanto = require('../lib/xeno-canto.js');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
======== A Handy Little Nodeunit Reference ========
|
======== A Handy Little Nodeunit Reference ========
|
||||||
@ -22,15 +22,20 @@ var xeno_canto = require('../lib/xeno-canto.js');
|
|||||||
test.ifError(value)
|
test.ifError(value)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports['awesome'] = {
|
exports['xeno-canto-api'] = {
|
||||||
setUp: function(done) {
|
setUp: function(done) {
|
||||||
// setup here
|
done();
|
||||||
done();
|
},
|
||||||
},
|
|
||||||
'no args': function(test) {
|
'search bearded bellbird returns 28 recordings': function(test) {
|
||||||
test.expect(1);
|
test.expect(4);
|
||||||
// tests here
|
var xeno_canto = new XenoCanto();
|
||||||
test.equal(xeno_canto.awesome(), 'awesome', 'should be awesome.');
|
xeno_canto.search("bearded bellbird", function(self){
|
||||||
test.done();
|
test.ok(!!self);
|
||||||
},
|
test.equal(typeof(self), 'object');
|
||||||
|
test.equal(typeof(self.entity), 'object');
|
||||||
|
test.equal(self.entity.numRecordings, "28");
|
||||||
|
test.done();
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user