From 5c385384beb793eebd203ce543c39e633e94815d Mon Sep 17 00:00:00 2001 From: Stephan Tabor Date: Mon, 19 Oct 2015 12:25:50 -0400 Subject: [PATCH] [feature] setup for coveralls --- README.md | 14 +++++++++----- gulpfile.js | 17 ++++++++++++++--- package.json | 7 +++---- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index cf617f4..f1a4a6c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# pkmn [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] +# pkmn [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url] > pokeapi.co wrapper. Details about the api can be found here: http://pokeapi.co/docs/ @@ -14,7 +14,6 @@ $ npm install --save pkmn ```js var Pkmn = require('pkmn'); var p = new Pkmn(); - ``` ### Get @@ -38,7 +37,9 @@ be rejected. p.get('pokemon', 'Vegeta') .catch(console.error) // logs [Error] 404 ``` + Too few arguments to `.get` also throws an error. All resources except `pokedex` require an `id` argument to passed to `.get` with them. + ```js p.get('pokemon') .then(console.log) // doesn't log @@ -49,6 +50,7 @@ p.get('pokedex') ``` The full list of valid resources is: + ``` pokedex, pokemon, egg, type, description, move, ability, sprite, game ``` @@ -57,15 +59,16 @@ Additionally, `.get` can take a `resource_id` as an argument. This is useful bec ```js p.get('/api/v1/pokemon/bulbasaur') -... +// ... ``` ### Convenience Methods All valid resource argumets to `.get` also have convenience methods: + ```js -p.pokemon([33, 'snorlax', 209) +p.pokemon([33, 'snorlax', 209]) p.ability(56) p.egg(2) p.pokedex() @@ -83,10 +86,11 @@ p.api() MIT © [Stephan Tabor](http://stephantabor.com) - [npm-image]: https://badge.fury.io/js/pkmn.svg [npm-url]: https://npmjs.org/package/pkmn [travis-image]: https://travis-ci.org/stephantabor/pkmn.svg?branch=master [travis-url]: https://travis-ci.org/stephantabor/pkmn [daviddm-image]: https://david-dm.org/stephantabor/pkmn.svg?theme=shields.io [daviddm-url]: https://david-dm.org/stephantabor/pkmn +[coveralls-image]: https://coveralls.io/repos/stephantabor/pkmn/badge.svg +[coveralls-url]: https://coveralls.io/r/stephantabor/pkmn diff --git a/gulpfile.js b/gulpfile.js index ee09ec1..8cf34b4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,3 +1,4 @@ +var path = require('path'); var gulp = require('gulp'); var eslint = require('gulp-eslint'); var excludeGitignore = require('gulp-exclude-gitignore'); @@ -5,6 +6,7 @@ var mocha = require('gulp-mocha'); var istanbul = require('gulp-istanbul'); var nsp = require('gulp-nsp'); var plumber = require('gulp-plumber'); +var coveralls = require('gulp-coveralls'); var babel = require('gulp-babel'); var isparta = require('isparta'); @@ -36,9 +38,9 @@ gulp.task('pre-test', function () { gulp.task('test', ['pre-test'], function (cb) { var mochaErr; - gulp.src(['test/unit.js', 'test/integration.js']) + gulp.src('test/**/*.js') .pipe(plumber()) - .pipe(mocha({reporter: 'nyan'})) + .pipe(mocha({reporter: 'spec'})) .on('error', function (err) { mochaErr = err; }) @@ -48,6 +50,15 @@ gulp.task('test', ['pre-test'], function (cb) { }); }); +gulp.task('coveralls', ['test'], function () { + if (!process.env.CI) { + return; + } + + return gulp.src(path.join(__dirname, 'coverage/lcov.info')) + .pipe(coveralls()); +}); + gulp.task('babel', function () { return gulp.src('lib/**/*.js') .pipe(babel()) @@ -55,4 +66,4 @@ gulp.task('babel', function () { }); gulp.task('prepublish', ['nsp', 'babel']); -gulp.task('default', ['static', 'test']); +gulp.task('default', ['static', 'test', 'coveralls']); diff --git a/package.json b/package.json index 9882c9f..9dcc975 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pkmn", - "version": "1.0.5", + "version": "1.0.6", "description": "a node.js pokeapi.co api wrapper", "homepage": "", "repository": "stephantabor/pkmn", @@ -25,15 +25,14 @@ "chai-as-promised": "^5.1.0", "gulp": "^3.6.0", "gulp-babel": "^5.1.0", + "gulp-coveralls": "^0.1.4", "gulp-eslint": "^1.0.0", "gulp-exclude-gitignore": "^1.0.0", "gulp-istanbul": "^0.9.0", "gulp-mocha": "^2.0.0", "gulp-nsp": "^0.4.5", "gulp-plumber": "^1.0.0", - "isparta": "^3.0.3", - "rewire": "^2.3.4", - "sinon": "^1.17.1" + "isparta": "^3.0.3" }, "scripts": { "prepublish": "gulp prepublish",