Plagger/Rule/FeedType.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 47 CC 4 SCAR 24.0
CC
4
Cov
0%
init
20.0
dispatch
2.0
BEGIN
2.0
CRAP 11.0
1 package Plagger::Rule::FeedType;
2 use strict;
3 use base qw( Plagger::Rule );
4  
5 use Plagger::Operator;
6  
7 sub init {
8 my $self = shift;
9  
10 if (my $type = $self->{type}) {
11 $type = [ $type ] if ref($type) ne 'ARRAY';
12 $self->{type} = $type;
13 } else {
14 Plagger->context->error("Can't parse type");
15 }
16  
17 $self->{op} ||= 'OR';
18 unless (Plagger::Operator->is_valid_op($self->{op})) {
19 Plagger->context->error("Unsupported operator $self->{op}");
20 }
21 }
22  
23 sub dispatch {
24 my($self, $args) = @_;
25  
26 my $feed = $args->{feed}
27 or Plagger->context->error("No feed object in this plugin phase");
28  
29 my @bool;
30 for my $want (@{$self->{type}}) {
31 push @bool, ($feed->type eq $want);
32 }
33  
34 Plagger::Operator->call($self->{op}, @bool);
35 }
36  
37 1;