| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$Method::Signatures::mutc{"cache"}{"ArrayRef"} ||= "Method::Signatures"->_make_constraint("ArrayRef")
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")
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 6 | ▶ | |||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 51 | 8 | ▶ | method add_group( $app_rssfilter_group, @group_options ) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($app_rssfilter_group) and $app_rssfilter_group->isa("App::Rssfilter::Group")
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")
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 6 | ▶ | |||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 4 | ▶ | method add_rule( $app_rssfilter_rule, @rule_options ) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($app_rssfilter_rule) and $app_rssfilter_rule->isa("App::Rssfilter::Rule")
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")
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 93 | 6 | ▶ | |||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 94 | 9 | ▶ | method add_feed( $app_rssfilter_feed, @feed_options ) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($app_rssfilter_feed) and $app_rssfilter_feed->isa("App::Rssfilter::Feed")
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")
| |||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||