blib/lib/Poet/Mason.pm

filter: Statementstmt 100% 101 / 101 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 4 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 24 / 24 Podpod n/a totaltotal 95.6% 133 / 139 CC 6 SCAR 3.3
CC
6
Cov
97%
__ANON__
3.0
instance
2.0
__ANON__
2.0
CRAP 1.4
« blib/lib/Poet.pm ↑ Summary blib/lib/Poet/Mechanize.pm »
1 package Poet::Mason; ## no critic (Moose::RequireMakeImmutable)
2 2 $Poet::Mason::VERSION = '0.16';
3 2 ▶use Poet qw($conf $poet);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use List::MoreUtils qw(uniq);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Method::Signatures::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 extends 'Mason';
10  
11 2 my $instance;
12  
13 2 ▶method instance ($class:) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine instance: called CC=2 SCAR=7.0
14 14 ▶ $instance ||= $class->new();
Condition66%2/3
$instance ||= $class->new
l!l&&r!l&&!r
1220
MC/DC0%0/2
$instance ||= $class->new
$instance $class->new
Truth table66%2/3
A ||= B
A= $instanceB= $class->new
ABresult
1X1
011
000
15 14 $instance;
16 2 }
17  
18 2 ▶method new ($class:) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine new: called CC=1 SCAR=0.0
19 2 return $class->SUPER::new( $class->get_options, @_ );
20 2 }
21  
22 2 ▶method get_options ($class:) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine get_options: called CC=1 SCAR=0.0
23 1 my %defaults = (
24 cache_root_class => $poet->app_class('Cache'),
25 comp_root => $poet->comps_dir,
26 data_dir => $poet->data_dir,
27 plugins => [ $class->get_plugins ],
28 );
29 1 my %configured = %{ $conf->get_hash("mason") };
30 1 my $extra_plugins = $conf->get_list("mason.extra_plugins");
31 1 delete( $configured{extra_plugins} );
32 1 my %options = ( %defaults, %configured );
33 1 $options{plugins} = [ uniq( @{ $options{plugins} }, '+Poet::Mason::Plugin', @$extra_plugins ) ];
34 1 return %options;
35 2 }
36  
37 2 ▶method get_plugins ($class:) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine get_plugins: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
38 1 return ( 'HTMLFilters', 'RouterSimple', 'Cache' );
39 2 }
40  
41 2 ▶method handle_psgi ($class: $psgi_env) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine handle_psgi: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
42 1 my $req = $poet->app_class('Plack::Request')->new($psgi_env);
43 1 my $res = $poet->app_class('Plack::Response')->new();
44 14 ▶ my $response = try {
Subroutine __ANON__: called CC=1 SCAR=0.0
45 14 my $interp = $poet->app_class('Mason')->instance;
46 14 my $m = $interp->_make_request( req => $req, res => $res );
47 14 $m->run( $class->_psgi_comp_path($req), $class->_psgi_parameters($req) );
48 12 $m->res;
49 }
50 2 ▶ catch {
Subroutine __ANON__: called CC=3 SCAR=11.0
51 2 my $err = $_;
52 2 ▶ if ( blessed($err) && $err->isa('Mason::Exception::TopLevelNotFound') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($err) and $err->isa('Mason::Exception::TopLevelNotFound')) { } 1 1 2
Condition66%2/3
builtin::blessed($err) and $err->isa("Mason::Exception::TopLevelNotFound")
!ll&&!rl&&r
101
MC/DC50%1/2
builtin::blessed($err) and $err->isa("Mason::Exception::TopLevelNotFound")
builtin::blessed($err) $err->isa("Mason::Exception::TopLevelNotFound")
Truth table66%2/3
A and B
A= builtin::blessed($err)B= $err->isa("Mason::Exception::TopLevelNotFound")
ABresult
0X0
100
111
53 1 $poet->app_class('Plack::Response')->new(404);
54 }
55 else {
56  
57 # Prevent Plack::Middleware::Debug from capturing this stack point
58 1 local $SIG{__DIE__} = undef;
59 1 die $err;
60 }
61 1 };
62 1 return $response->finalize;
63 2 }
64  
65 2 ▶method _psgi_comp_path ($class: $req) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _psgi_comp_path: called CC=2 SCAR=7.0
66 14 my $comp_path = $req->path;
67 14 ▶ $comp_path = "/$comp_path" if substr( $comp_path, 0, 1 ) ne '/';
Branch: 1 branch
BranchTrueFalseTotal
if substr($comp_path, 0, 1) ne "/" 0 14 14
68 14 return $comp_path;
69 2 }
70  
71 2 ▶method _psgi_parameters ($class: $req) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _psgi_parameters: called CC=1 SCAR=0.0
72 14 return $req->parameters;
73 2 }
74  
75 2 1;
76  
77 __END__
« blib/lib/Poet.pm ↑ Summary blib/lib/Poet/Mechanize.pm »