Skip to content
Browse files

run grunt init:plugin and adopt defaults

  • Loading branch information...
1 parent 7b4c859 commit 5df0752dad9d02260d33cf8fe15bc84fac8f5810 @dvberkel committed Nov 18, 2012
Showing with 183 additions and 30 deletions.
  1. +1 −0 .npmignore
  2. +22 −0 LICENSE-MIT
  3. +28 −18 README.md
  4. +2 −0 bin/grunt-peg
  5. +40 −0 grunt.js
  6. +26 −12 package.json
  7. +30 −0 tasks/peg.js
  8. +34 −0 test/peg_test.js
View
1 .npmignore
@@ -0,0 +1 @@
+/node_modules/
View
22 LICENSE-MIT
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Daan van Berkel
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
View
46 README.md
@@ -1,37 +1,47 @@
grunt-peg
=========
-grunt-peg provides a [grunt][1] multi task that generates parsers from
-[PEG grammars][2].
+A grunt multi task that generates parsers from PEG grammars.
Getting Started
---------------
-Install this grunt plugin next to your project's [grunt.js
-gruntfile][3] with: `npm install grunt-peg`
+Install this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: `npm install grunt-peg`
Then add this line to your project's `grunt.js` gruntfile:
- grunt.loadNpmTasks('grunt-peg');
+```javascript
+grunt.loadNpmTasks('grunt-peg');
+```
+
+[grunt]: http://gruntjs.com/
+[getting_started]: https://github.com/gruntjs/grunt/blob/master/docs/getting_started.md
Documentation
-------------
- grunt.initConfig({
- peg: {
- grammar: "grammar/example.peg",
- exportVar: "Example.parser",
- outputFile: "grammar/example.js"
- }
- });
+```javascript
+grunt.initConfig({
+ peg: {
+ grammar: "grammar/example.peg",
+ exportVar: "Example.parser",
+ outputFile: "grammar/example.js"
+ }
+});
+```
+
+Contributing
+------------
+
+In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt][grunt].
+
+Release History
+---------------
+
+_(Nothing yet)_
License
-------
-Copyright (c) 2012 Daan van Berkel
+Copyright (c) 2012 Daan van Berkel
Licensed under the MIT license.
-
-[1]: http://gruntjs.com/ "Grunt Homepage"
-[2]: http://en.wikipedia.org/wiki/Parsing_expression_grammar "Wikipedia on PEG grammars"
-[3]: https://github.com/gruntjs/grunt/blob/master/docs/getting_started.md "Getting started documentation for grunt"
-
View
2 bin/grunt-peg
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('grunt').npmTasks('grunt-peg').cli();
View
40 grunt.js
@@ -0,0 +1,40 @@
+module.exports = function(grunt) {
+
+ // Project configuration.
+ grunt.initConfig({
+ test: {
+ files: ['test/**/*.js']
+ },
+ lint: {
+ files: ['grunt.js', 'tasks/**/*.js', 'test/**/*.js']
+ },
+ watch: {
+ files: '<config:lint.files>',
+ tasks: 'default'
+ },
+ jshint: {
+ options: {
+ curly: true,
+ eqeqeq: true,
+ immed: true,
+ latedef: true,
+ newcap: true,
+ noarg: true,
+ sub: true,
+ undef: true,
+ boss: true,
+ eqnull: true,
+ node: true,
+ es5: true
+ },
+ globals: {}
+ }
+ });
+
+ // Load local tasks.
+ grunt.loadTasks('tasks');
+
+ // Default task.
+ grunt.registerTask('default', 'lint test');
+
+};
View
38 package.json
@@ -1,24 +1,38 @@
{
"name": "grunt-peg",
- "version": "0.0.0",
"description": "A grunt multi task that generates parsers from PEG grammars.",
- "main": "index.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
+ "version": "0.0.0",
+ "homepage": "https://github.com/dvberkel/grunt-peg",
+ "author": {
+ "name": "Daan van Berkel",
+ "email": "daan.v.berkel.1980@gmail.com",
+ "url": "http://dvberkel.github.com/"
},
"repository": {
"type": "git",
"url": "git://github.com/dvberkel/grunt-peg.git"
},
- "keywords": [
- "gruntplugin"
+ "bugs": {
+ "url": "https://github.com/dvberkel/grunt-peg/issues"
+ },
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/dvberkel/grunt-peg/blob/master/LICENSE-MIT"
+ }
],
- "author": "Daan van Berkel",
- "license": "MIT",
- "dependencies": {
- "pegjs": "0.7.0"
+ "main": "grunt.js",
+ "bin": "bin/grunt-peg",
+ "engines": {
+ "node": "*"
+ },
+ "scripts": {
+ "test": "./node_modules/.bin/grunt test"
},
"devDependencies": {
- "grunt": "*"
- }
+ "grunt": "~0.3.17"
+ },
+ "keywords": [
+ "gruntplugin"
+ ]
}
View
30 tasks/peg.js
@@ -0,0 +1,30 @@
+/*
+ * grunt-peg
+ * https://github.com/dvberkel/grunt-peg
+ *
+ * Copyright (c) 2012 Daan van Berkel
+ * Licensed under the MIT license.
+ */
+
+module.exports = function(grunt) {
+
+ // Please see the grunt documentation for more information regarding task and
+ // helper creation: https://github.com/gruntjs/grunt/blob/master/docs/toc.md
+
+ // ==========================================================================
+ // TASKS
+ // ==========================================================================
+
+ grunt.registerTask('peg', 'Your task description goes here.', function() {
+ grunt.log.write(grunt.helper('peg'));
+ });
+
+ // ==========================================================================
+ // HELPERS
+ // ==========================================================================
+
+ grunt.registerHelper('peg', function() {
+ return 'peg!!!';
+ });
+
+};
View
34 test/peg_test.js
@@ -0,0 +1,34 @@
+var grunt = require('grunt');
+
+/*
+ ======== A Handy Little Nodeunit Reference ========
+ https://github.com/caolan/nodeunit
+
+ Test methods:
+ test.expect(numAssertions)
+ test.done()
+ Test assertions:
+ test.ok(value, [message])
+ test.equal(actual, expected, [message])
+ test.notEqual(actual, expected, [message])
+ test.deepEqual(actual, expected, [message])
+ test.notDeepEqual(actual, expected, [message])
+ test.strictEqual(actual, expected, [message])
+ test.notStrictEqual(actual, expected, [message])
+ test.throws(block, [error], [message])
+ test.doesNotThrow(block, [error], [message])
+ test.ifError(value)
+*/
+
+exports['peg'] = {
+ setUp: function(done) {
+ // setup here
+ done();
+ },
+ 'helper': function(test) {
+ test.expect(1);
+ // tests here
+ test.equal(grunt.helper('peg'), 'peg!!!', 'should return the correct value.');
+ test.done();
+ }
+};

0 comments on commit 5df0752

Please sign in to comment.
Something went wrong with that request. Please try again.