[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:40 UTC 2013


The following commit has been merged in the master branch:
commit 43eb1821d0183a6a8041aecb517cc05d0fa051fd
Author: Tomas Doran <bobtfish at bobtfish.net>
Date:   Sat Mar 3 23:29:50 2012 +0000

    Implement T piece

diff --git a/lib/Log/Stash/Filter/T.pm b/lib/Log/Stash/Filter/T.pm
new file mode 100644
index 0000000..1c6647c
--- /dev/null
+++ b/lib/Log/Stash/Filter/T.pm
@@ -0,0 +1,25 @@
+package Log::Stash::Filter::T;
+use Moose;
+use MooseX::Types::Moose qw/ ArrayRef /;
+use Moose::Util::TypeConstraints;
+use namespace::autoclean;
+
+with 'Log::Stash::Role::Input';
+with 'Log::Stash::Role::Output';
+
+has '+output_to' => (
+    isa => ArrayRef[role_type('Log::Stash::Role::Output')],
+    is => 'ro',
+    required => 1,
+);
+
+sub consume {
+    my ($self, $message) = @_;
+    foreach my $output_to (@{ $self->output_to }) {
+        $output_to->consume($message);
+    }
+}
+
+__PACKAGE__->meta->make_immutable;
+1;
+
diff --git a/lib/Log/Stash/Role/Input.pm b/lib/Log/Stash/Role/Input.pm
index e591f01..aa45428 100644
--- a/lib/Log/Stash/Role/Input.pm
+++ b/lib/Log/Stash/Role/Input.pm
@@ -6,6 +6,7 @@ use namespace::autoclean;
 sub decode { from_json( $_[1], { utf8  => 1 } ) }
 
 has output_to => (
+    does => 'Log::Stash::Role::Output',
     is => 'ro',
     required => 1,
 );
diff --git a/t/filter.t b/t/filter.t
index 80a7593..84ca62a 100644
--- a/t/filter.t
+++ b/t/filter.t
@@ -6,6 +6,7 @@ use Try::Tiny;
 use Log::Stash::Filter::Null;
 use Log::Stash::Output::Test;
 use Log::Stash::Filter::All;
+use Log::Stash::Filter::T;
 
 my $called = 0;
 
@@ -46,5 +47,32 @@ try { $ob->consume('message') }
 
 is $test->messages_count, 0;
 
+$called = 0;
+my $called2 = 0;
+
+my $test2;
+$ob = try {
+    $test = Log::Stash::Output::Test->new(
+            on_consume_cb => sub { $called++ }
+    );
+    $test2 = Log::Stash::Output::Test->new(
+            on_consume_cb => sub { $called2++ }
+    );
+    Log::Stash::Filter::T->new(output_to => [$test, $test2])
+}
+catch { fail "Failed to construct $_" };
+ok $test;
+
+try { $ob->consume('message') }
+    catch { fail "Failed to consume message: $_" };
+
+is $test->messages_count, 1;
+is_deeply [$test->messages], ['message'];
+is $called, 1;
+
+is $test2->messages_count, 1;
+is_deeply [$test2->messages], ['message'];
+is $called2, 1;
+
 done_testing;
 

-- 
libmessage-passing-perl Debian packaging



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