Submodules/Result.pm

filter: Statementstmt 79.1% 53 / 67 Branchbran 33.3% 6 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 100% 4 / 4 totaltotal 73.5% 75 / 102 CC 11 SCAR 10.2
CC
11
Cov
69%
read
6.0
require
4.1
AUTOLOAD
3.9
CRAP 2.8
« Submodules.pm ↑ Summary
1 package Submodules::Result;
2 2 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use overload (
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 fallback => 1,
8 '""' => 'SCALAR',
9 2 );
10 2 our $AUTOLOAD;
11 2 our $VERSION = '1.0015';
12 2 our @CARP_NOT = qw(Submodules);
13 2 our $default_property = 'Module';
14 138 ▶our $SCALAR = sub {
Subroutine __ANON__: called CC=3 SCAR=11.2
15 138 my $self = shift;
16 138 my @call = caller(1);
17 138 ▶ return $self if $call[0] eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $call[0] eq __PACKAGE__ 0 138 138
18 138 eval {
19 138 $self->isa('UNIVERSAL');
20 };
21 138 ▶ return $self if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 138 138
22 138 $self->{$default_property};
23 2 };
24
25 138 ▶sub SCALAR {
Subroutine SCALAR: called CC=2 SCAR=7.6
26 # Easily oerride stringification through $Submodules::SCALAR
27 138 ▶ return &$SCALAR(@_) if 'CODE' eq ref $SCALAR;
Branch: 1 branch
BranchTrueFalseTotal
if "CODE" eq ref $Submodules::Result::SCALAR 138 0 138
28 }
29
30 24 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
31 24 my $class = shift;
32 24 bless {
33 AbsPath => undef,
34 Clobber => undef,
35 Module => undef,
36 Name => undef,
37 Path => undef,
38 RelPath => undef,
39 @_,
40 }, $class;
41 }
42
43 12 ▶sub require {
Subroutine require: called CC=3 SCAR=14.2
Pod documented
44 12 my $self = shift;
45 12 my @call = caller(0);
46 12 my $r = eval {
47 12 require "$self->{Path}";
48 };
49 12 ▶ if (my $e = $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) 0 12 12
50 0 ▶ if ($e =~ /did not return a true value/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e =~ /did not return a true value/) { } 0 0 0
51 0 die $self->Path." did not return a true value at $call[1] line $call[2]\n";
52 } else {
53 0 $e =~ s/(Compilation failed in require at) .*?$/$1 $call[1] line $call[2]/g;
54 0 die $e;
55 }
56 }
57 12 $r;
58 }
59
60 6 ▶sub use {
Subroutine use: called CC=2 SCAR=7.0
Pod documented
61 6 my $self = shift;
62 6 $self->require;
63 6 ▶ if (my $import = $self->Module->can('import')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $import = $self->Module->can("import")) 6 0 6
64 6 unshift @_, $self->Module;
65 6 goto &$import;
66 }
67 }
68
69 0 ▶sub read {
Subroutine read: not called CC=2 SCAR=17.9
Pod documented
70 0 my $self = shift;
71 0 undef local $/;
72 0 ▶ open my $in, '<', $self->{AbsPath} or croak "Failed to open $self->{AbsPath} for reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $in, "<", $self->{"AbsPath"} or croak(qq[Failed to open $self->{"AbsPath"} for reading: $!]) 0 0 0
73 0 binmode $in;
74 0 my $data = <$in>;
75 0 close $in;
76 0 $data;
77 }
78
79 36 ▶sub AUTOLOAD : lvalue {
Subroutine AUTOLOAD: called CC=3 SCAR=13.6
80 36 (my $name = $AUTOLOAD) =~ s/^.+:://;
81 36 my $self = shift;
82 36 my $lvalue;
83 36 ▶ if (exists $self->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{$name}) { } 36 0 36
84 36 $lvalue = \($self->{$name});
85 } else {
86 0 eval {
87 0 $lvalue = \($self->{$default_property}->$name);
88 };
89 0 ▶ croak "Unknown method or property '$name': $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
90 }
91 36 $$lvalue;
92 }
93
94 24 ▶sub DESTROY {
Subroutine DESTROY: called CC=2 SCAR=6.9
95 24 my $self = shift;
96 24 for my $k (keys %$self) {
97 144 undef $self->{$k};
98 144 delete $self->{$k};
99 }
100 24 undef $self;
101 }
102
103 2 1;
104
105 __END__
« Submodules.pm ↑ Summary