blib/lib/Text/MicroMason/Functions.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 12 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 4 totaltotal 92.5% 50 / 54 CC 4 SCAR 4.1
CC
4
Cov
100%
SafeMason
2.0
SafeCatchingMason
2.0
__ANON__
2.0
CRAP 1.5
« blib/lib/Text/MicroMason/CatchErrors.pm ↑ Summary blib/lib/Text/MicroMason/TextTemplate.pm »
1 package Text::MicroMason::Functions;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use vars qw( @ISA @EXPORT_OK );
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 @ISA = 'Exporter';
8  
9 10 @EXPORT_OK = (
10 'compile', # $code_ref = compile( $mason_text );
11 'compile_file', # $code_ref = compile_file( $filename );
12 'safe_compile', # $code_ref = safe_compile( $mason_text );
13 'safe_compile_file', # $code_ref = safe_compile_file( $filename );
14 'execute', # $result = execute( $filename, %args );
15 'execute_file', # $result = execute_file( $filename, %args );
16 'safe_execute', # $result = safe_execute( $mason_text, %args );
17 'safe_execute_file', # $result = safe_execute_file( $filename, %args );
18 );
19  
20 10 push @EXPORT_OK, map "try_$_", @EXPORT_OK;
21  
22 ######################################################################
23  
24 51 ▶sub Mason {
Subroutine Mason: called CC=1 SCAR=0.0
Pod undocumented
25 ()
26 51 }
27  
28 9 ▶sub SafeMason {
Subroutine SafeMason: called CC=2 SCAR=6.9
Pod undocumented
29 9 ▶ ( -Safe, (ref($_[0]) =~ /Safe/) ? (safe => shift) : () )
Branch: 1 branch
BranchTrueFalseTotal
ref($_[0]) =~ /Safe/ ? : 4 5 9
30 }
31  
32 13 ▶sub CatchingMason {
Subroutine CatchingMason: called CC=1 SCAR=0.0
Pod undocumented
33 13 ( -CatchErrors );
34 }
35  
36 11 ▶sub SafeCatchingMason {
Subroutine SafeCatchingMason: called CC=2 SCAR=6.9
Pod undocumented
37 11 ▶ ( -CatchErrors, -Safe, (ref($_[0]) =~ /Safe/) ? (safe => shift) : () )
Branch: 1 branch
BranchTrueFalseTotal
ref($_[0]) =~ /Safe/ ? : 4 7 11
38 }
39  
40 10 foreach my $sub (@EXPORT_OK ) {
41 10 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
42 160 my $method = $sub;
43 160 ▶ my $source = ( $method =~ s/_file// ) ? 'file' : 'text';
Branch: 1 branch
BranchTrueFalseTotal
$method =~ s/_file// ? : 80 80 160
44  
45 160 my $mason = "Mason";
46 160 ▶ $mason = "Catching$mason" if ( $method =~ s/try_// );
Branch: 1 branch
BranchTrueFalseTotal
if $method =~ s/try_// 80 80 160
47 160 ▶ $mason = "Safe$mason" if ( $method =~ s/safe_// );
Branch: 1 branch
BranchTrueFalseTotal
if $method =~ s/safe_// 80 80 160
48 160 ▶ *{__PACKAGE__."::$sub"} = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
49 84 ▶ Text::MicroMason->new( &$mason )
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'CODE' ? : 2 82 84
50 ->$method( (ref($_[0]) eq 'CODE') ? 'code' : $source => @_ )
51 }
52 160 }
53  
54 ######################################################################
55  
56 10 1;
57  
58 __END__
« blib/lib/Text/MicroMason/CatchErrors.pm ↑ Summary blib/lib/Text/MicroMason/TextTemplate.pm »