Plagger/Plugin/Notify/Command.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 37 CC 4 SCAR 14.8
CC
4
Cov
0%
plugin_init
6.0
update
6.0
finalize
6.0
CRAP 4.4
1 package Plagger::Plugin::Notify::Command;
2 use strict;
3 use base qw( Plagger::Plugin );
4  
5 sub register {
6 my($self, $context) = @_;
7 $context->register_hook(
8 $self,
9 'publish.feed' => \&update,
10 'publish.finalize' => \&finalize,
11 'plugin.init' => \&plugin_init,
12 );
13 }
14  
15 sub plugin_init {
16 my($self, $context, $args) = @_;
17  
18 unless (exists $self->conf->{command}) {
19 $context->error("'command' config is missing");
20 }
21 }
22  
23 sub update {
24 my($self, $context, $args) = @_;
25 $self->{count}++ if $args->{feed}->count;
26 }
27  
28 sub finalize {
29 my($self, $context, $args) = @_;
30 $self->do_command if $self->{count};
31 }
32  
33 sub do_command {
34 my $self = shift;
35 my $command = $self->conf->{command};
36 system($command);
37 }
38  
39 1;
40 __END__