ODS/Utils.pm

filter: Statementstmt 100% 68 / 68 Branchbran 87.5% 7 / 8 Conditioncond 100% 4 / 4 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 16 / 16 Podpod 0.0% 0 / 5 totaltotal 94.1% 97 / 103 CC 12 SCAR 9.6
CC
12
Cov
99%
deep_unblessed
6.0
import
5.0
BEGIN
3.0
CRAP 2.6
« ODS/Table/Row.pm ↑ Summary ODS/Table/Column/Base.pm »
1 package ODS::Utils;
2  
3 74 ▶use YAOO;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 74 ▶no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 74 ▶use Data::GUID;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 74 ▶use File::Copy qw/move/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 74 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 74 ▶use Scalar::Util qw//;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 74 ▶use Data::Dumper qw/Dumper/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 73 our ( %EX, %EX2);
12  
13 BEGIN {
14 74 ▶ %EX = (
Subroutine BEGIN: called CC=3 SCAR=11.0
15 load => [qw/all/],
16 clone => [qw/all/],
17 unique_class_name => [qw/all/],
18 build_temp_class => [qw/all/],
19 move => [qw/all/],
20 deep_unblessed => [qw/all/],
21 croak => [qw/error/],
22 Dumper => [qw/error/]
23 );
24 74 for my $ex (keys %EX) {
25 585 for (@{ $EX{$ex} }) {
26 584 push @{ $EX2{$_} }, $ex;
27 }
28 }
29 }
30  
31 sub import {
32 568 ▶ my ($self, @functions) = @_;
Subroutine import: called CC=5 SCAR=16.1
33  
34 568 my $caller = caller();
35  
36 568 for my $fun (@functions) {
37 1002 ▶ if ($EX{$fun}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ODS::Utils::EX{$fun}) { } 640 362 1002
elsif ($ODS::Utils::EX2{$fun}) { } 362 0 362
38 640 YAOO::make_keyword($caller, $fun, *{"${self}::${fun}"});
39 } elsif ($EX2{$fun}) {
40 362 for (@{ $EX2{$fun} }) {
41 724 YAOO::make_keyword($caller, $_, *{"${self}::${_}"});
42 }
43 }
44 }
45  
46 }
47  
48 sub clone {
49 39378 ▶ my ($c) = @_;
Subroutine clone: called CC=1 SCAR=0.0
Pod undocumented
50 39378 my $n = bless YAOO::deep_clone_ordered_hash($c), ref $c;
51 39378 return $n;
52 }
53  
54 sub load {
55 1917 ▶ my ($module) = shift;
Subroutine load: called CC=1 SCAR=0.0
Pod undocumented
56 1917 (my $require = $module) =~ s/\:\:/\//g;
57 1917 require $require . '.pm';
58 1747 return $module;
59 }
60  
61 sub unique_class_name {
62 1862 ▶ return 'A' . join("", split("-", Data::GUID->new->as_string()));
Subroutine unique_class_name: called CC=1 SCAR=0.0
Pod undocumented
63 }
64  
65 sub build_temp_class {
66 150 ▶ my ($class) = @_;
Subroutine build_temp_class: called CC=1 SCAR=0.0
Pod undocumented
67 150 load $class;
68 150 my $temp = $class . '::' . unique_class_name();
69 150 my $c = sprintf(
70 q|
71 package %s;
72 use YAOO;
73 extends '%s';
74 1;
75 |, $temp, $class );
76 150 ▶ eval $c;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
77 150 return $temp;
78 }
79  
80 sub deep_unblessed {
81 16 ▶ my ($obj) = @_;
Subroutine deep_unblessed: called CC=6 SCAR=17.9
Pod undocumented
82  
83 16 ▶ if ((ref($obj) || "SCALAR") !~ m/ARRAY|HASH|SCALAR/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ((ref $obj || "SCALAR") =~ /ARRAY|HASH|SCALAR/) 8 8 16
Condition100%2/2
ref $obj || 'SCALAR'
l!l
88
MC/DC100%1/1
ref $obj || 'SCALAR'
ref $obj
Truth table100%2/2
A
A= ref $obj
Aresult
11
00
84 8 $obj = {%{ $obj }};
85 }
86  
87 16 ▶ if ((ref($obj) || "") eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $obj || "") eq "HASH") 8 8 16
Condition100%2/2
ref $obj || ''
l!l
88
MC/DC100%1/1
ref $obj || ''
ref $obj
Truth table100%2/2
A
A= ref $obj
Aresult
11
00
88 8 for my $key (keys %{ $obj }) {
89 12 $obj->{$key} = deep_unblessed($obj->{$key});
90 }
91 }
92  
93 16 return $obj;
94 }
95  
96 73 1;
« ODS/Table/Row.pm ↑ Summary ODS/Table/Column/Base.pm »