Skip to content

Commit d46db9b

Browse files
author
Marc Rooding
committed
First working Gulp implementation based on streams
1 parent b491123 commit d46db9b

11 files changed

+157
-172
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules
22
npm-debug.log
33
tmp
44
.DS_Store
5-
.idea
5+
.idea
6+
output/

Gruntfile.js

Lines changed: 0 additions & 64 deletions
This file was deleted.

README.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
# grunt-protractor-cucumber-html-report
1+
# gulp-protractor-cucumber-html-report
22

33
> Generate html report from JSON file returned by cucumber js json formatter
4+
>
45
56
## Getting Started
6-
This plugin requires Grunt `~0.4.5`
7+
This plugin requires Grunt `~3.9.0`
78

8-
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:
9+
If you haven't used [Gulp](http://gulpjs.com/) before, be sure to check out the [Getting Started](https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md) guide, as it explains how to create a Gulpfile as well as install and use Gulp plugins. Once you're familiar with that process, you may install this plugin with this command:
910

1011
```shell
11-
npm install grunt-protractor-cucumber-html-report --save-dev
12+
npm install gulp-protractor-cucumber-html-report --save-dev
1213
```
1314

14-
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
15+
Once the plugin has been installed, it may be enabled inside your Gulpfile with this line of JavaScript:
1516

1617
```js
17-
grunt.loadNpmTasks('grunt-protractor-cucumber-html-report');
18+
var reporter = require('gulp-protractor-cucumber-html-report');
1819
```
1920

2021
## The "protractor-cucumber-html-report" task
2122

2223
### Overview
23-
In your project's Gruntfile, add a section named `protractor-cucumber-html-report` to the data object passed into `grunt.initConfig()`.
24+
In your project's Gulpfile, add a section named `protractor-cucumber-html-report` to the data object passed into `grunt.initConfig()`.
2425

