AutoCRUD/Controller/Schema.pm

filter: Statementstmt 71.4% 30 / 42 Branchbran 20.0% 2 / 10 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 90.0% 9 / 10 Podpod 100% 3 / 3 totaltotal 55.7% 44 / 79 CC 9 SCAR 31.2
CC
9
Cov
52%
perl_code
56.0
serve
3.1
BEGIN
1.0
CRAP 22.7
↑ Summary AutoCRUD/DataSource.pm »
1 package App::AutoCRUD::Controller::Schema;
2
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 extends 'App::AutoCRUD::Controller';
9 1 ▶use YAML;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Clone qw/clone/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11
12 1 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
13
14
15 #----------------------------------------------------------------------
16 # entry point to the controller
17 #----------------------------------------------------------------------
18 1 ▶sub serve {
Subroutine serve: called CC=3 SCAR=11.4
Pod documented
19 1 my ($self) = @_;
20
21 # extract from path : method to dispatch to
22 1 ▶ my $meth_name = $self->context->extract_path_segments(1)
Branch: 1 branch
BranchTrueFalseTotal
my $meth_name = $self->context->extract_path_segments(1) or die "URL too short, missing method name" 1 0 1
23 or die "URL too short, missing method name";
24 1 ▶ my $method = $self->can($meth_name)
Branch: 1 branch
BranchTrueFalseTotal
my $method = $self->can($meth_name) or die "no such method: $meth_name" 1 0 1
25 or die "no such method: $meth_name";
26
27 # dispatch to method
28 1 return $self->$method();
29 }
30
31 #----------------------------------------------------------------------
32 # published methods
33 #----------------------------------------------------------------------
34
35 1 ▶sub tablegroups {
Subroutine tablegroups: called CC=1 SCAR=0.0
Pod documented
36 1 my ($self) = @_;
37
38 1 my $context = $self->context;
39 1 $context->set_template("schema/tablegroups.tt");
40 1 return $context->datasource->tablegroups;
41 }
42
43 0 ▶sub perl_code {
Subroutine perl_code: not called CC=7 SCAR=40.3
Pod documented
44 0 my ($self) = @_;
45
46 # set view to "plain"
47 0 ▶ my $view_class = $self->app->find_class("View::Plain")
Branch: 1 branch
BranchTrueFalseTotal
my $view_class = $self->app->find_class("View::Plain") or die "no Plain view" 0 0 0
48 or die "no Plain view";
49 0 $self->context->set_view($view_class->new);
50
51 # call datasource schema (which may indirectly generate the perl class
52 # on the fly, from the DBI connection)
53 0 my $schema = $self->datasource->schema;
54
55 # retrieve perl code, either just generated, or from an existing .pm module
56 0 ▶ my $perl_code = $self->datasource->generated_schema || do {
Condition0%0/3
$self->datasource->generated_schema || do { my $schema_class = $self->datasource->loaded_class || ref $schema || $schema; $schema_class =~ s[::][/]g; my $path = $INC{$schema_class . '.pm'} or die "can't find source code for $schema_class.pm"; open my $fh, '<', $path or die "can't open $path"; local $/; readline $fh }
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->datasource->generated_schema || do { my $schema_class = $self->datasource->loaded_class || ref $schema || $schema; $schema_class =~ s[::][/]g; my $path = $INC{$schema_class . '.pm'} or die "can't find source code for $schema_class.pm"; open my $fh, '<', $path or die "can't open $path"; local $/; readline $fh }
$self->datasource->generated_schema do { my $schema_class = $self->datasource->loaded_class || ref $schema || $schema; $schema_class =~ s[::][/]g; my $path = $INC{$schema_class . '.pm'} or die "can't find source code for $schema_class.pm"; open my $fh, '<', $path or die "can't open $path"; local $/; readline $fh }
Truth table0%0/3
A || B
A= $self->datasource->generated_schemaB= do { my $schema_class = $self->datasource->loaded_class || ref $schema || $schema; $schema_class =~ s[::][/]g; my $path = $INC{$schema_class . '.pm'} or die "can't find source code for $schema_class.pm"; open my $fh, '<', $path or die "can't open $path"; local $/; readline $fh }
ABresult
1X1
011
000
57
58 # retrieve loaded classname
59 0 ▶ my $schema_class = $self->datasource->loaded_class || ref $schema || $schema;
Condition0%0/6
$self->datasource->loaded_class || ref $schema || $schema
l!l&&r!l&&!r
000
$self->datasource->loaded_class or ref $schema
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->datasource->loaded_class || ref $schema || $schema
$self->datasource->loaded_class ref $schema $schema
Truth table0%0/4
A or B || C
A= $self->datasource->loaded_classB= ref $schemaC= $schema
ABCresult
1XX1
01X1
0011
0000
60
61 # find source file and slurp its content
62 0 $schema_class =~ s[::][/]g;
63 0 ▶ my $path = $INC{$schema_class . ".pm"}
Branch: 1 branch
BranchTrueFalseTotal
my $path = $INC{$schema_class . '.pm'} or die "can't find source code for $schema_class.pm" 0 0 0
64 or die "can't find source code for $schema_class.pm";
65 0 ▶ open my $fh, "<", $path
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $path or die "can't open $path" 0 0 0
66 or die "can't open $path";
67 0 local $/;
68 0 <$fh>;
69 };
70
71 0 return $perl_code;
72 }
73
74
75 1 1;
76
77 __END__
↑ Summary AutoCRUD/DataSource.pm »