Subject: | Add filters for pre/post execute and prepare. |
It would be handy if a filter can be called for before and after an
execute and prepare call is made. Attached is a quick change that
implements this change, with some documentation.
Subject: | svnnotify.patch |
Index: Notify.pm
===================================================================
--- Notify.pm (revision 3669)
+++ Notify.pm (working copy)
@@ -999,11 +999,13 @@
sub prepare {
my $self = shift;
+ $self->run_filters(pre_prepare => "");
$self->prepare_recipients;
return $self unless @{ $self->{to} };
$self->prepare_contents;
$self->prepare_files;
$self->prepare_subject;
+ $self->run_filters(post_prepare => "");
}
##############################################################################
@@ -1272,6 +1274,7 @@
sub execute {
my $self = shift;
+ $self->run_filters(pre_execute => "");
$self->_dbpnt( "Sending message") if $self->{verbose};
return $self unless @{ $self->{to} };
@@ -1290,6 +1293,7 @@
close $out or warn "Child process exited: $?\n";
$self->_dbpnt( 'Message sent' ) if $self->{verbose};
+ $self->run_filters(post_execute => "");
return $self;
}
Index: Notify/Filter.pm
===================================================================
--- Notify/Filter.pm (revision 3669)
+++ Notify/Filter.pm (working copy)
@@ -107,6 +107,11 @@
slightly different format than documented here. Consult the documentation for
the relevant methods in those classes for details.
+There are four special filter subroutines that are called before and after
+calling prepare and execute, named C<pre_prepare>, C<post_prepare>,
+C<pre_execute>, and C<post_execute>. Their return value is ignored, and only
+an empty string is passed in as the second argument.
+
The package name of the filter module can be anything you like; just pass it
via the C<filter> parameter, e.g., C<< filter => [ 'My::Filter' ] >> (or
C<--filter My::Filter> on the command-line). If, however, it's in the