| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Pickles::WebApp; |
|
2
|
8
|
|
|
8
|
|
198252
|
use strict; |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
273
|
|
|
3
|
8
|
|
|
8
|
|
40
|
use base qw(Class::Data::Inheritable); |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
3399
|
|
|
4
|
8
|
|
|
8
|
|
3744
|
use Plack::Util; |
|
|
8
|
|
|
|
|
41012
|
|
|
|
8
|
|
|
|
|
275
|
|
|
5
|
8
|
|
|
8
|
|
2609
|
use Plack::Util::Accessor qw(config dispatcher container); |
|
|
8
|
|
|
|
|
746
|
|
|
|
8
|
|
|
|
|
63
|
|
|
6
|
8
|
|
|
8
|
|
1948
|
use Pickles::Util; |
|
|
8
|
|
|
|
|
39
|
|
|
|
8
|
|
|
|
|
449
|
|
|
7
|
8
|
|
|
8
|
|
42
|
use Scalar::Util qw(blessed); |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
8487
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata( 'config_class' => 'Config' ); |
|
10
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata( 'dispatcher_class' => 'Dispatcher' ); |
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata( 'context_class' => 'Context' ); |
|
12
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata( 'container_class' => 'Container' ); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
|
15
|
5
|
|
|
5
|
1
|
12
|
my $class = shift; |
|
16
|
5
|
|
|
|
|
12
|
my %args = @_; |
|
17
|
5
|
|
|
|
|
18
|
my $self = bless { %args }, $class; |
|
18
|
5
|
50
|
|
|
|
40
|
$self->config( $self->setup_config ) unless $self->config; |
|
19
|
5
|
50
|
|
|
|
64
|
$self->dispatcher( $self->setup_dispatcher ) unless $self->dispatcher; |
|
20
|
5
|
50
|
|
|
|
67
|
$self->container( $self->setup_container ) unless $self->container; |
|
21
|
5
|
|
|
|
|
39
|
$self; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub handler { |
|
25
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
26
|
0
|
0
|
|
|
|
0
|
$self = $self->new unless ref $self; |
|
27
|
|
|
|
|
|
|
my $app = sub { |
|
28
|
0
|
|
|
0
|
|
0
|
my $env = shift; |
|
29
|
0
|
|
|
|
|
0
|
my $c = $self->create_context( |
|
30
|
|
|
|
|
|
|
env => $env, |
|
31
|
|
|
|
|
|
|
); |
|
32
|
0
|
|
|
|
|
0
|
$c->dispatch; |
|
33
|
0
|
|
|
|
|
0
|
}; |
|
34
|
0
|
|
|
|
|
0
|
$app; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
25
|
|
|
25
|
1
|
177
|
sub appname { shift->config->appname; } |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub setup_config { |
|
40
|
5
|
|
|
5
|
1
|
90
|
my $self = shift; |
|
41
|
5
|
|
|
|
|
37
|
my $config_class = |
|
42
|
|
|
|
|
|
|
Plack::Util::load_class( $self->config_class, ref $self ); |
|
43
|
5
|
|
|
|
|
281
|
$config_class->construct; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub setup_dispatcher { |
|
47
|
5
|
|
|
5
|
1
|
56
|
my $self = shift; |
|
48
|
5
|
|
|
|
|
33
|
my $dispatcher_class = |
|
49
|
|
|
|
|
|
|
Plack::Util::load_class( $self->dispatcher_class, $self->appname ); |
|
50
|
5
|
|
|
|
|
129
|
my $dispatcher = $dispatcher_class->new( file => $self->get_routes_file ); |
|
51
|
5
|
|
|
|
|
26
|
$dispatcher->load_controllers( $self->appname ); |
|
52
|
5
|
|
|
|
|
37
|
$dispatcher; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub get_routes_file { |
|
56
|
5
|
|
|
5
|
1
|
10
|
my $self = shift; |
|
57
|
5
|
|
|
|
|
24
|
my $file = Pickles::Util::env_value( 'ROUTES', $self->appname ); |
|
58
|
5
|
50
|
|
|
|
28
|
if (! $file) { |
|
59
|
5
|
|
|
|
|
18
|
$file = $self->config->path_to( 'etc/routes.pl' ); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
5
|
|
|
|
|
1736
|
return $file; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub setup_container { |
|
65
|
5
|
|
|
5
|
1
|
60
|
my $self = shift; |
|
66
|
5
|
|
|
|
|
40
|
my $container_class = |
|
67
|
|
|
|
|
|
|
Plack::Util::load_class( $self->container_class, ref $self ); |
|
68
|
5
|
|
|
|
|
215
|
my $container = $container_class->new; |
|
69
|
5
|
|
|
|
|
24
|
$container->register( config => $self->config ); |
|
70
|
5
|
|
|
|
|
36
|
my $file = $self->get_container_file; |
|
71
|
5
|
50
|
|
|
|
159
|
if ( -e $file ) { |
|
72
|
5
|
|
|
|
|
36
|
$container->load( $file ); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
5
|
|
|
|
|
33
|
$container; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub get_container_file { |
|
78
|
5
|
|
|
5
|
1
|
10
|
my $self = shift; |
|
79
|
5
|
|
|
|
|
19
|
my $file = Pickles::Util::env_value('CONTAINER_FILE', $self->appname ); |
|
80
|
5
|
50
|
|
|
|
22
|
if (! $file) { |
|
81
|
5
|
|
|
|
|
15
|
$file = $self->config->path_to( 'etc/container.pl' ); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
5
|
|
|
|
|
880
|
return $file; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub create_context { |
|
87
|
5
|
|
|
5
|
0
|
36143
|
my $self = shift; |
|
88
|
5
|
50
|
|
|
|
188
|
$self = $self->new unless blessed $self; |
|
89
|
5
|
|
|
|
|
33
|
my %args = ( |
|
90
|
|
|
|
|
|
|
config => $self->config, |
|
91
|
|
|
|
|
|
|
dispatcher => $self->dispatcher, |
|
92
|
|
|
|
|
|
|
container => $self->container, |
|
93
|
|
|
|
|
|
|
@_ |
|
94
|
|
|
|
|
|
|
); |
|
95
|
5
|
|
|
|
|
99
|
my $context_class = |
|
96
|
|
|
|
|
|
|
Plack::Util::load_class( $self->context_class, $self->appname ); |
|
97
|
5
|
|
|
|
|
353
|
$context_class->new( %args ); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |