Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mdasberg committed Nov 19, 2013
0 parents commit a43852e
Show file tree
Hide file tree
Showing 20 changed files with 711 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
node_modules
npm-debug.log
tmp
13 changes: 13 additions & 0 deletions .jshintrc
@@ -0,0 +1,13 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"boss": true,
"eqnull": true,
"node": true
}
109 changes: 109 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,109 @@
/*
* grunt-karma-sonar
* https://github.com/mdasberg/grunt-karma-sonar
*
* Copyright (c) 2013 Mischa Dasberg
* Licensed under the MIT license.
*/

'use strict';

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'<%= nodeunit.tests %>'
],
options: {
jshintrc: '.jshintrc'
}
},

// Before generating any new files, remove any previously-created files.
clean: {
tests: ['.tmp']
},

// Configuration to be run (and then tested).
karma_sonar: {
default_options: {
project: {
key: 'grunt-sonar',
name: 'Grunt sonar plugin',
version: '0.1.0'
},
sources: [
{
path: 'sources/first/scripts',
prefix: 'sources/first',
coverageReport: 'results/first/lcov.info',
testReport: 'results/first/junit.xml'
}
,
{
path: 'sources/second/scripts',
prefix: 'sources/second',
coverageReport: 'results/second/lcov.info',
testReport: 'results/second/junit.xml'
}
],
exclusions: []
},
custom_options: {
options: {
defaultOutputDir: '.tmp/sonar/custom_options/',
instance: {
hostUrl : 'http://localhost:20001',
jdbcUrl : 'jdbc:h2:tcp://localhost:20003/sonar',
login: 'admin',
password: 'admin'
}
},
project: {
key: 'grunt-sonar',
name: 'Grunt sonar plugin',
version: '0.1.0'
},
sources: [
{
path: 'sources/first/scripts',
prefix: 'sources/first',
testReport: 'results/first/junit.xml'
},
{
path: 'sources/second/scripts',
prefix: 'sources/second',
coverageReport: 'results/second/lcov.info'

}
],
exclusions: []
}
},

// Unit tests.
nodeunit: {
tests: ['test/*_test.js']
}
});

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

// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-nodeunit');

// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'karma_sonar', 'nodeunit']);

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

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

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-karma-sonar

> Grunt plugin for integrating karma reports with sonar
## 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-karma-sonar --save-dev
```

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

```js
grunt.loadNpmTasks('grunt-karma-sonar');
```

## The "karma_sonar" task

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

```js
grunt.initConfig({
karma_sonar: {
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({
karma_sonar: {
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({
karma_sonar: {
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)_
42 changes: 42 additions & 0 deletions package.json
@@ -0,0 +1,42 @@
{
"name": "grunt-karma-sonar",
"description": "Grunt plugin for integrating karma reports with sonar",
"version": "0.1.0",
"homepage": "https://github.com/mdasberg/grunt-karma-sonar",
"author": {
"name": "Mischa Dasberg",
"email": "mischa@dasberg.nl"
},
"repository": {
"type": "git",
"url": "git://github.com/mdasberg/grunt-karma-sonar.git"
},
"bugs": {
"url": "https://github.com/mdasberg/grunt-karma-sonar/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/mdasberg/grunt-karma-sonar/blob/master/LICENSE-MIT"
}
],
"main": "Gruntfile.js",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt test"
},
"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": [
"gruntplugin"
]
}
12 changes: 12 additions & 0 deletions results/first/junit.xml
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<testsuites>
<testsuite name="PhantomJS 1.9.2 (Mac OS X)" package="undefined" timestamp="2013-11-18T22:28:40" id="0" hostname="atlantis" tests="1" errors="0" failures="0" time="0.003">
<properties>
<property name="browser.fullName" value="Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.2 Safari/534.34"/>
</properties>
<testcase name="should return hello first app" time="0.003" classname="PhantomJS 1.9.2 (Mac OS X).First app"/>
<system-out><![CDATA[
]]></system-out>
<system-err/>
</testsuite>
</testsuites>
17 changes: 17 additions & 0 deletions results/first/lcov.info
@@ -0,0 +1,17 @@
TN:
SF:./scripts/app-one.js
FN:1,App
FN:6,(anonymous_2)
FNF:2
FNH:2
FNDA:1,App
FNDA:1,(anonymous_2)
DA:1,1
DA:2,1
DA:6,1
DA:7,1
LF:4
LH:4
BRF:0
BRH:0
end_of_record
12 changes: 12 additions & 0 deletions results/second/junit.xml
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<testsuites>
<testsuite name="PhantomJS 1.9.2 (Mac OS X)" package="undefined" timestamp="2013-11-18T22:28:40" id="0" hostname="atlantis" tests="1" errors="0" failures="0" time="0.003">
<properties>
<property name="browser.fullName" value="Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.2 Safari/534.34"/>
</properties>
<testcase name="should return hello second app" time="0.003" classname="PhantomJS 1.9.2 (Mac OS X).Second app"/>
<system-out><![CDATA[
]]></system-out>
<system-err/>
</testsuite>
</testsuites>
17 changes: 17 additions & 0 deletions results/second/lcov.info
@@ -0,0 +1,17 @@
TN:
SF:./scripts/app-two.js
FN:1,App
FN:6,(anonymous_2)
FNF:2
FNH:2
FNDA:1,App
FNDA:1,(anonymous_2)
DA:1,1
DA:2,1
DA:6,1
DA:7,1
LF:4
LH:4
BRF:0
BRH:0
end_of_record
10 changes: 10 additions & 0 deletions sources/first/scripts/app-one.js
@@ -0,0 +1,10 @@
function App() {
who = {
name: 'first app'
};

this.hello = function() {
return 'hello ' + who.name;
}
}

9 changes: 9 additions & 0 deletions sources/first/test/app-oneSpec.js
@@ -0,0 +1,9 @@
'use strict';

/* jasmine specs for the first app. */
describe('First app', function () {

it("should return hello first app", function () {
expect(new App().hello()).toBe('hello first app');
});
});
10 changes: 10 additions & 0 deletions sources/second/scripts/app-two.js
@@ -0,0 +1,10 @@
function App() {
who = {
name: 'second app'
};

this.hello = function() {
return 'hello ' + who.name;
}
}

9 changes: 9 additions & 0 deletions sources/second/test/app-twoSpec.js
@@ -0,0 +1,9 @@
'use strict';

/* jasmine specs for the second app. */
describe('Second app', function () {

it("should return hello second app", function () {
expect(new App().hello()).toBe('hello second app');
});
});

0 comments on commit a43852e

Please sign in to comment.