| 1 | package HTTP::Proxy::BodyFilter::simple; | ||||||||||||||||||||||||||||
| 2 | 7 | $HTTP::Proxy::BodyFilter::simple::VERSION = '0.304'; | |||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use HTTP::Proxy::BodyFilter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use vars qw( @ISA ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 7 | @ISA = qw( HTTP::Proxy::BodyFilter ); | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 7 | my $methods = join '|', qw( begin filter end will_modify ); | |||||||||||||||||||||||||||
| 10 | 7 | $methods = qr/^(?:$methods)$/; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 17 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 17 | my $self = shift; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 17 | ▶ | croak "Constructor called without argument" unless @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 16 | $self->{_will_modify} = 1; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 16 | ▶ | if ( @_ == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 7 | ▶ | croak "Single parameter must be a CODE reference" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | unless ref $_[0] eq 'CODE'; | ||||||||||||||||||||||||||||
| 22 | 6 | $self->{_filter} = $_[0]; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | else { | ||||||||||||||||||||||||||||
| 25 | 9 | ▶ | $self->{_filter} = sub { }; # default | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 9 | ▶ | while (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 14 | my ( $name, $code ) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # basic error checking | ||||||||||||||||||||||||||||
| 30 | 14 | ▶ | croak "Parameter to $name must be a CODE reference" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$name ne "will_modify" and ref $code ne "CODE"
MC/DC100%2/2
$name ne "will_modify" and ref $code ne "CODE"
$name ne "will_modify"
ref $code ne "CODE"
Truth table100%3/3
A and B
A= $name ne "will_modify"B= ref $code ne "CODE"
| |||||||||||||||||||||||||||||
| 31 | if $name ne 'will_modify' && ref $code ne 'CODE'; | ||||||||||||||||||||||||||||
| 32 | 13 | ▶ | croak "Unkown method $name" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | unless $name =~ $methods; | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 12 | $self->{"_$name"} = $code; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # transparently call the actual methods | ||||||||||||||||||||||||||||
| 41 | 1 | ▶ | sub begin { goto &{ $_[0]{_begin} }; } | ||||||||||||||||||||||||||
|
Subroutine
begin: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 42 | 14 | ▶ | sub filter { goto &{ $_[0]{_filter} }; } | ||||||||||||||||||||||||||
|
Subroutine
filter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 1 | ▶ | sub end { goto &{ $_[0]{_end} }; } | ||||||||||||||||||||||||||
|
Subroutine
end: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 7 | ▶ | sub will_modify { return $_[0]{_will_modify} } | ||||||||||||||||||||||||||
|
Subroutine
will_modify: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 31 | ▶ | sub can { | ||||||||||||||||||||||||||
|
Subroutine
can: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | 31 | my ( $self, $method ) = @_; | |||||||||||||||||||||||||||
| 49 | return $method =~ $methods | ||||||||||||||||||||||||||||
| 50 | 31 | ▶ | ? $self->{"_$method"} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | : UNIVERSAL::can( $self, $method ); | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 7 | 1; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||||||||||