Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BradDenver committed Aug 7, 2013
0 parents commit 55bf3ce
Show file tree
Hide file tree
Showing 12 changed files with 293 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
node_modules
npm-debug.log
tmp

.DS_Store
14 changes: 14 additions & 0 deletions .jshintrc
@@ -0,0 +1,14 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"boss": true,
"eqnull": true,
"node": true,
"es5": true
}
31 changes: 31 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,31 @@
/*
* grunt-preen
* https://github.com/braddenver/grunt-preen
*
* Copyright (c) 2013 Brad Denver
* Licensed under the MIT license.
*/

'use strict';

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({

// Configuration to be run (and then tested).
preen: {
options: {
preview: false
},
},

});

// Actually load this plugin's task(s).
grunt.loadTasks('tasks');

// By default, lint and run all tests.
grunt.registerTask('default', ['preen']);

};
22 changes: 22 additions & 0 deletions LICENSE-MIT
@@ -0,0 +1,22 @@
Copyright (c) 2013 Brad Denver

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.
89 changes: 89 additions & 0 deletions README.md
@@ -0,0 +1,89 @@
# grunt-preen

> a grunt task plugin to run preen
## Getting Started
This plugin requires Grunt `~0.4.1`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-preen --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-preen');
```

## The "preen" task

### Overview
In your project's Gruntfile, add a section named `preen` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
preen: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
```

### Options

#### options.separator
Type: `String`
Default value: `', '`

A string value that is used to do something with whatever.

#### options.punctuation
Type: `String`
Default value: `'.'`

A string value that is used to do something else with whatever else.

### Usage Examples

#### Default Options
In this example, the default options are used to do something with whatever. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result would be `Testing, 1 2 3.`

```js
grunt.initConfig({
preen: {
options: {},
files: {
'dest/default_options': ['src/testing', 'src/123'],
},
},
})
```

#### Custom Options
In this example, custom options are used to do something else with whatever else. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result in this case would be `Testing: 1 2 3 !!!`

```js
grunt.initConfig({
preen: {
options: {
separator: ': ',
punctuation: ' !!!',
},
files: {
'dest/default_options': ['src/testing', 'src/123'],
},
},
})
```

## 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](http://gruntjs.com/).

## Release History
_(Nothing yet)_
48 changes: 48 additions & 0 deletions package.json
@@ -0,0 +1,48 @@
{
"name": "grunt-preen",
"description": "a grunt task plugin to run preen",
"version": "0.1.0",
"homepage": "https://github.com/braddenver/grunt-preen",
"author": {
"name": "Brad Denver",
"email": "brad.denver@gmail.com",
"url": "braddenver.com"
},
"repository": {
"type": "git",
"url": "git://github.com/braddenver/grunt-preen.git"
},
"bugs": {
"url": "https://github.com/braddenver/grunt-preen/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/braddenver/grunt-preen/blob/master/LICENSE-MIT"
}
],
"main": "Gruntfile.js",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt test"
},
"dependencies": {
"preen": "*"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt": "~0.4.1"
},
"peerDependencies": {
"grunt": "~0.4.1"
},
"keywords": [
"bower",
"gruntplugin",
"preen"
]
}
32 changes: 32 additions & 0 deletions tasks/preen.js
@@ -0,0 +1,32 @@
/*
* grunt-preen
* https://github.com/braddenver/grunt-preen
*
* Copyright (c) 2013 Brad Denver
* Licensed under the MIT license.
*/

'use strict';

module.exports = function(grunt) {

// Please see the Grunt documentation for more information regarding task
// creation: http://gruntjs.com/creating-tasks

var preen = require('preen');

grunt.registerTask('preen', 'Preen bower packages according to preen property of bower.json.', function() {
// Merge task-specific and/or target-specific options with these defaults.
var options = this.options({
preview: true
});

// If --debug was specified
//if (grunt.option('debug'))
//options.debug = true;

preen.preen(options);
grunt.log.writeln('Preen Complete.');
});

};
1 change: 1 addition & 0 deletions test/expected/custom_options
@@ -0,0 +1 @@
Testing: 1 2 3 !!!
1 change: 1 addition & 0 deletions test/expected/default_options
@@ -0,0 +1 @@
Testing, 1 2 3.
1 change: 1 addition & 0 deletions test/fixtures/123
@@ -0,0 +1 @@
1 2 3
1 change: 1 addition & 0 deletions test/fixtures/testing
@@ -0,0 +1 @@
Testing
48 changes: 48 additions & 0 deletions test/preen_test.js
@@ -0,0 +1,48 @@
'use strict';

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.preen = {
setUp: function(done) {
// setup here if necessary
done();
},
default_options: function(test) {
test.expect(1);

var actual = grunt.file.read('tmp/default_options');
var expected = grunt.file.read('test/expected/default_options');
test.equal(actual, expected, 'should describe what the default behavior is.');

test.done();
},
custom_options: function(test) {
test.expect(1);

var actual = grunt.file.read('tmp/custom_options');
var expected = grunt.file.read('test/expected/custom_options');
test.equal(actual, expected, 'should describe what the custom option(s) behavior is.');

test.done();
},
};

0 comments on commit 55bf3ce

Please sign in to comment.