mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-10 23:19:15 +00:00
change exposed notifier api
This commit is contained in:
parent
a7f03343ac
commit
918a42fff5
6
app.js
6
app.js
@ -9,12 +9,11 @@ var env = process.env.NODE_ENV || 'development',
|
||||
_ = require('underscore'),
|
||||
Reader = require('./lib/reader').Reader,
|
||||
Notifier = require('./lib/notifier').Notifier,
|
||||
BaseNotifierTransport = require('./lib/notifier/transport/base').Transport,
|
||||
ConsoleNotifierTransport = require('./lib/notifier/transport/console').Transport,
|
||||
ProjectsCollection = require('./lib/project').ProjectsCollection,
|
||||
BuildsCollection = require('./lib/build').BuildsCollection,
|
||||
libLogger = require('./lib/logger'),
|
||||
libReader = require('./lib/reader'),
|
||||
libNotifier = require('./lib/notifier'),
|
||||
libNode = require('./lib/node'),
|
||||
libCommand = require('./lib/command'),
|
||||
libExecutor = require('./lib/executor'),
|
||||
@ -63,9 +62,9 @@ app.httpServer.addRequestListener(function(req, res, next) {
|
||||
});
|
||||
|
||||
app.lib = {};
|
||||
app.lib.BaseNotifierTransport = BaseNotifierTransport;
|
||||
app.lib.logger = libLogger;
|
||||
app.lib.reader = libReader;
|
||||
app.lib.notifier = libNotifier;
|
||||
app.lib.command = libCommand;
|
||||
app.lib.executor = libExecutor;
|
||||
app.lib.scm = libScm;
|
||||
@ -223,7 +222,6 @@ Steppy(
|
||||
});
|
||||
|
||||
app.notifier = new Notifier({db: db});
|
||||
app.notifier.register('console', ConsoleNotifierTransport);
|
||||
|
||||
completeUncompletedBuilds(this.slot());
|
||||
},
|
||||
|
@ -2,29 +2,36 @@
|
||||
|
||||
var Steppy = require('twostep').Steppy,
|
||||
_ = require('underscore'),
|
||||
logger = require('../logger')('notifier');
|
||||
logger = require('../logger')('notifier'),
|
||||
BaseNotifierTransport = require('./transport/base').Transport,
|
||||
ConsoleNotifierTransport = require('./transport/console').Transport;
|
||||
|
||||
var constructors = {
|
||||
console: ConsoleNotifierTransport
|
||||
};
|
||||
|
||||
exports.register = function(type, constructor) {
|
||||
constructors[type] = constructor;
|
||||
};
|
||||
|
||||
exports.BaseNotifierTransport = BaseNotifierTransport;
|
||||
|
||||
|
||||
function Notifier(params) {
|
||||
this.db = params.db;
|
||||
|
||||
this.constructors = {};
|
||||
this.instances = {};
|
||||
}
|
||||
|
||||
exports.Notifier = Notifier;
|
||||
|
||||
Notifier.prototype.register = function(type, constructor) {
|
||||
this.constructors[type] = constructor;
|
||||
};
|
||||
|
||||
Notifier.prototype.init = function(params, callback) {
|
||||
var self = this;
|
||||
|
||||
Steppy(
|
||||
function() {
|
||||
var initGroup = this.makeGroup();
|
||||
_(self.constructors).each(function(Constructor, type) {
|
||||
_(constructors).each(function(Constructor, type) {
|
||||
self.instances[type] = new Constructor();
|
||||
self.instances[type].init(params[type], initGroup.slot());
|
||||
});
|
||||
|
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var Notifier = require('../lib/notifier').Notifier,
|
||||
var libNotifier = require('../lib/notifier'),
|
||||
Notifier = libNotifier.Notifier,
|
||||
expect = require('expect.js'),
|
||||
sinon = require('sinon'),
|
||||
_ = require('underscore');
|
||||
@ -19,7 +20,7 @@ describe('notifier module', function() {
|
||||
|
||||
describe('test notifier', function() {
|
||||
it('should be rigestered', function() {
|
||||
notifier.register('test', TestTransport);
|
||||
libNotifier.register('test', TestTransport);
|
||||
});
|
||||
|
||||
it('should be intialized without errors', function(done) {
|
||||
|
Loading…
Reference in New Issue
Block a user