lib/Mite/Compiled.pm

filter: Statementstmt 93.7% 45 / 48 Branchbran 50.0% 3 / 6 Conditioncond 55.5% 5 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 3 totaltotal 77.7% 63 / 81 CC 8 SCAR 13.6
CC
8
Cov
84%
compile
7.7
write
2.2
BEGIN
1.0
CRAP 3.9
« lib/Mite/Shim.pm ↑ Summary lib/Mite/Trait/HasRequiredMethods.pm »
1 115 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 115 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 115 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Mite::Compiled;
6 115 ▶use Mite::Miteception -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 115 our $AUTHORITY = 'cpan:TOBYINK';
9 115 our $VERSION = '0.013000';
10  
11 115 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # Don't load Mite::Source else it will go circular
14  
15 has file =>
16 is => rw,
17 isa => Path,
18 coerce => true,
19 lazy => true,
20 94 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
21 94 my $self = shift;
22 94 return $self->_source_file2compiled_file( $self->source->file );
23 115 };
24  
25 115 has source =>
26 is => ro,
27 isa => MiteSource,
28 # avoid a circular dep with Mite::Source
29 weak_ref => true,
30 required => true,
31 handles => [ qw( classes class_order ) ];
32  
33 93 ▶sub compile {
Subroutine compile: called CC=7 SCAR=20.4
Pod undocumented
34 93 my $self = shift;
35  
36 93 my $code;
37 93 for my $class_name ( @{ $self->class_order } ) {
38 127 my $class = $self->classes->{$class_name};
39  
40 # Only supported by Type::Tiny 1.013_001 but no harm
41 # in doing this anyway.
42 local $Type::Tiny::SafePackage = sprintf 'package %s;',
43 127 eval { $self->source->project->config->data->{shim} }
44 127 ▶ // do { $class_name . '::__SAFE_NAMESPACE__' };
Condition66%2/3
eval { do { $self->source->project->config->data->{"shim"} } } // do { $class_name . '::__SAFE_NAMESPACE__' }
l!l&&r!l&&!r
81190
MC/DC0%0/2
eval { do { $self->source->project->config->data->{"shim"} } } // do { $class_name . '::__SAFE_NAMESPACE__' }
eval { do { $self->source->project->config->data->{"shim"} } } do { $class_name . '::__SAFE_NAMESPACE__' }
Truth table66%2/3
A // B
A= eval { do { $self->source->project->config->data->{"shim"} } }B= do { $class_name . '::__SAFE_NAMESPACE__' }
ABresult
1X1
011
000
45  
46 127 $code .= $class->compile;
47 }
48  
49 93 my $tidied;
50 93 ▶ eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { my $flag; if ($self->source->project->config->should_tidy) { $flag = Perl::Tidy::perltidy("source", \$code, "destination", \$tidied, "argv", scalar []); } ; not $flag } } and defined $tidied and length $tidied and $code = $tidied 0 93 93
Condition50%3/6
eval { do { my $flag; if ($self->source->project->config->should_tidy) { $flag = Perl::Tidy::perltidy("source", \$code, "destination", \$tidied, "argv", scalar []); } ; not $flag } } and defined $tidied and length $tidied
!ll&&!rl&&r
9300
eval { do { my $flag; if ($self->source->project->config->should_tidy) { $flag = Perl::Tidy::perltidy("source", \$code, "destination", \$tidied, "argv", scalar []); } ; not $flag } } and defined $tidied
!ll&&!rl&&r
8580
MC/DC0%0/3
eval { do { my $flag; if ($self->source->project->config->should_tidy) { $flag = Perl::Tidy::perltidy("source", \$code, "destination", \$tidied, "argv", scalar []); } ; not $flag } } and defined $tidied and length $tidied
eval { do { my $flag; if ($self->source->project->config->should_tidy) { $flag = Perl::Tidy::perltidy("source", \$code, "destination", \$tidied, "argv", scalar []); } ; not $flag } } defined $tidied length $tidied
Truth table50%2/4
A and B and C
A= eval { do { my $flag; if ($self->source->project->config->should_tidy) { $flag = Perl::Tidy::perltidy("source", \$code, "destination", \$tidied, "argv", scalar []); } ; not $flag } }B= defined $tidiedC= length $tidied
ABCresult
0XX0
10X0
1100
1111
51 93 my $flag;
52 93 ▶ if ( $self->source->project->config->should_tidy ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->source->project->config->should_tidy) 0 8 8
53 0 $flag = Perl::Tidy::perltidy(
54 source => \$code,
55 destination => \$tidied,
56 argv => [],
57 );
58 }
59 8 !$flag;
60 } and defined($tidied) and length($tidied) and ($code = $tidied);
61  
62 93 return $code;
63 }
64  
65 93 ▶sub write {
Subroutine write: called CC=2 SCAR=7.9
Pod undocumented
66 93 my ( $self, %opts ) = @_;
67  
68 93 my $code = $self->compile;
69 93 ▶ if ( defined $opts{module_fakeout_namespace} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"module_fakeout_namespace"}) 0 93 93
70 0 my $ns = $opts{module_fakeout_namespace};
71 0 $code =~ s/$ns\:://g;
72 }
73  
74 93 return $self->file->spew_utf8($code);
75 }
76  
77 1 ▶sub remove {
Subroutine remove: called CC=1 SCAR=0.0
Pod undocumented
78 1 my $self = shift;
79  
80 1 return $self->file->remove;
81 }
82  
83 115 signature_for _source_file2compiled_file => (
84 pos => [ Defined ],
85 );
86  
87 94 ▶sub _source_file2compiled_file {
Subroutine _source_file2compiled_file: called CC=1 SCAR=0.0
88 94 my ( $self, $source_file ) = @_;
89  
90 # Changes here must be coordinated with Mite.pm
91 94 return $source_file . '.mite.pm';
92 }
93  
94 115 1;
« lib/Mite/Shim.pm ↑ Summary lib/Mite/Trait/HasRequiredMethods.pm »