lib/Wcpancover.pm

filter: Statementstmt 83.7% 62 / 74 Branchbran 18.7% 3 / 16 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 64.7% 11 / 17 Podpod 100% 1 / 1 totaltotal 69.0% 78 / 113 CC 10 SCAR 23.9
CC
10
Cov
71%
__ANON__
42.0
startup
3.1
__ANON__
2.3
CRAP 10.9
« lib/Wcpancover/Admin.pm ↑ Summary script/getcovered.pl »
1 package Wcpancover;
2 2 ▶use Mojo::Base 'Mojolicious';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '0.05';
7  
8 2 ▶use File::Basename 'dirname';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use File::Spec::Functions qw'rel2abs catdir';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use File::ShareDir 'dist_dir';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use Mojo::Home;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶has db => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
17 0 my $self = shift;
18 my $schema_class = $self->config->{db_schema}
19 0 ▶ or die "Unknown DB Schema Class";
Branch: 1 branch
BranchTrueFalseTotal
my $schema_class = $self->config->{"db_schema"} or die "Unknown DB Schema Class" 0 0 0
20 0 ▶ eval "require $schema_class"
Branch: 1 branch
BranchTrueFalseTotal
eval "require $schema_class" or die "Could not load Schema Class ($schema_class), $@" 0 0 0
21 or die "Could not load Schema Class ($schema_class), $@";
22  
23 my $db_connect = $self->config->{db_connect}
24 0 ▶ or die "No DBI connection string provided";
Branch: 1 branch
BranchTrueFalseTotal
my $db_connect = $self->config->{"db_connect"} or die "No DBI connection string provided" 0 0 0
25 0 ▶ my @db_connect = ref $db_connect ? @$db_connect : ($db_connect);
Branch: 1 branch
BranchTrueFalseTotal
ref $db_connect ? : 0 0 0
26  
27 0 ▶ my $schema = $schema_class->connect(@db_connect)
Branch: 1 branch
BranchTrueFalseTotal
my $schema = $schema_class->connect(@db_connect) or die "Could not connect to $schema_class using $db_connect[0]" 0 0 0
28 or die "Could not connect to $schema_class using $db_connect[0]";
29  
30 0 return $schema;
31 2 };
32  
33 2 has app_debug => 0;
34  
35 1 ▶has home_path => sub {
Subroutine __ANON__: called CC=2 SCAR=8.1
36 1 ▶ my $path = $ENV{MOJO_HOME} || getcwd;
Condition33%1/3
$ENV{'MOJO_HOME'} || getcwd()
l!l&&r!l&&!r
010
MC/DC0%0/2
$ENV{'MOJO_HOME'} || getcwd()
$ENV{'MOJO_HOME'} getcwd()
Truth table33%1/3
A || B
A= $ENV{'MOJO_HOME'}B= getcwd()
ABresult
1X1
011
000
37 1 return File::Spec->rel2abs($path);
38 2 };
39  
40 1 ▶has config_file => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
41 1 my $self = shift;
42 1 ▶ return $ENV{WCPANCOVER_CONFIG} if $ENV{WCPANCOVER_CONFIG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"WCPANCOVER_CONFIG"} 0 1 1
43  
44 1 return rel2abs('wcpancover.conf', $self->home_path);
45 2 };
46  
47 1 ▶sub startup {
Subroutine startup: called CC=3 SCAR=11.2
Pod documented
48 1 my $app = shift;
49  
50 1 $app->plugin(
51 Config => {
52 file => $app->config_file,
53 default => {
54 'db_connect' => [
55 'dbi:SQLite:dbname=' . $app->home->rel_file('wcpancover.db'),
56 undef,
57 undef,
58 {'sqlite_unicode' => 1}
59 ],
60 'db_schema' => 'Wcpancover::DB::Schema',
61 'secret' => '47110815'
62 },
63 }
64 );
65  
66 1 $app->plugin('I18N');
67 1 $app->plugin('Mojolicious::Plugin::ServerInfo');
68 1 $app->plugin('Mojolicious::Plugin::DBInfo');
69  
70 {
71 # use content from directories under share/files or using File::ShareDir
72 1 my $lib_base = catdir(dirname(rel2abs(__FILE__)), '..', 'share','files');
73  
74 1 my $public = catdir($lib_base, 'public');
75  
76 1 ▶ $app->static->paths->[0] = -d $public ? $public : catdir(dist_dir('Wcpancover'), 'files','public');
Branch: 1 branch
BranchTrueFalseTotal
-d $public ? : 0 1 1
77 1 my $static_path = $app->static->paths->[0];
78  
79 1 my $templates = catdir($lib_base, 'templates');
80 1 ▶ $app->renderer->paths->[0] = -d $templates ? $templates : catdir(dist_dir('Wcpancover'), 'files', 'templates');
Branch: 1 branch
BranchTrueFalseTotal
-d $templates ? : 0 1 1
81 }
82  
83 1 push @{$app->commands->namespaces}, 'Wcpancover::Command';
84  
85 1 $app->secrets([$app->config->{secret}]);
86  
87 0 ▶ $app->helper(schema => sub { shift->app->db });
Subroutine __ANON__: not called CC=1 SCAR=1.2
88  
89 0 ▶ $app->helper('home_page' => sub {'/'});
Subroutine __ANON__: not called CC=1 SCAR=1.2
90  
91 1 my $routes = $app->routes;
92  
93 1 $routes->get('/')->to('front#index');
94 1 $routes->get('/front/*name')->to('front#page');
95 1 $routes->get('/dist/*name')->to('dist#show');
96 1 $routes->post('/dist')->to('dist#query');
97 0 ▶ $routes->get('/dists' => sub { shift->render });
Subroutine __ANON__: not called CC=1 SCAR=1.2
98  
99 1 $routes->get('/author/*author')->to('author#show');
100 1 $routes->post('/author')->to('author#query');
101 0 ▶ $routes->get('/authors' => sub { shift->render });
Subroutine __ANON__: not called CC=1 SCAR=1.2
102 0 ▶ $routes->get('/about' => sub { shift->render });
Subroutine __ANON__: not called CC=1 SCAR=1.2
103  
104  
105 }
106  
107 2 1;
108  
109 __END__
« lib/Wcpancover/Admin.pm ↑ Summary script/getcovered.pl »