'use strict';

module.exports = function(grunt) {

  var files = ['*.js', 'test/**/*.js'];

  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),

    jshint: {
      all: files,
      options: grunt.file.readJSON('.jshintrc')
    },

    jscs: {
      src: files,
      options: {
        config: '.jscsrc',
        verbose: true,
        fix: true
      }
    },

    watch: {
      js: {
        files: files,
        tasks: ['test']
      },
      doc: {
        files: files,
        tasks: ['jsdoc', 'reload:docs']
      }
    },

    mochaTest: {
      test: {
        options: {
          reporter: 'spec'
        },
        src: ['test/**/*.js']
      }
    },

    jsdoc : {
      dist: {
        src: files,
        options: {
          configure: '.jsdoc',
          destination: 'doc/api',
          'private': false,
          template: 'node_modules/ink-docstrap/template'
        }
      }
    }

  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-jsdoc');
  grunt.loadNpmTasks('grunt-jscs');
  grunt.loadNpmTasks('grunt-release');
  grunt.loadNpmTasks('grunt-mocha-test');

  grunt.registerTask('default', ['watch:js']);
  grunt.registerTask('test', ['jshint', 'jscs', 'mochaTest']);

  grunt.registerTask('docs', ['watch:doc']);

};
