Skip to content

Commit

Permalink
added files
Browse files Browse the repository at this point in the history
  • Loading branch information
baelter committed Nov 18, 2013
1 parent 28d1ba9 commit 95a5483
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
npm-debug.log
tmp
*.idea
*.iml
13 changes: 13 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -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
}
78 changes: 78 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* grunt-rsimulatorjs
* https://github.com/baelter/grunt-rsimulatorjs
*
* Copyright (c) 2013 Anders Bälter
* 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).
rsimulatorjs: {
default_options: {
options: {
}
},
custom_options: {
options: {
simulator: {
port: 6001,
rootPath: './mockmock',
useRootRelativePath: false
},
proxy: {
port : 8001,
pathnameOnly : false,
router : {
'/hoo' : '127.0.0.1:' + 6001,
'' : '127.0.0.1:' + 9001
}
}
}
}
},

// 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', 'rsimulatorjs', 'nodeunit']);

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

};
22 changes: 22 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2013 Anders Bälter

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.
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "grunt-rsimulatorjs",
"description": "Grunt plugin for rsimulatorjs-server",
"version": "0.1.0",
"homepage": "https://github.com/baelter/grunt-rsimulatorjs",
"author": {
"name": "Anders Bälter",
"email": "[email protected]"
},
"repository": {
"type": "git",
"url": "https://github.com/baelter/grunt-rsimulatorjs.git"
},
"bugs": {
"url": "https://github.com/baelter/grunt-rsimulatorjs/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/baelter/grunt-rsimulatorjs/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"
],
"dependencies": {
"rsimulatorjs-server": "~0.3.9"
}
}
50 changes: 50 additions & 0 deletions tasks/rsimulatorjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* grunt-rsimulatorjs
* https://github.com/baelter/grunt-rsimulatorjs
*
* Copyright (c) 2013 Anders Bälter
* 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
grunt.registerMultiTask('rsimulatorjs', 'Start rsimulatorjs', function () {
var rsimulatorjsServer = require('rsimulatorjs-server'),
route,
options = this.options({
simulator: {
port: 9005,
rootPath: './mocked-rest-api',
useRootRelativePath: true
},
proxy: {
port : 9004,
pathnameOnly : true,
router : {
'/service' : '127.0.0.1:' + 9005,
'' : '127.0.0.1:' + 9001
}
}
}),
serverOptions = {
simulatorConfig: options.simulator,
proxyConfig: {
port: options.proxy.port,
options: {
pathnameOnly: options.proxy.pathnameOnly,
router: options.proxy.router
}
}
};
rsimulatorjsServer(serverOptions);
grunt.log.writeln('Started rsimulator on ' + options.simulator.port + ' with proxy on ' + options.proxy.port + ' with the following routes:');
for(route in options.proxy.router) {
grunt.log.writeln(route + ' : ' + options.proxy.router[route]);
}
});

};

0 comments on commit 95a5483

Please sign in to comment.