Plagger/Plugin/Summary/Auto.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 32 CC 3 SCAR 18.4
CC
3
Cov
0%
auto_summarize
12.0
register
2.0
BEGIN
2.0
CRAP 6.3
1 package Plagger::Plugin::Summary::Auto;
2 use strict;
3 use base qw( Plagger::Plugin );
4  
5 use Plagger::Util;
6  
7 sub register {
8 my($self, $context) = @_;
9 $context->register_hook(
10 $self,
11 'update.entry.fixup' => \&auto_summarize,
12 );
13 }
14  
15 sub auto_summarize {
16 my($self, $context, $args) = @_;
17  
18 if ($args->{entry}->body && !$args->{entry}->summary) {
19 # give plugins a chance
20 my $summary = $context->run_hook_once('summarizer.summarize', {
21 entry => $args->{entry},
22 feed => $args->{feed},
23 text => $args->{entry}->body,
24 });
25 $args->{entry}->summary($summary) if defined $summary;
26 }
27 }
28  
29 1;
30 __END__