Updated diagnostics wiretap with ability to use regex for testing matches

This commit is contained in:
Jim Cowart 2012-04-26 09:42:53 -04:00
parent ccb4706a12
commit 3441008c1f
15 changed files with 38 additions and 14 deletions

BIN
.DS_Store vendored

Binary file not shown.

View file

@ -22,5 +22,5 @@ cp ./lib/standard/postal.* ./example/standard/js
cp ./lib/amd/postal.* ./example/amd/js/libs/postal
cp ./lib/amd/postal.js ./example/node/client/js/lib
cp ./lib/amd/postal.diagnostics.js ./example/node/client/js/lib
cp ./lib/node/postal.diagnostics.js ./example/node/messaging
cp ./lib/node/diags/postal.diagnostics.js ./example/node/messaging
cp ./lib/node/postal.js ./example/node/messaging

View file

@ -8,7 +8,10 @@ define( [ "postal", "underscore" ], function ( postal, _, undefined ) {
_.each( filter, function ( item, key ) {
if ( env[key] ) {
possible++;
if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( _.isRegExp( item ) && item.test( env[key] ) ) {
match++;
}
else if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( applyFilter( item, env[key] ) ) {
match++;
}

View file

@ -1 +1 @@
define(["postal","underscore"],function(a,b,c){var d=[],e=function(a,c){var d=0,f=0;return b.each(a,function(a,g){c[g]&&(f++,b.isObject(c[g])&&!b.isArray(c[g])?e(a,c[g])&&d++:b.isEqual(c[g],a)&&d++)}),d===f},f=a.addWireTap(function(a,c){if(!d.length||b.any(d,function(a){return e(a,c)})){if(!JSON)throw"This browser or environment does not provide JSON support";try{console.log(JSON.stringify(c))}catch(f){try{var g=b.extend({},c);delete g.data,console.log(JSON.stringify(g)+"\n "+"JSON.stringify Error: "+f.message)}catch(h){console.log("Unable to parse data to JSON: "+f)}}}});a.diagnostics=a.diagnostics||{},a.diagnostics.console={clearFilters:function(){d=[]},removeFilter:function(a){d=b.filter(d,function(c){return!b.isEqual(c,a)})},addFilter:function(a){b.isArray(a)||(a=[a]),b.each(a,function(a){(d.length===0||!b.any(d,function(c){return b.isEqual(c,a)}))&&d.push(a)})},getCurrentFilters:function(){return d},removeWireTap:function(){f&&f()}}})
define(["postal","underscore"],function(a,b,c){var d=[],e=function(a,c){var d=0,f=0;return b.each(a,function(a,g){c[g]&&(f++,b.isRegExp(a)&&a.test(c[g])?d++:b.isObject(c[g])&&!b.isArray(c[g])?e(a,c[g])&&d++:b.isEqual(c[g],a)&&d++)}),d===f},f=a.addWireTap(function(a,c){if(!d.length||b.any(d,function(a){return e(a,c)})){if(!JSON)throw"This browser or environment does not provide JSON support";try{console.log(JSON.stringify(c))}catch(f){try{var g=b.extend({},c);delete g.data,console.log(JSON.stringify(g)+"\n "+"JSON.stringify Error: "+f.message)}catch(h){console.log("Unable to parse data to JSON: "+f)}}}});a.diagnostics=a.diagnostics||{},a.diagnostics.console={clearFilters:function(){d=[]},removeFilter:function(a){d=b.filter(d,function(c){return!b.isEqual(c,a)})},addFilter:function(a){b.isArray(a)||(a=[a]),b.each(a,function(a){(d.length===0||!b.any(d,function(c){return b.isEqual(c,a)}))&&d.push(a)})},getCurrentFilters:function(){return d},removeWireTap:function(){f&&f()}}})

View file

@ -8,7 +8,10 @@ define( [ "postal", "underscore" ], function ( postal, _, undefined ) {
_.each( filter, function ( item, key ) {
if ( env[key] ) {
possible++;
if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( _.isRegExp( item ) && item.test( env[key] ) ) {
match++;
}
else if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( applyFilter( item, env[key] ) ) {
match++;
}

View file

@ -5,7 +5,10 @@ module.exports = function ( _, postal ) {
_.each( filter, function ( item, key ) {
if ( env[key] ) {
possible++;
if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( _.isRegExp( item ) && item.test( env[key] ) ) {
match++;
}
else if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( applyFilter( item, env[key] ) ) {
match++;
}

View file

@ -8,7 +8,10 @@
_.each( filter, function ( item, key ) {
if ( env[key] ) {
possible++;
if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( _.isRegExp( item ) && item.test( env[key] ) ) {
match++;
}
else if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( applyFilter( item, env[key] ) ) {
match++;
}

View file

@ -1 +1 @@
(function(a,b,c){var d=[],e=function(a,c){var d=0,f=0;return b.each(a,function(a,g){c[g]&&(f++,b.isObject(c[g])&&!b.isArray(c[g])?e(a,c[g])&&d++:b.isEqual(c[g],a)&&d++)}),d===f},f=a.addWireTap(function(a,c){if(!d.length||b.any(d,function(a){return e(a,c)})){if(!JSON)throw"This browser or environment does not provide JSON support";try{console.log(JSON.stringify(c))}catch(f){try{var g=b.extend({},c);delete g.data,console.log(JSON.stringify(g)+"\n "+"JSON.stringify Error: "+f.message)}catch(h){console.log("Unable to parse data to JSON: "+f)}}}});a.diagnostics=a.diagnostics||{},a.diagnostics.console={clearFilters:function(){d=[]},removeFilter:function(a){d=b.filter(d,function(c){return!b.isEqual(c,a)})},addFilter:function(a){b.isArray(a)||(a=[a]),b.each(a,function(a){(d.length===0||!b.any(d,function(c){return b.isEqual(c,a)}))&&d.push(a)})},getCurrentFilters:function(){return d},removeWireTap:function(){f&&f()}}})(postal,_)
(function(a,b,c){var d=[],e=function(a,c){var d=0,f=0;return b.each(a,function(a,g){c[g]&&(f++,b.isRegExp(a)&&a.test(c[g])?d++:b.isObject(c[g])&&!b.isArray(c[g])?e(a,c[g])&&d++:b.isEqual(c[g],a)&&d++)}),d===f},f=a.addWireTap(function(a,c){if(!d.length||b.any(d,function(a){return e(a,c)})){if(!JSON)throw"This browser or environment does not provide JSON support";try{console.log(JSON.stringify(c))}catch(f){try{var g=b.extend({},c);delete g.data,console.log(JSON.stringify(g)+"\n "+"JSON.stringify Error: "+f.message)}catch(h){console.log("Unable to parse data to JSON: "+f)}}}});a.diagnostics=a.diagnostics||{},a.diagnostics.console={clearFilters:function(){d=[]},removeFilter:function(a){d=b.filter(d,function(c){return!b.isEqual(c,a)})},addFilter:function(a){b.isArray(a)||(a=[a]),b.each(a,function(a){(d.length===0||!b.any(d,function(c){return b.isEqual(c,a)}))&&d.push(a)})},getCurrentFilters:function(){return d},removeWireTap:function(){f&&f()}}})(postal,_)

View file

@ -8,7 +8,10 @@ define( [ "postal", "underscore" ], function ( postal, _, undefined ) {
_.each( filter, function ( item, key ) {
if ( env[key] ) {
possible++;
if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( _.isRegExp( item ) && item.test( env[key] ) ) {
match++;
}
else if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( applyFilter( item, env[key] ) ) {
match++;
}

View file

@ -1 +1 @@
define(["postal","underscore"],function(a,b,c){var d=[],e=function(a,c){var d=0,f=0;return b.each(a,function(a,g){c[g]&&(f++,b.isObject(c[g])&&!b.isArray(c[g])?e(a,c[g])&&d++:b.isEqual(c[g],a)&&d++)}),d===f},f=a.addWireTap(function(a,c){if(!d.length||b.any(d,function(a){return e(a,c)})){if(!JSON)throw"This browser or environment does not provide JSON support";try{console.log(JSON.stringify(c))}catch(f){try{var g=b.extend({},c);delete g.data,console.log(JSON.stringify(g)+"\n "+"JSON.stringify Error: "+f.message)}catch(h){console.log("Unable to parse data to JSON: "+f)}}}});a.diagnostics=a.diagnostics||{},a.diagnostics.console={clearFilters:function(){d=[]},removeFilter:function(a){d=b.filter(d,function(c){return!b.isEqual(c,a)})},addFilter:function(a){b.isArray(a)||(a=[a]),b.each(a,function(a){(d.length===0||!b.any(d,function(c){return b.isEqual(c,a)}))&&d.push(a)})},getCurrentFilters:function(){return d},removeWireTap:function(){f&&f()}}})
define(["postal","underscore"],function(a,b,c){var d=[],e=function(a,c){var d=0,f=0;return b.each(a,function(a,g){c[g]&&(f++,b.isRegExp(a)&&a.test(c[g])?d++:b.isObject(c[g])&&!b.isArray(c[g])?e(a,c[g])&&d++:b.isEqual(c[g],a)&&d++)}),d===f},f=a.addWireTap(function(a,c){if(!d.length||b.any(d,function(a){return e(a,c)})){if(!JSON)throw"This browser or environment does not provide JSON support";try{console.log(JSON.stringify(c))}catch(f){try{var g=b.extend({},c);delete g.data,console.log(JSON.stringify(g)+"\n "+"JSON.stringify Error: "+f.message)}catch(h){console.log("Unable to parse data to JSON: "+f)}}}});a.diagnostics=a.diagnostics||{},a.diagnostics.console={clearFilters:function(){d=[]},removeFilter:function(a){d=b.filter(d,function(c){return!b.isEqual(c,a)})},addFilter:function(a){b.isArray(a)||(a=[a]),b.each(a,function(a){(d.length===0||!b.any(d,function(c){return b.isEqual(c,a)}))&&d.push(a)})},getCurrentFilters:function(){return d},removeWireTap:function(){f&&f()}}})

View file

@ -1,7 +1,7 @@
{
"name" : "postal.diagnostics",
"description" : "Wiretap add-on for postal.js allowing configurable console.logging output of messages being published through postal's message bus.",
"version" : "0.6.0",
"version" : "0.6.1",
"homepage" : "http://github.com/ifandelse/postal.js",
"repository" : {
"type" : "git",

View file

@ -5,7 +5,10 @@ module.exports = function ( _, postal ) {
_.each( filter, function ( item, key ) {
if ( env[key] ) {
possible++;
if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( _.isRegExp( item ) && item.test( env[key] ) ) {
match++;
}
else if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( applyFilter( item, env[key] ) ) {
match++;
}

View file

@ -8,7 +8,10 @@
_.each( filter, function ( item, key ) {
if ( env[key] ) {
possible++;
if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( _.isRegExp( item ) && item.test( env[key] ) ) {
match++;
}
else if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( applyFilter( item, env[key] ) ) {
match++;
}

View file

@ -1 +1 @@
(function(a,b,c){var d=[],e=function(a,c){var d=0,f=0;return b.each(a,function(a,g){c[g]&&(f++,b.isObject(c[g])&&!b.isArray(c[g])?e(a,c[g])&&d++:b.isEqual(c[g],a)&&d++)}),d===f},f=a.addWireTap(function(a,c){if(!d.length||b.any(d,function(a){return e(a,c)})){if(!JSON)throw"This browser or environment does not provide JSON support";try{console.log(JSON.stringify(c))}catch(f){try{var g=b.extend({},c);delete g.data,console.log(JSON.stringify(g)+"\n "+"JSON.stringify Error: "+f.message)}catch(h){console.log("Unable to parse data to JSON: "+f)}}}});a.diagnostics=a.diagnostics||{},a.diagnostics.console={clearFilters:function(){d=[]},removeFilter:function(a){d=b.filter(d,function(c){return!b.isEqual(c,a)})},addFilter:function(a){b.isArray(a)||(a=[a]),b.each(a,function(a){(d.length===0||!b.any(d,function(c){return b.isEqual(c,a)}))&&d.push(a)})},getCurrentFilters:function(){return d},removeWireTap:function(){f&&f()}}})(postal,_)
(function(a,b,c){var d=[],e=function(a,c){var d=0,f=0;return b.each(a,function(a,g){c[g]&&(f++,b.isRegExp(a)&&a.test(c[g])?d++:b.isObject(c[g])&&!b.isArray(c[g])?e(a,c[g])&&d++:b.isEqual(c[g],a)&&d++)}),d===f},f=a.addWireTap(function(a,c){if(!d.length||b.any(d,function(a){return e(a,c)})){if(!JSON)throw"This browser or environment does not provide JSON support";try{console.log(JSON.stringify(c))}catch(f){try{var g=b.extend({},c);delete g.data,console.log(JSON.stringify(g)+"\n "+"JSON.stringify Error: "+f.message)}catch(h){console.log("Unable to parse data to JSON: "+f)}}}});a.diagnostics=a.diagnostics||{},a.diagnostics.console={clearFilters:function(){d=[]},removeFilter:function(a){d=b.filter(d,function(c){return!b.isEqual(c,a)})},addFilter:function(a){b.isArray(a)||(a=[a]),b.each(a,function(a){(d.length===0||!b.any(d,function(c){return b.isEqual(c,a)}))&&d.push(a)})},getCurrentFilters:function(){return d},removeWireTap:function(){f&&f()}}})(postal,_)

View file

@ -4,7 +4,10 @@ var filters = [],
_.each( filter, function ( item, key ) {
if ( env[key] ) {
possible++;
if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( _.isRegExp( item ) && item.test( env[key] ) ) {
match++;
}
else if ( _.isObject( env[key] ) && !_.isArray( env[key] ) ) {
if ( applyFilter( item, env[key] ) ) {
match++;
}