[Bps-public-commit] Plack-Middleware-Test-StashWarnings branch, verbose-option, created. 0.07-1-g0e83ff4
? sunnavy
sunnavy at bestpractical.com
Thu Apr 3 14:01:41 EDT 2014
The branch, verbose-option has been created
at 0e83ff4f1b347e2841aa354e820d72ae938729a3 (commit)
- Log -----------------------------------------------------------------
commit 0e83ff4f1b347e2841aa354e820d72ae938729a3
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Apr 4 01:54:37 2014 +0800
new verbose option to replace $ENV{TEST_VERBOSE}
this allows the caller to decide if the old warn handler shall be called,
which is more convenient.
diff --git a/lib/Plack/Middleware/Test/StashWarnings.pm b/lib/Plack/Middleware/Test/StashWarnings.pm
index 021c5ca..ecbcb14 100644
--- a/lib/Plack/Middleware/Test/StashWarnings.pm
+++ b/lib/Plack/Middleware/Test/StashWarnings.pm
@@ -8,6 +8,14 @@ use parent qw(Plack::Middleware);
use Carp ();
use Storable 'nfreeze';
+sub new {
+ my $proto = shift;
+ my $class = ref $proto || $proto;
+ my $self = $class->SUPER::new(@_);
+ $self->{verbose} = $ENV{TEST_VERBOSE} unless defined $self->{verbose};
+ return $self;
+}
+
sub call {
my ($self, $env) = @_;
@@ -36,7 +44,7 @@ sub _stash_warnings_for {
my $old_warn = $SIG{__WARN__} || sub { warn @_ };
local $SIG{__WARN__} = sub {
$self->add_warning(@_);
- $old_warn->(@_) if $ENV{TEST_VERBOSE};
+ $old_warn->(@_) if $self->{verbose};
};
return $code->(@_);
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list