[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:48 UTC 2013
The following commit has been merged in the master branch:
commit e9a09544d46f69b29541a921c3ba1c2fe6821365
Author: Tomas Doran <bobtfish at bobtfish.net>
Date: Tue Apr 10 19:45:09 2012 +0100
Make an official callback output
diff --git a/lib/Log/Stash/Output/Test.pm b/lib/Log/Stash/Output/Test.pm
index f70cd77..b8658f6 100644
--- a/lib/Log/Stash/Output/Test.pm
+++ b/lib/Log/Stash/Output/Test.pm
@@ -2,12 +2,18 @@ package Log::Stash::Output::Test;
use Moose;
use namespace::autoclean;
+extends 'Log::Stash::Output::Callback';
+
+has '+cb' => (
+ default => sub { sub {} },
+);
+
has messages => (
isa => 'ArrayRef',
default => sub { [] },
traits => ['Array'],
handles => {
- consume => 'push',
+ consume_test => 'push',
message_count => 'count',
messages => 'elements',
},
@@ -15,20 +21,10 @@ has messages => (
lazy => 1,
);
-has on_consume_cb => (
- isa => 'CodeRef',
- is => 'ro',
- predicate => '_has_on_consume_cb',
-);
-
after consume => sub {
- my ($self, $msg) = @_;
- $self->on_consume_cb->($msg)
- if $self->_has_on_consume_cb;
+ shift()->consume_test(@_);
};
-with 'Log::Stash::Role::Output';
-
__PACKAGE__->meta->make_immutable;
1;
diff --git a/lib/Log/Stash/Role/Filter.pm b/lib/Log/Stash/Role/Filter.pm
index 155befd..125ca5a 100644
--- a/lib/Log/Stash/Role/Filter.pm
+++ b/lib/Log/Stash/Role/Filter.pm
@@ -2,8 +2,12 @@ package Log::Stash::Role::Filter;
use Moose::Role;
use namespace::autoclean;
-with 'Log::Stash::Role::Input';
-with 'Log::Stash::Role::Output';
+requires 'filter';
+
+with qw/
+ Log::Stash::Role::Input
+ Log::Stash::Role::Output
+/;
sub consume {
my ($self, $message) = @_;
@@ -12,8 +16,6 @@ sub consume {
$self->output_to->consume($new);
}
-requires 'filter';
-
1;
=head1 NAME
diff --git a/t/filter.t b/t/filter.t
index 20a4f23..a3fd031 100644
--- a/t/filter.t
+++ b/t/filter.t
@@ -15,7 +15,7 @@ my $called = 0;
my $test;
my $ob = try {
$test = Log::Stash::Output::Test->new(
- on_consume_cb => sub { $called++ }
+ cb => sub { $called++ }
);
Log::Stash::Filter::Null->new(output_to => $test)
}
@@ -37,7 +37,7 @@ is_deeply [$test->messages], [];
$ob = try {
$test = Log::Stash::Output::Test->new(
- on_consume_cb => sub { $called++ }
+ cb => sub { $called++ }
);
Log::Stash::Filter::All->new(output_to => $test)
}
@@ -55,10 +55,10 @@ my $called2 = 0;
my $test2;
$ob = try {
$test = Log::Stash::Output::Test->new(
- on_consume_cb => sub { $called++ }
+ cb => sub { $called++ }
);
$test2 = Log::Stash::Output::Test->new(
- on_consume_cb => sub { $called2++ }
+ cb => sub { $called2++ }
);
Log::Stash::Filter::T->new(output_to => [$test, $test2])
}
@@ -78,7 +78,7 @@ is $called2, 1;
$ob = try {
$test = Log::Stash::Output::Test->new(
- on_consume_cb => sub { $called++ }
+ cb => sub { $called++ }
);
Log::Stash::Filter::Key->new(
output_to => $test,
@@ -98,7 +98,7 @@ is_deeply [$test->messages], [{foo => 'bar', baz => 'quux'}];
$ob = try {
$test = Log::Stash::Output::Test->new(
- on_consume_cb => sub { $called++ }
+ cb => sub { $called++ }
);
Log::Stash::Filter::Key->new(
output_to => $test,
diff --git a/t/output_test.t b/t/output_test.t
index f55e786..9b577ea 100644
--- a/t/output_test.t
+++ b/t/output_test.t
@@ -7,7 +7,7 @@ use Log::Stash::Output::Test;
my $called = 0;
-my $test = try { Log::Stash::Output::Test->new(on_consume_cb => sub { $called++ }) }
+my $test = try { Log::Stash::Output::Test->new(cb => sub { $called++ }) }
catch { fail "Failed to construct $_" };
ok $test;
--
libmessage-passing-perl Debian packaging
More information about the Pkg-perl-cvs-commits
mailing list