| 1 | package WebSource::Filter::distance; | ||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | ▶ | use WebSource::Filter; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | our @ISA = ('WebSource::Filter'); | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | WebSource::Filter::script - Use a script for filtering | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | =head1 DESCRIPTION | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | Each time an object passes thru this filter a meta-information named distance | ||||||||||||||||||||
| 15 | is incremented by 1. Once this meta-information has reached the maximum | ||||||||||||||||||||
| 16 | the item is filtered. | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | B<In wsd file...> | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | <ws:filter name="somename" type="distance" forward-to"somemodules"> | ||||||||||||||||||||
| 23 | <parameters> | ||||||||||||||||||||
| 24 | <param name="maximum" value="<maxvalue>" /> | ||||||||||||||||||||
| 25 | </parameters> | ||||||||||||||||||||
| 26 | </ws:filter> | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | =head1 METHODS | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | =cut | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 36 | 0 | my $class = shift; | |||||||||||||||||||
| 37 | 0 | my %params = @_; | |||||||||||||||||||
| 38 | 0 | my $self = bless \%params, $class; | |||||||||||||||||||
| 39 | 0 | $self->SUPER::_init_; | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | ▶ | $self->{maximum} or $self->{maximum} = 5; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | 0 | $self->log(2,"Maximum set to ",$self->{maximum}); | |||||||||||||||||||
| 43 | 0 | return $self; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | ▶ | sub keep { | ||||||||||||||||||
|
Subroutine
keep: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 47 | 0 | my $self = shift; | |||||||||||||||||||
| 48 | 0 | my $env = shift; | |||||||||||||||||||
| 49 | 0 | $self->log(6,"Distance was '",$env->{distance},"'"); | |||||||||||||||||||
| 50 | 0 | ▶ | if($env->{distance}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | 0 | $env->{distance} += 1; | |||||||||||||||||||
| 52 | } else { | ||||||||||||||||||||
| 53 | 0 | $env->{distance} = 1; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | 0 | $self->log(6,"Distance is now '",$env->{distance},"'"); | |||||||||||||||||||
| 56 | 0 | $self->log(5,"Distance updated env is now : ",$env->as_string); | |||||||||||||||||||
| 57 | 0 | ▶ | return (! $self->{maximum}) || ($env->{distance} <= $self->{maximum}); | ||||||||||||||||||
|
Condition0%0/3
!$self->{'maximum'} || $env->{'distance'} <= $self->{'maximum'}
MC/DC0%0/2
!$self->{'maximum'} || $env->{'distance'} <= $self->{'maximum'}
!$self->{'maximum'}
$env->{'distance'} <= $self->{'maximum'}
Truth table0%0/3
not(A) || B
A= !$self->{'maximum'}B= $env->{'distance'} <= $self->{'maximum'}
| |||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | =head1 SEE ALSO | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | WebSource | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | =cut | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 1 | 1; | |||||||||||||||||||
| 67 | |||||||||||||||||||||