Rssfilter/Group.pm

filter: Statementstmt 99.2% 131 / 132 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% 194 / 218 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 {
9 6 $App::Rssfilter::Group::VERSION = '0.07';
10 }
11 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 with 'App::Rssfilter::Logger';
13 6 with 'App::Rssfilter::FromHash';
14 6 with 'App::Rssfilter::FromYaml';
15 6 ▶use Method::Signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 6 ▶method BUILDARGS( @options ) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BUILDARGS: called CC=2 SCAR=6.9
18 12 ▶ if( 1 == @options ) {
Branch: 1 branch
BranchTrueFalseTotal
if (1 == @options) 5 7 12
19 5 unshift @options, 'name';
20 }
21 12 return { @options };
22 }
23  
24  
25 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
26 3 my $child_storage = $storage->path_push( $self->name );
27 3 my @rules = map { @{ $_ } } $rules, $self->rules;
28 3 $self->logger->debugf( 'filtering feeds in %s', $self->name );
29 3 $_->update( rules => \@rules, storage => $child_storage ) for @{ $self->groups };
30 3 $_->update( rules => \@rules, storage => $child_storage ) for @{ $self->feeds };
31 }
32  
33  
34  
35 has name => (
36 is => 'ro',
37 0 ▶ default => sub { '.' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 6 );
39  
40  
41 8 ▶has storage => (
Subroutine __ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 8 8
42 6 is => 'ro',
43 default => method { App::Rssfilter::Feed::Storage->new },
44 );
45  
46  
47 12 ▶has groups => (
Subroutine __ANON__: called CC=1 SCAR=0.0
48 6 is => 'ro',
49 default => sub { [] },
50 );
51 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
52 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
53 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
54 2 use Scalar::Util qw< blessed >;
55 2 if ( ! blessed( $app_rssfilter_group ) or ! $app_rssfilter_group->isa( 'App::Rssfilter::Group' ) ) {
56 unshift @group_options, $app_rssfilter_group; # restore original @_
57 $app_rssfilter_group = App::Rssfilter::Group->new( @group_options );
58 8 }
59 8  
60 push @{ $self->groups }, $app_rssfilter_group;
61 return $self;
62 }
63 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
64 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
65 2 ▶method group( $name ) {
Subroutine __ANON__: called CC=1 SCAR=0.0
66 use List::Util qw< first >;
67 first { $_->name eq $name } reverse @{ $self->groups };
68 }
69  
70  
71 12 ▶has rules => (
Subroutine __ANON__: called CC=1 SCAR=0.0
72 6 is => 'ro',
73 default => sub { [] },
74 );
75 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
76 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
77 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
78 1 use Scalar::Util qw< blessed >;
79 6 ▶ if ( ! blessed( $app_rssfilter_rule ) or ! $app_rssfilter_rule->isa( 'App::Rssfilter::Rule' ) ) {
Subroutine BEGIN: called CC=1 SCAR=0.0
80 1 unshift @rule_options, $app_rssfilter_rule; # restore original @_
81 use App::Rssfilter::Rule;
82 $app_rssfilter_rule = App::Rssfilter::Rule->new( @rule_options );
83 4 }
84 4  
85 push @{ $self->rules }, $app_rssfilter_rule;
86 return $self;
87 }
88  
89  
90 12 ▶has feeds => (
Subroutine __ANON__: called CC=1 SCAR=0.0
91 6 is => 'ro',
92 default => sub { [] },
93 );
94 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
95 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
96 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
97 2 use Scalar::Util qw< blessed >;
98 6 ▶ if ( ! blessed( $app_rssfilter_feed ) or ! $app_rssfilter_feed->isa( 'App::Rssfilter::Feed' ) ) {
Subroutine BEGIN: called CC=1 SCAR=0.0
99 2 unshift @feed_options, $app_rssfilter_feed; # restore original @_
100 use App::Rssfilter::Feed;
101 $app_rssfilter_feed = App::Rssfilter::Feed->new( @feed_options );
102 9 }
103 9  
104 push @{ $self->feeds }, $app_rssfilter_feed;
105 return $app_rssfilter_feed;
106 }
107 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
108 6 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
109 2 ▶method feed( $name ) {
Subroutine __ANON__: called CC=1 SCAR=0.0
110 use List::Util qw< first >;
111 first { $_->name eq $name } reverse @{ $self->feeds };
112 }
113  
114 6  
115  
116 1;
117  
118 __END__
« Rssfilter/Feed/Storage.pm ↑ Summary Rssfilter/Filter/MarkTitle.pm »