Navigator/Node/DBI.pm

filter: Statementstmt 44.6% 46 / 103 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 43.3% 13 / 30 Podpod 100% 6 / 6 totaltotal 43.6% 65 / 149 CC 5 SCAR 10.9
CC
5
Cov
41%
_attributes
12.0
MOUNT
6.0
_attributes
6.0
CRAP 3.0
« Navigator/Node/DBIDM.pm ↑ Summary Navigator/View/TT2.pm »
1 package Tree::Navigator::Node::DBI;
2 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 extends 'Tree::Navigator::Node';
6  
7 1 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Params::Validate qw/validate/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub MOUNT {
Subroutine MOUNT: not called CC=2 SCAR=17.9
Pod documented
12 0 my ($class, $mount_args) = @_;
13 0 ▶ my @mount_point = %{$mount_args->{mount_point} || {}};
Condition0%0/2
$mount_args->{'mount_point'} || {}
l!l
00
MC/DC0%0/1
$mount_args->{'mount_point'} || {}
$mount_args->{'mount_point'}
Truth table0%0/2
A
A= $mount_args->{'mount_point'}
Aresult
11
00
14 0 $mount_args->{mount_point} = validate(@mount_point , {
15 dbh => {isa => 'DBI::db'},
16 });
17 }
18  
19 0 ▶sub is_parent { return 1 }
Subroutine is_parent: not called CC=1 SCAR=6.9
Pod documented
20  
21 0 ▶sub _children {
Subroutine _children: not called CC=1 SCAR=6.9
22 0 my $self = shift;
23 0 return [qw/Tables Rows/];
24 }
25  
26  
27 0 ▶sub _child {
Subroutine _child: not called CC=1 SCAR=6.9
28 0 my ($self, $child_path) = @_;
29 0 my $class = ref $self;
30 0 my $subclass = $class . "::" . $child_path;
31 0 return $subclass->new(mount_point => $self->mount_point,
32 path => $child_path);
33 }
34  
35 0 ▶sub _attributes {
Subroutine _attributes: not called CC=1 SCAR=6.9
36 0 my $self = shift;
37 0 my $dbh = $self->mount_point->{dbh};
38 0 return {dbh => $dbh->{Name}};
39 }
40  
41  
42 1 __PACKAGE__->meta->make_immutable;
43  
44 package Tree::Navigator::Node::DBI::Tables;
45 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 1 extends 'Tree::Navigator::Node';
48  
49 0 ▶sub is_parent { return 1 }
Subroutine is_parent: not called CC=1 SCAR=6.9
Pod documented
50  
51 0 ▶sub _children {
Subroutine _children: not called CC=1 SCAR=6.9
52 0 my $self = shift;
53 0 my $dbh = $self->mount_point->{dbh};
54  
55 0 my %args
56 = (catalog => undef, schema => undef, table => undef, type => "TABLE");
57 0 my $tables_sth = $dbh->table_info(@args{qw/catalog schema table type/});
58 0 my $tables = $tables_sth->fetchall_arrayref({TABLE_NAME => 1});
59 0 return [map {$_->{TABLE_NAME}} @$tables];
60 }
61  
62 0 ▶sub _child {
Subroutine _child: not called CC=1 SCAR=6.9
63 0 my ($self, $table_name) = @_;
64 0 return Tree::Navigator::Node::DBI::Table->new(
65 mount_point => $self->mount_point,
66 path => ($self->path . "/" . $table_name),
67 );
68 }
69  
70 package Tree::Navigator::Node::DBI::Table;
71 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 1 extends 'Tree::Navigator::Node';
74  
75 0 ▶sub is_parent { return 1 }
Subroutine is_parent: not called CC=1 SCAR=6.9
Pod documented
76  
77 0 ▶sub _children {
Subroutine _children: not called CC=1 SCAR=6.9
78 0 my $self = shift;
79 0 my $dbh = $self->mount_point->{dbh};
80 0 my $table = $self->last_path;
81  
82 0 my %args
83 = (catalog => undef, schema => undef, table => $table, column => undef);
84 0 my $columns_sth = $dbh->column_info(@args{qw/catalog schema table column/});
85 0 my $columns = $columns_sth->fetchall_arrayref({COLUMN_NAME => 1});
86 0 return [map {$_->{COLUMN_NAME}} @$columns];
87 }
88  
89 0 ▶sub _child {
Subroutine _child: not called CC=1 SCAR=6.9
90 0 my ($self, $col_name) = @_;
91 0 return Tree::Navigator::Node::DBI::Column->new(
92 mount_point => $self->mount_point,
93 path => ($self->path . "/" . $col_name),
94 );
95 }
96  
97 0 ▶sub _attributes {
Subroutine _attributes: not called CC=2 SCAR=17.9
98 0 my $self = shift;
99 0 my $dbh = $self->mount_point->{dbh};
100 0 my $table = $self->last_path;
101 0 my %args = (catalog => undef, schema => undef, table => $table);
102 0 my @primary_key = $dbh->primary_key(@args{qw/catalog schema table/});
103 0 ▶ return {primary_key => join(";", @primary_key) || ''};
Condition0%0/2
join(';', @primary_key) || ''
l!l
00
MC/DC0%0/1
join(';', @primary_key) || ''
join(';', @primary_key)
Truth table0%0/2
A
A= join(';', @primary_key)
Aresult
11
00
104 }
105  
106 package Tree::Navigator::Node::DBI::Column;
107 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
108 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
109 1 extends 'Tree::Navigator::Node';
110  
111 0 ▶sub is_parent { return 0 }
Subroutine is_parent: not called CC=1 SCAR=6.9
Pod documented
112 0 ▶sub _children { return [] }
Subroutine _children: not called CC=1 SCAR=6.9
113  
114 0 ▶sub _attributes {
Subroutine _attributes: not called CC=3 SCAR=24.8
115 0 my $self = shift;
116 0 my $dbh = $self->mount_point->{dbh};
117 0 my ($col, $table) = reverse split "/", $self->path;
118 0 my %args
119 = (catalog => undef, schema => undef, table => $table, column => $col);
120 0 my $columns_sth = $dbh->column_info(@args{qw/catalog schema table column/});
121 0 my $col_info = $columns_sth->fetchrow_hashref;
122 0 my %attrs;
123 0 ▶ while (my ($col, $info) = each %$col_info) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$col_info) 0 0 0
124 0 ▶ $attrs{$col} = $info if $info;
Branch: 1 branch
BranchTrueFalseTotal
if $info 0 0 0
125 }
126 0 return \%attrs;
127 }
128  
129  
130 package Tree::Navigator::Node::DBI::Rows;
131 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
132 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
133 1 extends 'Tree::Navigator::Node';
134  
135 0 ▶sub is_parent { return 1 }
Subroutine is_parent: not called CC=1 SCAR=6.9
Pod documented
136  
137 0 ▶sub _children {
Subroutine _children: not called CC=1 SCAR=6.9
138 0 my $self = shift;
139 0 my $dbh = $self->mount_point->{dbh};
140  
141 # TODO
142 0 return [];
143 }
144  
145  
146 1 1; # End of Tree::Navigator::Node::DBI
147  
148  
149  
150 __END__
« Navigator/Node/DBIDM.pm ↑ Summary Navigator/View/TT2.pm »