Puzzle/DBI.pm

filter: Statementstmt 20.0% 8 / 40 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 33.3% 2 / 6 Podpod 0.0% 0 / 4 totaltotal 15.6% 10 / 64 CC 6 SCAR 20.8
CC
6
Cov
16%
new
12.0
rs2hash
12.0
rs2aoh
6.0
CRAP 8.0
« Puzzle/Request.pm ↑ Summary Puzzle/MasonHandler.pm »
1 package Puzzle::DBI;
2  
3 1 our $VERSION = '0.04';
4  
5 1 ▶use base 'DBIx::Class::Schema';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use DBIx::Class::Schema::Loader;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
10 0 my $proto = shift;
11 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
12 0 my $dsn = shift;
13 0 my $user = shift;
14 0 my $password = shift;
15 0 ▶ my $schema = shift || 'DBIx::Class::Schema::Loader';
Condition0%0/2
shift() || 'DBIx::Class::Schema::Loader'
l!l
00
MC/DC0%0/1
shift() || 'DBIx::Class::Schema::Loader'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
16 0 my $s = $schema->connect($dsn,$user,$password);
17 0 bless $s, $class;
18 0 return $s;
19 }
20  
21 0 ▶sub row2hash {
Subroutine row2hash: not called CC=1 SCAR=6.9
Pod undocumented
22 0 my $selft = shift;
23 0 my $rs = shift;
24 0 my $include_columns = shift;
25 0 my @columns = ($rs->columns, @$include_columns);
26 0 return {map { $rs->table.'.'.$_ => $rs->get_column($_) } @columns};
27 }
28  
29 0 ▶sub rs2aoh {
Subroutine rs2aoh: not called CC=2 SCAR=17.9
Pod undocumented
30 0 my $self = shift;
31 0 my $rs = shift;
32 0 my $include_columns = shift;
33 0 my @ret;
34 0 ▶ while (my $row = $rs->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $rs->next) 0 0 0
35 0 push @ret, $self->row2hash($row,$include_columns);
36 }
37 0 return \@ret;
38 }
39  
40 =head rs2hash()
41  
42 Return an hashref where every key is the primary key value or a contatenation
43 of primary keys and value is an hashref with record elements
44  
45 =cut
46  
47 0 ▶sub rs2hash {
Subroutine rs2hash: not called CC=3 SCAR=24.8
Pod undocumented
48 0 my $self = shift;
49 0 my $rs = shift;
50 0 my $include_columns = shift;
51 0 my $ret = {};
52 0 my @pk = $rs->result_source->primary_columns;
53 0 ▶ while (my $row = $rs->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $rs->next) 0 0 0
54 my $key = scalar(@pk) == 1
55 ? $row->get_column($pk[0]) . ''
56 0 ▶ : join('-',map {$row->$_} @pk);
Branch: 1 branch
BranchTrueFalseTotal
scalar @pk == 1 ? : 0 0 0
57 0 $ret->{$key} = $self->row2hash($row,$include_columns);
58 }
59 0 return $ret;
60 }
61  
62 1 1;
63  
« Puzzle/Request.pm ↑ Summary Puzzle/MasonHandler.pm »