lib/Wcpancover.pm

filter: Statementstmt 85.0% 51 / 60 Branchbran 18.7% 3 / 16 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 9 / 12 Podpod 100% 1 / 1 totaltotal 69.1% 65 / 94 CC 10 SCAR 25.8
CC
10
Cov
70%
__ANON__
42.0
startup
3.0
__ANON__
2.3
CRAP 13.2
« 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.02';
7  
8 2 ▶use File::Basename 'dirname';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use File::Spec::Functions qw'rel2abs catdir';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use File::ShareDir 'dist_dir';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 0 ▶has db => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
14 0 my $self = shift;
15 my $schema_class = $self->config->{db_schema}
16 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
17 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
18 or die "Could not load Schema Class ($schema_class), $@";
19  
20 my $db_connect = $self->config->{db_connect}
21 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
22 0 ▶ my @db_connect = ref $db_connect ? @$db_connect : ($db_connect);
Branch: 1 branch
BranchTrueFalseTotal
ref $db_connect ? : 0 0 0
23  
24 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
25 or die "Could not connect to $schema_class using $db_connect[0]";
26  
27 0 return $schema;
28 2 };
29  
30 2 has app_debug => 0;
31  
32 1 ▶has home_path => sub {
Subroutine __ANON__: called CC=2 SCAR=8.1
33 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
34 1 return File::Spec->rel2abs($path);
35 2 };
36  
37 1 ▶has config_file => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
38 1 my $self = shift;
39 1 ▶ return $ENV{WCPANCOVER_CONFIG} if $ENV{WCPANCOVER_CONFIG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"WCPANCOVER_CONFIG"} 0 1 1
40  
41 1 return rel2abs('wcpancover.conf', $self->home_path);
42 2 };
43  
44 1 ▶sub startup {
Subroutine startup: called CC=3 SCAR=11.1
Pod documented
45 1 my $app = shift;
46  
47 1 $app->plugin(
48 Config => {
49 file => $app->config_file,
50 default => {
51 'db_connect' => [
52 'dbi:SQLite:dbname=' . $app->home->rel_file('wcpancover.db'),
53 undef,
54 undef,
55 {'sqlite_unicode' => 1}
56 ],
57 'db_schema' => 'Wcpancover::DB::Schema',
58 'secret' => '47110815'
59 },
60 }
61 );
62  
63 1 $app->plugin('I18N');
64 1 $app->plugin('Mojolicious::Plugin::ServerInfo');
65 1 $app->plugin('Mojolicious::Plugin::DBInfo');
66  
67 {
68 # use content from directories under share/files or using File::ShareDir
69 1 my $lib_base = catdir(dirname(rel2abs(__FILE__)), '..', 'share','files');
70  
71 1 my $public = catdir($lib_base, 'public');
72  
73 1 ▶ $app->static->paths->[0] = -d $public ? $public : catdir(dist_dir('Wcpancover'), 'files','public');
Branch: 1 branch
BranchTrueFalseTotal
-d $public ? : 0 1 1
74 1 my $static_path = $app->static->paths->[0];
75  
76 1 my $templates = catdir($lib_base, 'templates');
77 1 ▶ $app->renderer->paths->[0] = -d $templates ? $templates : catdir(dist_dir('Wcpancover'), 'files', 'templates');
Branch: 1 branch
BranchTrueFalseTotal
-d $templates ? : 0 1 1
78 }
79  
80 1 push @{$app->commands->namespaces}, 'Wcpancover::Command';
81  
82 1 $app->secrets([$app->config->{secret}]);
83  
84 0 ▶ $app->helper(schema => sub { shift->app->db });
Subroutine __ANON__: not called CC=1 SCAR=1.2
85  
86 0 ▶ $app->helper('home_page' => sub {'/'});
Subroutine __ANON__: not called CC=1 SCAR=1.2
87  
88 1 my $routes = $app->routes;
89  
90 1 $routes->get('/')->to('front#index');
91 1 $routes->get('/front/*name')->to('front#page');
92 1 $routes->get('/dist/*name')->to('dist#show');
93 1 $routes->get('/author/*author')->to('author#show');
94  
95  
96 }
97  
98 2 1;
99  
100 __END__
« lib/Wcpancover/Admin.pm ↑ Summary script/getcovered.pl »