Rssfilter/Group.pm

filter: Statementstmt 99.2% 130 / 131 Branchbran 64.7% 22 / 34 Conditioncond 58.3% 7 / 12 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 96.8% 31 / 32 Podpod n/a totaltotal 88.9% 193 / 217 CC 24 SCAR 12.1
CC
24
Cov
90%
update
9.5
add_group
4.0
add_rule
4.0
CRAP 3.4
« Rssfilter/Feed/Storage.pm ↑ Summary Rssfilter/Filter/MarkTitle.pm »
1 # ABSTRACT: associate one or more rules with more than one feed
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 package App::Rssfilter::Group;
8 6 $App::Rssfilter::Group::VERSION = '0.08'; # TRIAL
9 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 with 'App::Rssfilter::Logger';
11 6 with 'App::Rssfilter::FromHash';
12 6 with 'App::Rssfilter::FromYaml';
13 6 ▶use Method::Signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 6 ▶method BUILDARGS( @options ) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BUILDARGS: called CC=2 SCAR=6.9
16 12 ▶ if( 1 == @options ) {
Branch: 1 branch
BranchTrueFalseTotal
if (1 == @options) 5 7 12
17 5 unshift @options, 'name';
18 }
19 12 return { @options };
20 }
21  
22  
23 6 ▶method update( ArrayRef :$rules = [], :$storage = $self->storage ) {
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine update: called CC=9 SCAR=22.5
Branch: 5 branches
BranchTrueFalseTotal
exists $args{'rules'} ? : 3 0 3
unless ($Method::Signatures::mutc{"cache"}{"ArrayRef"} ||= "Method::Signatures"->_make_constraint("ArrayRef"))->check($rules) 0 3 3
exists $args{'storage'} ? : 1 2 3
if keys %args 0 3 3
if scalar @_ > 4 0 3 3
Condition33%1/3
$Method::Signatures::mutc{"cache"}{"ArrayRef"} ||= "Method::Signatures"->_make_constraint("ArrayRef")
l!l&&r!l&&!r
030
MC/DC0%0/2
$Method::Signatures::mutc{"cache"}{"ArrayRef"} ||= "Method::Signatures"->_make_constraint("ArrayRef")
$Method::Signatures::mutc{"cache"}{"ArrayRef"} "Method::Signatures"->_make_constraint("ArrayRef")
Truth table33%1/3
A ||= B
A= $Method::Signatures::mutc{"cache"}{"ArrayRef"}B= "Method::Signatures"->_make_constraint("ArrayRef")
ABresult
1X1
011
000
24 3 my $child_storage = $storage->path_push( $self->name );
25 3 my @rules = map { @{ $_ } } $rules, $self->rules;
26 3 $self->logger->debugf( 'filtering feeds in %s', $self->name );
27 3 $_->update( rules => \@rules, storage => $child_storage ) for @{ $self->groups };
28 3 $_->update( rules => \@rules, storage => $child_storage ) for @{ $self->feeds };
29 }
30  
31  
32  
33 has name => (
34 is => 'ro',
35 0 ▶ default => sub { '.' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
36 6 );
37  
38  
39 8 ▶has storage => (
Subroutine __ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 8 8
40 6 is => 'ro',
41 default => method { App::Rssfilter::Feed::Storage->new },
42 );
43  
44  
45 12 ▶has groups => (
Subroutine __ANON__: called CC=1 SCAR=0.0
46 6 is => 'ro',
47 default => sub { [] },
48 );
49 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine add_group: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @_ > 0 0 8 8
50 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
51 8 ▶method add_group( $app_rssfilter_group, @group_options ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($app_rssfilter_group) and $app_rssfilter_group->isa("App::Rssfilter::Group")) 2 6 8
Condition66%2/3
builtin::blessed($app_rssfilter_group) and $app_rssfilter_group->isa("App::Rssfilter::Group")
!ll&&!rl&&r
206
MC/DC50%1/2
builtin::blessed($app_rssfilter_group) and $app_rssfilter_group->isa("App::Rssfilter::Group")
builtin::blessed($app_rssfilter_group) $app_rssfilter_group->isa("App::Rssfilter::Group")
Truth table66%2/3
A and B
A= builtin::blessed($app_rssfilter_group)B= $app_rssfilter_group->isa("App::Rssfilter::Group")
ABresult
0X0
100
111
52 2 use Scalar::Util qw< blessed >;
53 2 if ( ! blessed( $app_rssfilter_group ) or ! $app_rssfilter_group->isa( 'App::Rssfilter::Group' ) ) {
54 unshift @group_options, $app_rssfilter_group; # restore original @_
55 $app_rssfilter_group = App::Rssfilter::Group->new( @group_options );
56 8 }
57 8  
58 push @{ $self->groups }, $app_rssfilter_group;
59 return $self;
60 }
61 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine group: called CC=3 SCAR=11.0
Branch: 2 branches
BranchTrueFalseTotal
unless scalar @_ > 0 0 2 2
if scalar @_ > 1 0 2 2
62 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
63 2 ▶method group( $name ) {
Subroutine __ANON__: called CC=1 SCAR=0.0
64 use List::Util qw< first >;
65 first { $_->name eq $name } reverse @{ $self->groups };
66 }
67  
68  
69 12 ▶has rules => (
Subroutine __ANON__: called CC=1 SCAR=0.0
70 6 is => 'ro',
71 default => sub { [] },
72 );
73 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine add_rule: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @_ > 0 0 4 4
74 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
75 4 ▶method add_rule( $app_rssfilter_rule, @rule_options ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($app_rssfilter_rule) and $app_rssfilter_rule->isa("App::Rssfilter::Rule")) 1 3 4
Condition66%2/3
builtin::blessed($app_rssfilter_rule) and $app_rssfilter_rule->isa("App::Rssfilter::Rule")
!ll&&!rl&&r
103
MC/DC50%1/2
builtin::blessed($app_rssfilter_rule) and $app_rssfilter_rule->isa("App::Rssfilter::Rule")
builtin::blessed($app_rssfilter_rule) $app_rssfilter_rule->isa("App::Rssfilter::Rule")
Truth table66%2/3
A and B
A= builtin::blessed($app_rssfilter_rule)B= $app_rssfilter_rule->isa("App::Rssfilter::Rule")
ABresult
0X0
100
111
76 1 use Scalar::Util qw< blessed >;
77 6 ▶ if ( ! blessed( $app_rssfilter_rule ) or ! $app_rssfilter_rule->isa( 'App::Rssfilter::Rule' ) ) {
Subroutine BEGIN: called CC=1 SCAR=0.0
78 1 unshift @rule_options, $app_rssfilter_rule; # restore original @_
79 use App::Rssfilter::Rule;
80 $app_rssfilter_rule = App::Rssfilter::Rule->new( @rule_options );
81 4 }
82 4  
83 push @{ $self->rules }, $app_rssfilter_rule;
84 return $self;
85 }
86  
87  
88 12 ▶has feeds => (
Subroutine __ANON__: called CC=1 SCAR=0.0
89 6 is => 'ro',
90 default => sub { [] },
91 );
92 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine add_feed: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @_ > 0 0 9 9
93 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
94 9 ▶method add_feed( $app_rssfilter_feed, @feed_options ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($app_rssfilter_feed) and $app_rssfilter_feed->isa("App::Rssfilter::Feed")) 2 7 9
Condition66%2/3
builtin::blessed($app_rssfilter_feed) and $app_rssfilter_feed->isa("App::Rssfilter::Feed")
!ll&&!rl&&r
207
MC/DC50%1/2
builtin::blessed($app_rssfilter_feed) and $app_rssfilter_feed->isa("App::Rssfilter::Feed")
builtin::blessed($app_rssfilter_feed) $app_rssfilter_feed->isa("App::Rssfilter::Feed")
Truth table66%2/3
A and B
A= builtin::blessed($app_rssfilter_feed)B= $app_rssfilter_feed->isa("App::Rssfilter::Feed")
ABresult
0X0
100
111
95 2 use Scalar::Util qw< blessed >;
96 6 ▶ if ( ! blessed( $app_rssfilter_feed ) or ! $app_rssfilter_feed->isa( 'App::Rssfilter::Feed' ) ) {
Subroutine BEGIN: called CC=1 SCAR=0.0
97 2 unshift @feed_options, $app_rssfilter_feed; # restore original @_
98 use App::Rssfilter::Feed;
99 $app_rssfilter_feed = App::Rssfilter::Feed->new( @feed_options );
100 9 }
101 9  
102 push @{ $self->feeds }, $app_rssfilter_feed;
103 return $app_rssfilter_feed;
104 }
105 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine feed: called CC=3 SCAR=11.0
Branch: 2 branches
BranchTrueFalseTotal
unless scalar @_ > 0 0 2 2
if scalar @_ > 1 0 2 2
106 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
107 2 ▶method feed( $name ) {
Subroutine __ANON__: called CC=1 SCAR=0.0
108 use List::Util qw< first >;
109 first { $_->name eq $name } reverse @{ $self->feeds };
110 }
111  
112 6  
113  
114 1;
115  
116 __END__
« Rssfilter/Feed/Storage.pm ↑ Summary Rssfilter/Filter/MarkTitle.pm »