| 1 | package Text::MicroMason::PostProcess; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | ###################################################################### | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 10 | ▶ | sub assembler_rules { | ||||||||||||||||||||||||||
|
Subroutine
assembler_rules: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 10 | 10 | my %rules = $self->NEXT('assembler_rules', @_); | |||||||||||||||||||||||||||
| 11 | 10 | $rules{return_output} = "\$m->post_process( $rules{return_output} )"; | |||||||||||||||||||||||||||
| 12 | 10 | %rules; | |||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 14 | ▶ | sub post_processors { | ||||||||||||||||||||||||||
|
Subroutine
post_processors: called CC=6 SCAR=18.5
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 14 | my $self = shift; | |||||||||||||||||||||||||||
| 17 | 14 | my $funcs = $self->{post_process}; | |||||||||||||||||||||||||||
| 18 | 14 | ▶ | my @funcs = ref($funcs) eq 'ARRAY' ? @$funcs : $funcs ? $funcs : (); | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 19 | 14 | ▶ | if ( scalar @_ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | @funcs = ( $#_ == 0 and ref($_[0]) eq 'ARRAY' ) ? @{ $_[0] } : (@funcs, @_); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$#_ == 0 and ref $_[0] eq "ARRAY"
MC/DC0%0/2
$#_ == 0 and ref $_[0] eq "ARRAY"
$#_ == 0
ref $_[0] eq "ARRAY"
Truth table33%1/3
A and B
A= $#_ == 0B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||
| 21 | 4 | $self->{post_process} = [ @funcs ]; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 14 | return @funcs; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 10 | ▶ | sub post_process { | ||||||||||||||||||||||||||
|
Subroutine
post_process: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 28 | 10 | local $_ = shift; | |||||||||||||||||||||||||||
| 29 | 10 | foreach my $func ( $self->post_processors ) { | |||||||||||||||||||||||||||
| 30 | 13 | my $p = prototype($func); | |||||||||||||||||||||||||||
| 31 | 13 | ▶ | if ( defined $p and ! length $p ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $p and not length $p
MC/DC50%1/2
defined $p and not length $p
defined $p
not length $p
Truth table66%2/3
A and not(B)
A= defined $pB= not length $p
| |||||||||||||||||||||||||||||
| 32 | 2 | &$func; | |||||||||||||||||||||||||||
| 33 | } else { | ||||||||||||||||||||||||||||
| 34 | 11 | $_ = &$func( $_ ); | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | 10 | $_; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | ###################################################################### | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | 1; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | __END__ | ||||||||||||||||||||||||||||