[SCM] libmessage-passing-perl Debian packaging branch, master, updated. debian/0.111-3-14-g44f6e88

Tomas Doran bobtfish at bobtfish.net
Mon May 6 11:56:39 UTC 2013


The following commit has been merged in the master branch:
commit c7fbb7acf3978e63b73fcb4252edc4c341703a25
Author: Tomas Doran <bobtfish at bobtfish.net>
Date:   Sat Mar 3 19:49:15 2012 +0000

    Add support for filter chains

diff --git a/lib/Log/Stash/Filter/Null.pm b/lib/Log/Stash/Filter/Null.pm
new file mode 100644
index 0000000..560b132
--- /dev/null
+++ b/lib/Log/Stash/Filter/Null.pm
@@ -0,0 +1,14 @@
+package Log::Stash::Filter::Null;
+use Moose;
+use namespace::autoclean;
+
+with 'Log::Stash::Role::Filter';
+
+sub filter {
+    my ($self, $message) = @_;
+    $message;
+}
+
+__PACKAGE__->meta->make_immutable;
+1;
+
diff --git a/lib/Log/Stash/Role/Filter.pm b/lib/Log/Stash/Role/Filter.pm
index 4f90807..4613c9a 100644
--- a/lib/Log/Stash/Role/Filter.pm
+++ b/lib/Log/Stash/Role/Filter.pm
@@ -5,6 +5,11 @@ use namespace::autoclean;
 with 'Log::Stash::Role::Input';
 with 'Log::Stash::Role::Output';
 
+sub consume {
+    my ($self, $message) = @_;
+    $self->output_to->consume($self->filter($message));
+}
+
 requires 'filter';
 
 1;
diff --git a/t/output_test.t b/t/filter.t
similarity index 59%
copy from t/output_test.t
copy to t/filter.t
index c30022f..31f6388 100644
--- a/t/output_test.t
+++ b/t/filter.t
@@ -3,15 +3,22 @@ use warnings;
 use Test::More;
 use Try::Tiny;
 
+use Log::Stash::Filter::Null;
 use Log::Stash::Output::Test;
 
 my $called = 0;
 
-my $test = try { Log::Stash::Output::Test->new(on_consume_cb => sub { $called++ }) }
-    catch { fail "Failed to construct $_" };
+my $test;
+my $ob = try {
+    $test = Log::Stash::Output::Test->new(
+            on_consume_cb => sub { $called++ }
+    );
+    Log::Stash::Filter::Null->new(output_to => $test)
+}
+catch { fail "Failed to construct $_" };
 ok $test;
 
-try { $test->consume('message') }
+try { $ob->consume('message') }
     catch { fail "Failed to consume message: $_" };
 
 is $test->messages_count, 1;

-- 
libmessage-passing-perl Debian packaging



More information about the Pkg-perl-cvs-commits mailing list