examples/hypnotoad/lib/MyApp.pm

filter: Statementstmt 91.8% 34 / 37 Branchbran 0.0% 0 / 2 Conditioncond 36.3% 4 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 88.8% 8 / 9 Podpod 100% 1 / 1 totaltotal 70.1% 47 / 67 CC 6 SCAR 13.5
CC
6
Cov
76%
startup
7.0
__ANON__
6.0
BEGIN
1.0
CRAP 3.8
« blib/lib/Mojolicious/Plugin/Buffer/I18N.pm ↑ Summary blib/lib/Mojolicious/Plugin/Buffer/Lock/File.pm »
1 package MyApp;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use CHI;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Basename qw(dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use File::Path qw(make_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Mojo::Base 'Mojolicious';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶sub startup {
Subroutine startup: called CC=5 SCAR=19.4
Pod documented
13 1 my $self = shift;
14  
15 1 my $home = $self->home;
16 1 my $var_dir = $home->child('var')->to_string;
17 1 ▶ my $cache_dir = $ENV{MYAPP_CACHE_DIR} // File::Spec->catdir($var_dir, 'cache');
Condition33%1/3
$ENV{"MYAPP_CACHE_DIR"} // "File::Spec"->catdir($var_dir, "cache")
l!l&&r!l&&!r
100
MC/DC0%0/2
$ENV{"MYAPP_CACHE_DIR"} // "File::Spec"->catdir($var_dir, "cache")
$ENV{"MYAPP_CACHE_DIR"} "File::Spec"->catdir($var_dir, "cache")
Truth table33%1/3
A // B
A= $ENV{"MYAPP_CACHE_DIR"}B= "File::Spec"->catdir($var_dir, "cache")
ABresult
1X1
011
000
18 1 ▶ my $lock_dir = $ENV{MYAPP_LOCK_DIR} // File::Spec->catdir($var_dir, 'locks');
Condition33%1/3
$ENV{"MYAPP_LOCK_DIR"} // "File::Spec"->catdir($var_dir, "locks")
l!l&&r!l&&!r
100
MC/DC0%0/2
$ENV{"MYAPP_LOCK_DIR"} // "File::Spec"->catdir($var_dir, "locks")
$ENV{"MYAPP_LOCK_DIR"} "File::Spec"->catdir($var_dir, "locks")
Truth table33%1/3
A // B
A= $ENV{"MYAPP_LOCK_DIR"}B= "File::Spec"->catdir($var_dir, "locks")
ABresult
1X1
011
000
19 1 ▶ my $pid_file = $ENV{MYAPP_PID_FILE} // File::Spec->catfile($var_dir, 'hypnotoad.pid');
Condition33%1/3
$ENV{"MYAPP_PID_FILE"} // "File::Spec"->catfile($var_dir, "hypnotoad.pid")
l!l&&r!l&&!r
100
MC/DC0%0/2
$ENV{"MYAPP_PID_FILE"} // "File::Spec"->catfile($var_dir, "hypnotoad.pid")
$ENV{"MYAPP_PID_FILE"} "File::Spec"->catfile($var_dir, "hypnotoad.pid")
Truth table33%1/3
A // B
A= $ENV{"MYAPP_PID_FILE"}B= "File::Spec"->catfile($var_dir, "hypnotoad.pid")
ABresult
1X1
011
000
20 1 ▶ my $listen = $ENV{MYAPP_LISTEN} // 'http://*:8080';
Condition50%1/2
$ENV{"MYAPP_LISTEN"} // "http://*:8080"
l!l
10
MC/DC0%0/1
$ENV{"MYAPP_LISTEN"} // "http://*:8080"
$ENV{"MYAPP_LISTEN"}
Truth table50%1/2
A
A= $ENV{"MYAPP_LISTEN"}
Aresult
11
00
21  
22 1 make_path($cache_dir, $lock_dir, dirname($pid_file));
23  
24 1 $self->config(hypnotoad => {
25 listen => [$listen],
26 workers => 4,
27 pid_file => $pid_file,
28 });
29  
30 1 $self->plugin('Buffer' => {
31 optimise_content => 1,
32 cache => CHI->new(
33 driver => 'File',
34 root_dir => $cache_dir,
35 namespace => 'pages',
36 ),
37 cache_lock_dir => $lock_dir,
38 cache_duration => '10 minutes',
39 });
40  
41 0 ▶ $self->routes->get('/expensive' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
42 0 my $c = shift;
43 0 ▶ return if $c->buffer_is_cached;
Branch: 1 branch
BranchTrueFalseTotal
if $c->buffer_is_cached 0 0 0
44  
45 # ... expensive work ...
46  
47 0 $c->render(template => 'expensive', built_at => scalar localtime);
48 1 });
49  
50 1 return;
51 }
52  
53 1 1;
« blib/lib/Mojolicious/Plugin/Buffer/I18N.pm ↑ Summary blib/lib/Mojolicious/Plugin/Buffer/Lock/File.pm »