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."
|
||||
(Source: [Xeno-canto website](http://xeno-canto.org/))
|
||||
|
||||
## /!\ No code released yet /!\ ##
|
||||
Just started. Please be patient.
|
||||
## Installation
|
||||
```
|
||||
$ 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
|
||||
12/11/13 xeno-canto inception
|
||||
12/11/13 xeno-canto inception, basic search 0.0.1
|
||||
|
||||
|
||||
### License
|
||||
|
@ -1,22 +1,22 @@
|
||||
{
|
||||
"name": "xeno-canto",
|
||||
"description": "Node.js API for xeno-canto database webservices",
|
||||
"version": "0.0.0",
|
||||
"version": "0.0.1",
|
||||
"homepage": "",
|
||||
"author": {
|
||||
"name": "Patrick De Marta",
|
||||
"name": "tripitakit",
|
||||
"email": "patrick.demarta@gmail.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github/tripitakit/xeno-canto.git"
|
||||
"url": "https://github.com/tripitakit/xeno-canto"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/tripitakit/xeno-canto/issues"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"type": "GNU GPL",
|
||||
"url": "http://www.gnu.org/licenses/"
|
||||
}
|
||||
],
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var xeno_canto = require('../lib/xeno-canto.js');
|
||||
var XenoCanto = require('../lib/xeno-canto.js');
|
||||
|
||||
/*
|
||||
======== A Handy Little Nodeunit Reference ========
|
||||
@ -22,15 +22,20 @@ var xeno_canto = require('../lib/xeno-canto.js');
|
||||
test.ifError(value)
|
||||
*/
|
||||
|
||||
exports['awesome'] = {
|
||||
exports['xeno-canto-api'] = {
|
||||
setUp: function(done) {
|
||||
// setup here
|
||||
done();
|
||||
},
|
||||
'no args': function(test) {
|
||||
test.expect(1);
|
||||
// tests here
|
||||
test.equal(xeno_canto.awesome(), 'awesome', 'should be awesome.');
|
||||
|
||||
'search bearded bellbird returns 28 recordings': function(test) {
|
||||
test.expect(4);
|
||||
var xeno_canto = new XenoCanto();
|
||||
xeno_canto.search("bearded bellbird", function(self){
|
||||
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