Pickles/WebApp.pm

filter: Statementstmt 89.8% 62 / 69 Branchbran 43.7% 7 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 14 / 16 Podpod 88.8% 8 / 9 totaltotal 82.7% 91 / 110 CC 9 SCAR 8.4
CC
9
Cov
81%
handler
6.0
new
4.2
get_routes_file
2.0
CRAP 2.3
« Pickles/View.pm ↑ Summary Pickles/Plugin/Encode.pm »
1 package Pickles::WebApp;
2 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 8 ▶use base qw(Class::Data::Inheritable);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use Plack::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use Plack::Util::Accessor qw(config dispatcher container);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use Pickles::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 __PACKAGE__->mk_classdata( 'config_class' => 'Config' );
10 8 __PACKAGE__->mk_classdata( 'dispatcher_class' => 'Dispatcher' );
11 8 __PACKAGE__->mk_classdata( 'context_class' => 'Context' );
12 8 __PACKAGE__->mk_classdata( 'container_class' => 'Container' );
13  
14 5 ▶sub new {
Subroutine new: called CC=4 SCAR=14.3
Pod documented
15 5 my $class = shift;
16 5 my %args = @_;
17 5 my $self = bless { %args }, $class;
18 5 ▶ $self->config( $self->setup_config ) unless $self->config;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->config 5 0 5
19 5 ▶ $self->dispatcher( $self->setup_dispatcher ) unless $self->dispatcher;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->dispatcher 5 0 5
20 5 ▶ $self->container( $self->setup_container ) unless $self->container;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->container 5 0 5
21 5 $self;
22 }
23  
24 0 ▶sub handler {
Subroutine handler: not called CC=2 SCAR=17.9
Pod documented
25 0 my $self = shift;
26 0 ▶ $self = $self->new unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
27 0 ▶ my $app = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 0 my $env = shift;
29 0 my $c = $self->create_context(
30 env => $env,
31 );
32 0 $c->dispatch;
33 0 };
34 0 $app;
35 }
36  
37 25 ▶sub appname { shift->config->appname; }
Subroutine appname: called CC=1 SCAR=0.0
Pod documented
38  
39 5 ▶sub setup_config {
Subroutine setup_config: called CC=1 SCAR=0.0
Pod documented
40 5 my $self = shift;
41 5 my $config_class =
42 Plack::Util::load_class( $self->config_class, ref $self );
43 5 $config_class->construct;
44 }
45  
46 5 ▶sub setup_dispatcher {
Subroutine setup_dispatcher: called CC=1 SCAR=0.0
Pod documented
47 5 my $self = shift;
48 5 my $dispatcher_class =
49 Plack::Util::load_class( $self->dispatcher_class, $self->appname );
50 5 my $dispatcher = $dispatcher_class->new( file => $self->get_routes_file );
51 5 $dispatcher->load_controllers( $self->appname );
52 5 $dispatcher;
53 }
54  
55 5 ▶sub get_routes_file {
Subroutine get_routes_file: called CC=2 SCAR=7.0
Pod documented
56 5 my $self = shift;
57 5 my $file = Pickles::Util::env_value( 'ROUTES', $self->appname );
58 5 ▶ if (! $file) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($file) 5 0 5
59 5 $file = $self->config->path_to( 'etc/routes.pl' );
60 }
61 5 return $file;
62 }
63  
64 5 ▶sub setup_container {
Subroutine setup_container: called CC=2 SCAR=7.0
Pod documented
65 5 my $self = shift;
66 5 my $container_class =
67 Plack::Util::load_class( $self->container_class, ref $self );
68 5 my $container = $container_class->new;
69 5 $container->register( config => $self->config );
70 5 my $file = $self->get_container_file;
71 5 ▶ if ( -e $file ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $file) 5 0 5
72 5 $container->load( $file );
73 }
74 5 $container;
75 }
76  
77 5 ▶sub get_container_file {
Subroutine get_container_file: called CC=2 SCAR=7.0
Pod documented
78 5 my $self = shift;
79 5 my $file = Pickles::Util::env_value('CONTAINER_FILE', $self->appname );
80 5 ▶ if (! $file) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($file) 5 0 5
81 5 $file = $self->config->path_to( 'etc/container.pl' );
82 }
83 5 return $file;
84 }
85  
86 5 ▶sub create_context {
Subroutine create_context: called CC=2 SCAR=7.0
Pod undocumented
87 5 my $self = shift;
88 5 ▶ $self = $self->new unless blessed $self;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($self) 5 0 5
89 5 my %args = (
90 config => $self->config,
91 dispatcher => $self->dispatcher,
92 container => $self->container,
93 @_
94 );
95 5 my $context_class =
96 Plack::Util::load_class( $self->context_class, $self->appname );
97 5 $context_class->new( %args );
98 }
99  
100  
101 8 1;
102  
103 __END__
« Pickles/View.pm ↑ Summary Pickles/Plugin/Encode.pm »