Salus.pm

filter: Statementstmt 98.4% 64 / 65 Branchbran 77.7% 14 / 18 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 13 / 13 Podpod 100% 1 / 1 totaltotal 93.0% 93 / 100 CC 12 SCAR 11.6
CC
12
Cov
93%
import
5.0
new
5.0
__ANON__
4.0
CRAP 3.2
« Salus/Row.pm ↑ Summary Salus/Command.pm »
1 package Salus;
2  
3 3 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 our $VERSION = '0.10';
7  
8 3 ▶use Salus::Header;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Salus::Table;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 my (%PRO, %META);
12 3 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
13 %PRO = (
14 4 ▶ keyword => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
15 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 my ($caller, $keyword, $cb) = @_;
17 4 *{"${caller}::${keyword}"} = $cb;
18 },
19 28 ▶ clone => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
20 28 my $obj = shift;
21 28 my $ref = ref $obj;
22 28 ▶ return $obj if !$ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 16 12 28
23 12 ▶ return [ map { $PRO{clone}->($_) } @{$obj} ] if $ref eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "ARRAY" 2 10 12
24 10 ▶ return { map { $_ => $PRO{clone}->($obj->{$_}) } keys %{$obj} } if $ref eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "HASH" 10 0 10
25 0 return $obj;
26 }
27 3 );
28 }
29  
30 3 ▶sub import {
Subroutine import: called CC=5 SCAR=16.1
31 3 my ($pkg, %import) = @_;
32  
33 3 my $caller = caller();
34  
35 3 ▶ if (exists $import{header} ? $import{header} : $import{all}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $import{"header"} ? $import{"header"} : $import{"all"}) 2 1 3
exists $import{'header'} ? : 0 3 3
36 2 my ($index, %indexes) = (0, ());
37 8 ▶ $PRO{keyword}($caller, 'header', sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
38 8 my ($name, %options) = @_;
39 8 $options{name} = $name;
40 8 push @{$META{$caller}{headers}}, \%options;
41 2 });
42 }
43  
44 3 ▶ if (exists $import{new} ? $import{new} : $import{all}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $import{"new"} ? $import{"new"} : $import{"all"}) 2 1 3
exists $import{'new'} ? : 0 3 3
45 2 ▶ $PRO{keyword}($caller, 'new', sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
46 2 my ($pkg, %options) = @_;
47 2 __PACKAGE__->new($META{$caller}, \%options, $pkg);
48 2 });
49 }
50 }
51  
52 2 ▶sub new {
Subroutine new: called CC=5 SCAR=16.1
Pod documented
53 2 my ($self, $meta, $options, $caller) = @_;
54
55 2 $meta = $PRO{clone}($meta);
56  
57 2 my ($i, @headers, %properties) = (0, (), ());
58  
59 my %indexes = map {
60 8 ▶ $_->{index} ? ($_->{index} => 1) : ()
Branch: 1 branch
BranchTrueFalseTotal
$_->{'index'} ? : 0 8 8
61 2 } @{ $meta->{headers} };
62  
63 2 for my $header (@{$meta->{headers}}) {
64 8 while (1) {
65 14 ▶ unless ($indexes{$i}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($indexes{$i}) 8 6 14
66 8 $indexes{$i}++;
67 8 $header->{index} = $i;
68 8 last;
69 }
70 6 ++$i;
71 }
72 8 push @headers, Salus::Header->new(%{$header});
73 }
74  
75 return Salus::Table->new(
76 2 ▶ %{$options},
Condition50%1/2
$meta->{'rows'} || []
l!l
02
MC/DC0%0/1
$meta->{'rows'} || []
$meta->{'rows'}
Truth table50%1/2
A
A= $meta->{'rows'}
Aresult
11
00
77 headers => \@headers,
78 2 rows => $meta->{rows} || []
79 );
80 }
81  
82 3 1;
83  
84 __END__;
« Salus/Row.pm ↑ Summary Salus/Command.pm »