lib/Egg/Model/DBIC.pm

filter: Statementstmt 40.8% 29 / 71 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 25 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 64.2% 9 / 14 Podpod n/a totaltotal 28.3% 38 / 134 CC 20 SCAR 47.1
CC
20
Cov
27%
_setup
210.6
__ANON__
20.0
_setup
2.0
CRAP 111.4
« lib/Egg/Helper/Model/DBIC.pm ↑ Summary blib/lib/Egg/Plugin/DBIC.pm »
1 package Egg::Model::DBIC;
2 #
3 # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4 #
5 # $Id: DBIC.pm 324 2008-04-17 12:45:09Z lushe $
6 #
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION = '3.01';
11  
12 0 ▶sub _setup {
Subroutine _setup: not called CC=1 SCAR=6.9
13 0 my($class, $e)= @_;
14 0 Egg::Model::DBIC::handler->_setup($e);
15 0 $class->next::method($e);
16 }
17  
18 package Egg::Model::DBIC::handler;
19 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use UNIVERSAL::require;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use base qw/ Egg::Model /;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use Carp qw/ croak /;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 0 ▶sub _setup {
Subroutine _setup: not called CC=17 SCAR=53.5
25 0 my($class, $e)= @_;
26 0 my $dbic_path= $e->path_to(qw{ lib_project Model/DBIC });
27 0 ▶ -e $dbic_path || die __PACKAGE__. qq{ - '${dbic_path}'is not found. };
Branch: 1 branch
BranchTrueFalseTotal
-e $dbic_path or die 'Egg::Model::DBIC::handler' . " - '${dbic_path}'is not found. " 0 0 0
28 0 my $schemas= $e->ixhash;
29 2 ▶ no strict 'refs'; ## no critic.
Subroutine BEGIN: called CC=1 SCAR=0.0
30 2 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 0 ▶ for (sort (grep /\.pm$/, <$dbic_path/*>)) { ## no critic.
Subroutine BEGIN: called CC=1 SCAR=0.2
32 0 ▶ m{([^\\\/\:]+)\.pm$} || next;
Branch: 1 branch
BranchTrueFalseTotal
m[([^\\\/\:]+)\.pm$] or next 0 0 0
33 0 my $pkg = $e->project_name. "::Model::DBIC::$1";
34 0 my $name= lc $1;
35 0 ▶ $pkg->require or die $@;
Branch: 1 branch
BranchTrueFalseTotal
$pkg->require or die $@ 0 0 0
36 0 ▶ my $c= $pkg->config || die __PACKAGE__. qq{ - '$pkg' config is empty. };
Condition0%0/2
$pkg->config || die('Egg::Model::DBIC::handler' . " - '${pkg}' config is empty. ")
l!l
00
MC/DC0%0/1
$pkg->config || die('Egg::Model::DBIC::handler' . " - '${pkg}' config is empty. ")
$pkg->config
Truth table0%0/2
A
A= $pkg->config
Aresult
11
00
37 0 ▶ $c->{dsn} || die __PACKAGE__. q{ - '$pkg' dsn is empty. };
Branch: 1 branch
BranchTrueFalseTotal
$c->{"dsn"} or die "Egg::Model::DBIC::handler - '\$pkg' dsn is empty. " 0 0 0
38 0 ▶ $c->{user} ||= "";
Condition0%0/2
$c->{"user"} ||= ""
l!l
00
MC/DC0%0/1
$c->{"user"} ||= ""
$c->{"user"}
Truth table0%0/2
A
A= $c->{"user"}
Aresult
11
00
39 0 ▶ $c->{password} ||= "";
Condition0%0/2
$c->{"password"} ||= ""
l!l
00
MC/DC0%0/1
$c->{"password"} ||= ""
$c->{"password"}
Truth table0%0/2
A
A= $c->{"password"}
Aresult
11
00
40 0 ▶ $c->{options} ||= {};
Condition0%0/2
$c->{"options"} ||= {}
l!l
00
MC/DC0%0/1
$c->{"options"} ||= {}
$c->{"options"}
Truth table0%0/2
A
A= $c->{"options"}
Aresult
11
00
41 0 ▶ my $label= lc( $c->{label_name} || "dbic::$name" );
Condition0%0/2
$c->{'label_name'} || "dbic::$name"
l!l
00
MC/DC0%0/1
$c->{'label_name'} || "dbic::$name"
$c->{'label_name'}
Truth table0%0/2
A
A= $c->{'label_name'}
Aresult
11
00
42 0 ▶ my $alias= $c->{label_source} || $c->{label_moniker} || {};
Condition0%0/5
$c->{'label_source'} || $c->{'label_moniker'} || {}
l!l
00
$c->{"label_source"} or $c->{"label_moniker"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->{'label_source'} || $c->{'label_moniker'} || {}
$c->{"label_source"} $c->{"label_moniker"}
Truth table0%0/3
A or B
A= $c->{"label_source"}B= $c->{"label_moniker"}
ABresult
1X1
011
000
43 0 $alias= { map{ lc($_) => $alias->{$_} }keys %$alias };
44 0 $e->model_manager->add_register(0, $label, $pkg);
45 0 *{"${pkg}::new"}= $class->_mk_schema_closure
46 0 ($pkg, @{$c}{qw{ dsn user password options }});
47 0 ▶ my $schema= $pkg->new
Condition0%0/2
$pkg->new || die(" Schema of '${pkg}' cannot be connected. ")
l!l
00
MC/DC0%0/1
$pkg->new || die(" Schema of '${pkg}' cannot be connected. ")
$pkg->new
Truth table0%0/2
A
A= $pkg->new
Aresult
11
00
48 || die qq{ Schema of '$pkg' cannot be connected. };
49 0 for my $moniker ($schema->sources) {
50 0 my $m_class= "${pkg}::$moniker";
51 0 ▶ my $m_label= $alias->{lc $moniker} || "${label}::$moniker";
Condition0%0/2
$$alias{lc $moniker} || "${label}::$moniker"
l!l
00
MC/DC0%0/1
$$alias{lc $moniker} || "${label}::$moniker"
$$alias{lc $moniker}
Truth table0%0/2
A
A= $$alias{lc $moniker}
Aresult
11
00
52 0 $e->model_manager->add_register(0, $m_label, $m_class);
53 0 *{"${m_class}::ACCEPT_CONTEXT"}=
54 0 ▶ sub { $_[1]->model($label)->resultset($moniker) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
55 }
56 0 $schemas->{$label}= $pkg;
57 }
58 0 ▶ %$schemas or die __PACKAGE__. q{ - Schema module is not found. };
Branch: 1 branch
BranchTrueFalseTotal
%$schemas or die "Egg::Model::DBIC::handler - Schema module is not found. " 0 0 0
59 0 $e->global->{dbic_schemas}= $schemas;
60 0 @_;
61 }
62 0 ▶sub _mk_schema_closure {
Subroutine _mk_schema_closure: not called CC=1 SCAR=6.9
63 0 my($class, $s_class, @source)= @_;
64 0 my $schema;
65 0 ▶ sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
66 return $schema if ( $schema
67 and $schema->storage->dbh->{Active}
68 0 ▶ and $schema->storage->dbh->ping
Branch: 1 branch
BranchTrueFalseTotal
if $schema and $schema->storage->dbh->{"Active"} and $schema->storage->dbh->ping 0 0 0
Condition0%0/6
$schema and $schema->storage->dbh->{"Active"} and $schema->storage->dbh->ping
!ll&&!rl&&r
000
$schema and $schema->storage->dbh->{"Active"}
!ll&&!rl&&r
000
MC/DC0%0/3
$schema and $schema->storage->dbh->{"Active"} and $schema->storage->dbh->ping
$schema $schema->storage->dbh->{"Active"} $schema->storage->dbh->ping
Truth table0%0/4
A and B and C
A= $schemaB= $schema->storage->dbh->{"Active"}C= $schema->storage->dbh->ping
ABCresult
0XX0
10X0
1100
1111
69 );
70 0 $schema= $s_class->connect(@source);
71 0 };
72 }
73  
74 2 1;
75  
76 __END__
« lib/Egg/Helper/Model/DBIC.pm ↑ Summary blib/lib/Egg/Plugin/DBIC.pm »