Skip to content

Commit

Permalink
sekeleton source code: ready for TDD
Browse files Browse the repository at this point in the history
  • Loading branch information
kerphi committed Oct 21, 2013
1 parent ea49137 commit f99b2a5
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 0 deletions.
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2013 Stéphane Gully <stephane.gully@gmail.com>

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.
1 change: 1 addition & 0 deletions index.js
@@ -0,0 +1 @@
module.exports = require('./lib/monitorpid');
47 changes: 47 additions & 0 deletions lib/monitorpid.js
@@ -0,0 +1,47 @@
/*jslint node: true, maxlen: 100, maxerr: 50, indent: 2 */
'use strict';

var fs = require('fs');
var util = require('util');
var spawn = require('child_process').spawn;
var EventEmitter = require('events').EventEmitter;

// Constructor
var MonitorPid = function (pid, options) {
var self = this;

self.pid = pid;

self.options = mixin({
// recursive: true,
// watchDirectory: false
}, options);

// ...
};

MonitorPid.prototype = Object.create(EventEmitter.prototype);

MonitorPid.prototype.start = function () {
// ...
};
MonitorPid.prototype.stop = function () {
// ...
};

module.exports = MonitorPid;

/**
* Mixing object properties.
*/
var mixin = function() {
var mix = {};
[].forEach.call(arguments, function(arg) {
for (var name in arg) {
if (arg.hasOwnProperty(name)) {
mix[name] = arg[name];
}
}
});
return mix;
};
30 changes: 30 additions & 0 deletions package.json
@@ -0,0 +1,30 @@
{
"name": "monitor-pid",
"version": "0.0.1",
"description": "Monitors a pid and all its sons",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"repository": {
"type": "git",
"url": "git://github.com/kerphi/node-monitor-pid.git"
},
"keywords": [
"monitor",
"pid",
"pidstat",
"pstree",
"csv",
"statistics"
],
"author": "Stéphane Gully <stephane.gully@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/kerphi/node-monitor-pid/issues"
},
"devDependencies": {
"chai": "~1.8.1",
"mocha": "~1.13.0"
}
}
23 changes: 23 additions & 0 deletions test/monitor-pid.js
@@ -0,0 +1,23 @@
/*jslint node: true, maxlen: 100, maxerr: 50, indent: 2 */
'use strict';

var expect = require('chai').expect;
var MonitorPid = require('../index.js');

before(function (){

});

describe('MonitorPid', function () {

it('should return an error if started on an unknown pid @1', function (done) {
var i = 0;
expect(i, 'xxx').to.be.numeric;
done();
});

});

after(function (){

});

0 comments on commit f99b2a5

Please sign in to comment.