Skip to content

Commit 8ecffa8

Browse files
committed
Merge pull request #2 from mrourke/testing
Presentation
2 parents 9932809 + 48acb53 commit 8ecffa8

4 files changed

Lines changed: 23 additions & 78 deletions

File tree

Gruntfile.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,19 @@ module.exports = function(grunt) {
4747
},
4848
},
4949
test: {
50-
5150
src: ['test/fixtures/*.html'],
5251
css: ['test/fixtures/styles.css'],
53-
dest: 'tmp/purestyles.css',
54-
hello: 'hello world'
52+
dest: 'tmp/purestyles.css'
53+
},
54+
goose: {
55+
src: [
56+
'Goose-Windmill/public/app/**/*.html',
57+
'Goose-Windmill/public/app/**/*.js',
58+
'Goose-Windmill/public/index.html'
59+
],
60+
css: ['Goose-Windmill/public/styles/*.css'],
61+
dest: 'tmp/gooseCSS.css'
5562
}
56-
},
57-
58-
// Unit tests.grunt
59-
nodeunit: {
60-
tests: ['test/*_test.js']
6163
}
6264

6365
});
@@ -68,11 +70,10 @@ module.exports = function(grunt) {
6870
// These plugins provide necessary tasks.
6971
grunt.loadNpmTasks('grunt-contrib-jshint');
7072
grunt.loadNpmTasks('grunt-contrib-clean');
71-
grunt.loadNpmTasks('grunt-contrib-nodeunit');
7273

7374
// Whenever the "test" task is run, first clean the "tmp" dir, then run this
7475
// plugin's task(s), then test the result.
75-
grunt.registerTask('test', ['clean', 'purifycss', 'nodeunit']);
76+
grunt.registerTask('test', ['clean', 'purifycss:test', 'nodeunit']);
7677

7778
// By default, lint and run all tests.
7879
grunt.registerTask('default', ['purifycss:test']);

README.md

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -19,72 +19,22 @@ grunt.loadNpmTasks('grunt-purifycss');
1919

2020
## The "purifycss" task
2121

22-
### Overview
23-
In your project's Gruntfile, add a section named `purifycss` to the data object passed into `grunt.initConfig()`.
24-
25-
```js
26-
grunt.initConfig({
27-
purifycss: {
28-
options: {
29-
// Task-specific options go here.
30-
},
31-
your_target: {
32-
// Target-specific file lists and/or options go here.
33-
},
34-
},
35-
});
36-
```
37-
38-
### Options
39-
40-
#### options.separator
41-
Type: `String`
42-
Default value: `', '`
43-
44-
A string value that is used to do something with whatever.
45-
46-
#### options.punctuation
47-
Type: `String`
48-
Default value: `'.'`
49-
50-
A string value that is used to do something else with whatever else.
51-
5222
### Usage Examples
5323

54-
#### Default Options
55-
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.`
24+
In this example, the default options are to specify a target with src files, style files, and an output destination. The plugin will search for style selectors used in the source files, and then output a trimmed down style sheet.
5625

5726
```js
5827
grunt.initConfig({
5928
purifycss: {
6029
options: {},
61-
files: {
62-
'dest/default_options': ['src/testing', 'src/123'],
63-
},
64-
},
65-
});
66-
```
67-
68-
#### Custom Options
69-
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 !!!`
70-
71-
```js
72-
grunt.initConfig({
73-
purifycss: {
74-
options: {
75-
separator: ': ',
76-
punctuation: ' !!!',
77-
},
78-
files: {
79-
'dest/default_options': ['src/testing', 'src/123'],
30+
target: {
31+
src: ['test/fixtures/*.html', 'test/fixtures/*.js'],
32+
css: ['test/fixtures/*.css'],
33+
dest: 'tmp/purestyles.css'
8034
},
8135
},
8236
});
8337
```
8438

8539
## Contributing
86-
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/).
87-
88-
## Release History
89-
_(Nothing yet)_
90-
# grunt-purify-css
40+
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/).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@
3939
],
4040
"dependencies": {
4141
"glob": "^5.0.10",
42-
"purify-css": "^1.0.3"
42+
"purify-css": "^1.0.x"
4343
}
4444
}

tasks/purifycss.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ var purify = require('purify-css');
1313

1414
module.exports = function(grunt) {
1515

16-
// Please see the Grunt documentation for more information regarding task
17-
// creation: http://gruntjs.com/creating-tasks
18-
1916
grunt.registerMultiTask('purifycss', 'Clean unnecessary CSS', function() {
2017
// Merge task-specific and/or target-specific options with these defaults.
2118
var options = this.options({
@@ -24,19 +21,16 @@ module.exports = function(grunt) {
2421
var src = [];
2522
this.data.src.forEach(function(pathPattern) {
2623
var files = glob.sync(pathPattern);
27-
console.log("glob files: ", files);
24+
console.log("Source Files: ", files);
2825
src = src.concat(files);
2926
});
3027

3128
var styles = [];
3229
this.data.css.forEach(function(pathPattern) {
33-
var files = glob.sync(pathPattern);
34-
console.log("glob styles: ", files);
35-
styles = styles.concat(files);
36-
})
37-
38-
console.log(src);
39-
console.log(styles);
30+
var style = glob.sync(pathPattern);
31+
console.log("Style Files: ", style);
32+
styles = styles.concat(style);
33+
});
4034

4135
var pure = purify(src, styles, {write: false, info: true});
4236

0 commit comments

Comments
 (0)