2526
```js
2627
grunt.initConfig({
@@ -37,17 +38,17 @@ grunt.initConfig({
3738

3839
### Options
3940

40-
#### options.separator
41+
#### dest
4142
Type: `String`
42-
Default value: `', '`
43+
Default value: `'.'`
4344

44-
A string value that is used to do something with whatever.
45+
The output directory for the HTML report relative from the Gulpfile
4546

46-
#### options.punctuation
47+
#### filename
4748
Type: `String`
48-
Default value: `'.'`
49+
Default value: `'report.html'`
4950

50-
A string value that is used to do something else with whatever else.
51+
The filename for the HTML report
5152

5253
### Usage Examples
5354

@@ -68,5 +69,9 @@ grunt.initConfig({
6869
## Contributing
6970
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/).
7071

72+
## Copyright
73+
74+
Copyright for portions of project [gulp-protractor-cucumber-html-report](https://github.com/mrooding/gulp-protractor-cucumber-html-report) are held by Robert Hilscher, 2015 as part of project [grunt-protractor-cucumber-html-report](https://github.com/robhil/grunt-protractor-cucumber-html-report). All other copyright for project [gulp-protractor-cucumber-html-report](https://github.com/mrooding/gulp-protractor-cucumber-html-report) are held by Marc Rooding, 2015.
75+
7176
## Release History
72-
_(Nothing yet)_
77+
_(Nothing yet)_

gulpfile.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
var gulp = require('gulp'),
4+
jshint = require('gulp-jshint');
5+
6+
gulp.task('develop', function() {
7+
function scripts() {
8+
return gulp.src('*.js')
9+
.pipe(jshint())
10+
.pipe(jshint.reporter('jshint-stylish'));
11+
}
12+
13+
var watcher = gulp.watch('*.js');
14+
watcher.on('change', scripts);
15+
16+
return scripts();
17+
});

index.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
var through = require('through2'),
2+
gutil = require('gulp-util'),
3+
formatter = require('./lib/html_formatter'),
4+
path = require('path'),
5+
fs = require('fs-extra'),
6+
PluginError = gutil.PluginError;
7+
8+
var PLUGIN_NAME = 'gulp-protractor-cucumber-html-reporter';
9+
10+
function gulpProtractorCucumberHtmlReport(opts) {
11+
var currentDir = __dirname;
12+
13+
opts = opts || {};
14+
if (!opts.dest) {
15+
opts.dest = '.';
16+
}
17+
if (!opts.filename) {
18+
opts.filename = 'report.html';
19+
}
20+
opts.templates = {
21+
featureTemplate: path.join(currentDir, './templates/feature_template.html'),
22+
headerTemplate: path.join(currentDir, './templates/header_template.html'),
23+
reportTemplate: path.join(currentDir, './templates/report_template.html'),
24+
scenarioTemplate: path.join(currentDir, './templates/scenario_template.html'),
25+
stepTemplate: path.join(currentDir, './templates/step_template.html')
26+
};
27+
28+
return through.obj(function (file, enc, cb) {
29+
if (file.isNull()) {
30+
return cb(null, file);
31+
}
32+
33+
if (file.isBuffer()) {
34+
var testResults = JSON.parse(file.contents);
35+
36+
fs.writeFileSync(opts.dest + '/' + opts.filename, formatter.generateReport(testResults, opts.templates));
37+
38+
fs.copySync(currentDir + '/templates/assets', opts.dest + '/assets/');
39+
40+
gutil.log('File ' + opts.filename + ' has been created in \'' + opts.dest + '\' directory');
41+
} else {
42+
throw new PluginError(PLUGIN_NAME, '[Error] Currently only buffers are supported');
43+
}
44+
45+
return cb(null, file);
46+
});
47+
}
48+
49+
// Exporting the plugin main function
50+
module.exports = gulpProtractorCucumberHtmlReport;

package.json

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,50 @@
11
{
2-
"name": "grunt-protractor-cucumber-html-report",
2+
"name": "gulp-protractor-cucumber-html-report",
33
"description": "Generate html report from JSON file returned by cucumber-js json formatter",
4-
"version": "0.0.8",
5-
"homepage": "https://github.com/robhil/grunt-protractor-cucumber-html-report",
4+
"version": "0.0.1",
5+
"homepage": "https://github.com/mrooding/gulp-protractor-cucumber-html-report",
66
"author": {
7-
"name": "Hilscher, Robert",
8-
"email": "robert.hilscher@pearson.com"
7+
"name": "Rooding, Marc",
8+
"email": "mrooding@xebia.com"
99
},
1010
"repository": {
1111
"type": "git",
12-
"url": "git://github.com/robhil/grunt-protractor-cucumber-html-report.git"
12+
"url": "git://github.com/mrooding/gulp-protractor-cucumber-html-report.git"
1313
},
1414
"bugs": {
15-
"url": "https://github.com/robhil/grunt-protractor-cucumber-html-report/issues"
15+
"url": "https://github.com/mrooding/gulp-protractor-cucumber-html-report/issues"
1616
},
1717
"licenses": [
1818
{
1919
"type": "MIT",
20-
"url": "https://github.com/roberthilscher/grunt-protractor-cucumber-html-report/blob/master/LICENSE-MIT"
20+
"url": "https://github.com/mrooding/gulp-protractor-cucumber-html-report/blob/master/LICENSE-MIT"
2121
}
2222
],
2323
"engines": {
2424
"node": ">= 0.8.0"
2525
},
2626
"scripts": {
27-
"test": "grunt test"
27+
"test": "mocha"
2828
},
29-
"devDependencies": {
30-
"grunt-contrib-jshint": "^0.9.2",
31-
"grunt-contrib-clean": "^0.5.0",
32-
"grunt-contrib-nodeunit": "^0.3.3",
33-
"grunt": "~0.4.5"
29+
"files": [
30+
"index.js"
31+
],
32+
"dependencies": {
33+
"gulp-util": "^3.0.0",
34+
"through2": "^0.6.1"
3435
},
35-
"peerDependencies": {
36-
"grunt": "~0.4.5"
36+
"devDependencies": {
37+
"chai": "^3.2.0",
38+
"cucumber": "^0.5.2",
39+
"event-stream": "^3.3.1",
40+
"fs-extra": "^0.22.1",
41+
"gulp": "^3.9.0",
42+
"gulp-jshint": "^1.11.2",
43+
"jshint-stylish": "^2.0.1",
44+
"mocha": "^2.2.5",
45+
"vinyl": "^0.5.0"
3746
},
3847
"keywords": [
39-
"gruntplugin"
48+
"gulpplugin"
4049
]
41-
}
50+
}

tasks/protractor-cucumber-html-report.js

Lines changed: 0 additions & 57 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

test/protractor_cucumber_html_report_test.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)