Comparing version 1.1.1 to 1.2.0
var gulp = global.gulp = require('gulp'), | ||
plugins = global.plugins = require("gulp-load-plugins")( { scope: ['devDependencies'] } );; | ||
gulp.task( 'jshint', function(callback) { | ||
gulp.task( 'eslint', function(callback) { | ||
return gulp.src( './lib/*.js' ) | ||
.pipe( global.plugins.jshint() ) | ||
.pipe( global.plugins.jshint.reporter('default' )); | ||
.pipe( global.plugins.eslint() ) | ||
.pipe( global.plugins.eslint.format() ) | ||
.pipe( global.plugins.eslint.failOnError() ); | ||
} ); | ||
@@ -24,2 +25,2 @@ | ||
gulp.task( 'default', ['jshint', 'mocha', 'doc'] ); | ||
gulp.task( 'default', ['eslint', 'mocha', 'doc'] ); |
@@ -29,3 +29,3 @@ var async = require('async'); | ||
var self = this; | ||
if( this.warpers[division] && warper ){ | ||
if( this.warpers[division] && warper ){ | ||
this.warpers[division] = warper; | ||
@@ -123,3 +123,3 @@ warper.barrel = self; | ||
barrel.affiliate = function( firestarter ){ | ||
this.logger.harconlog( null, 'Affiliate', { name: firestarter.name, division: firestarter.division, context: firestarter.context, events: firestarter.event || firestarter.events }, 'info' ); | ||
this.logger.harconlog( null, 'Affiliate', { name: firestarter.name, division: firestarter.division, context: firestarter.context, events: firestarter.event || firestarter.events }, 'info' ); | ||
@@ -137,2 +137,22 @@ if( this.firestarters.find( function(element){ return element.name === firestarter.name; } ) ) | ||
/** | ||
* Collects matching firestarter instances to the passed {Communication} response object | ||
* | ||
* @method matchingResponse | ||
* @param {Communication} comm The communication instance | ||
*/ | ||
barrel.matchingResponse = function(comm){ | ||
return this.firestarters.filter( function( fs ){ return fs.active && ( (comm.source === fs.name) || (fs.listeningToResponses && fs.matches( comm.division, comm.event ) ) ); } ); | ||
}; | ||
/** | ||
* Collects matching firestarter instances to the passed {Communication} object | ||
* | ||
* @method matching | ||
* @param {Communication} comm The communication instance | ||
*/ | ||
barrel.matching = function(comm){ | ||
return this.firestarters.filter( function( fs ){ return fs.active && fs.matches( comm.division, comm.event ); } ); | ||
}; | ||
/** | ||
* Emits a response in the bus | ||
@@ -148,6 +168,4 @@ * | ||
self.firestarters.forEach( function( fs ){ | ||
if( fs.active && ( (comm.source === fs.name) || (fs.listeningToResponses && fs.matches( comm.division, comm.event ) ) ) ){ | ||
fs.appease( err, comm, responseComms ); | ||
} | ||
self.matchingResponse( comm ).forEach( function( fs ){ | ||
fs.appease( err, comm, responseComms ); | ||
} ); | ||
@@ -168,6 +186,6 @@ }; | ||
var matching = this.firestarters.filter( function( fs ){ return fs.active && fs.matches( comm.division, comm.event ); } ); | ||
var matching = this.matching( comm ); | ||
if( matching.length === 0 ){ | ||
if( self.isSystemEvent( comm.event ) ) return; | ||
if( self.isSystemEvent( comm.event ) ) return false; | ||
@@ -174,0 +192,0 @@ if( comm.callback ) |
@@ -64,3 +64,3 @@ var Cerobee = require('clerobee'); | ||
if( this.error || this.response ){ | ||
if( this.error && this.response ) | ||
if( this.error && this.response ) | ||
throw new Error('Invalid comm: comm has both error and response attributes.'); | ||
@@ -67,0 +67,0 @@ if( this.id === this.originalId ) |
@@ -80,2 +80,2 @@ /* jshint bitwise: false */ | ||
}); | ||
} | ||
} |
@@ -9,3 +9,3 @@ var Communication = require('./Communication'); | ||
function isString(obj) { | ||
return "[object String]" === toString.call(obj); | ||
return toString.call(obj) === "[object String]"; | ||
} | ||
@@ -68,3 +68,3 @@ | ||
var found = isLast( params, ['callback','cb'] ) && isLast( params, 'ignite' ) && isLast( params, 'terms' ); | ||
var found = isLast( params, ['callback', 'cb'] ) && isLast( params, 'ignite' ) && isLast( params, 'terms' ); | ||
@@ -78,3 +78,3 @@ return params; | ||
firestarter.sameDivision = function( division ){ | ||
var div = division || ''; | ||
var div = division || ''; | ||
@@ -189,6 +189,6 @@ if( div === '*' ) | ||
var hasCallback = params.length>0 && isFunction( params[ params.length-1 ] ); | ||
var call_params = self.sliceArguments.apply( self, params ).slice( 1, hasCallback ? params.length-1 : params.length ); | ||
var callParams = self.sliceArguments.apply( self, params ).slice( 1, hasCallback ? params.length-1 : params.length ); | ||
var callback = hasCallback ? params[ params.length-1 ] : null; | ||
var newComm = comm.burst( this.name, event, call_params, callback ); | ||
var newComm = comm.burst( this.name, event, callParams, callback ); | ||
@@ -244,5 +244,5 @@ this.logger.harconlog( null, 'Igniting', {newComm: newComm.shallow(), comm: comm.shallow()} ); | ||
var ids = []; | ||
var _arguments = self.sliceArguments.apply( self, arguments ).slice( 3 ); | ||
var slicedArguments = self.sliceArguments.apply( self, arguments ).slice( 3 ); | ||
event.forEach( function(ev){ | ||
var args = [externalId, division, ev].concat( _arguments ); | ||
var args = [externalId, division, ev].concat( slicedArguments ); | ||
ids.push( this.simpleIgnite.apply( this, args ) ); | ||
@@ -249,0 +249,0 @@ } ); |
@@ -76,11 +76,14 @@ var Firestarter = require('./Firestarter'); | ||
var index = eventName.lastIndexOf( '.' ); | ||
var eventPath = index === -1 ? [] : eventName.substring(0,index).split( '.' ); | ||
var prefix = eventName.substring(0, index); | ||
for(var i = 0, len = eventPath.length; i < len && i < this.pathLength; i+=1) | ||
if( eventPath[i] === '*' ){ | ||
if( i === eventPath.length-1 ) break; | ||
else continue; | ||
} | ||
else if( this.path[i] !== eventPath[i] ) matches = false; | ||
else if( i === eventPath.length-1 && i<this.path.length-1 ) matches = false; | ||
if( this.name !== prefix ){ | ||
var eventPath = index === -1 ? [] : prefix.split( '.' ); | ||
for(var i = 0, len = eventPath.length; i < len && i < this.pathLength; i+=1) | ||
if( eventPath[i] === '*' ){ | ||
if( i === eventPath.length-1 ) break; | ||
else continue; | ||
} | ||
else if( this.path[i] !== eventPath[i] ) matches = false; | ||
else if( i === eventPath.length-1 && i<this.path.length-1 ) matches = false; | ||
} | ||
@@ -87,0 +90,0 @@ if( matches ) |
@@ -8,3 +8,3 @@ var Communication = require('../lib/Communication'); | ||
var VERSION = exports.VERSION = '1.1.1'; | ||
var VERSION = exports.VERSION = '1.2.0'; | ||
@@ -180,3 +180,3 @@ var _ = require('lodash'); | ||
try{ | ||
var componentConfig = options || this.options[fss.name] || {}; | ||
var componentConfig = options || this.options[fss.name] || {}; | ||
componentConfig.inflicter = this; | ||
@@ -183,0 +183,0 @@ object.init( componentConfig, function(err){ if(err){ |
{ | ||
"name": "harcon", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Messaging/Service Bus for the harmonic convergence of node-based enterprise entities.", | ||
@@ -37,3 +37,3 @@ "keywords": [ | ||
"gulp-docco": "latest", | ||
"gulp-jshint": "latest", | ||
"gulp-eslint": "latest", | ||
"gulp-load-plugins": "latest", | ||
@@ -50,3 +50,3 @@ "gulp-mocha": "latest", | ||
}, | ||
"_id": "harcon@1.1.1" | ||
"_id": "harcon@1.2.0" | ||
} |
@@ -44,2 +44,11 @@ var chai = require("chai"); | ||
it('Simple greetings by name is', function(done){ | ||
// Sending a greetings message with 2 parameters and waiting for the proper answer | ||
inflicter.ignite( '0', '', 'marie.simple', 'whatsup?', 'how do you do?', function(err, res){ | ||
should.not.exist(err); should.exist(res); | ||
expect( res ).to.include( 'Bonjour!' ); | ||
done( ); | ||
} ); | ||
}); | ||
it('Simple greetings is', function(done){ | ||
@@ -46,0 +55,0 @@ // Sending a greetings message with 2 parameters and waiting for the proper answer |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
990920
41
16823