blib/lib/ExtUtils/Builder/Action/Function.pm

filter: Statementstmt 90.0% 54 / 60 Branchbran 71.4% 10 / 14 Conditioncond 53.3% 8 / 15 MC/DCmcdc 12.5% 1 / 8 Subroutinesub 78.5% 11 / 14 Podpod 87.5% 7 / 8 totaltotal 76.4% 91 / 119 CC 14 SCAR 12.7
CC
14
Cov
81%
to_code
6.1
new
5.4
to_command
3.3
CRAP 3.5
« blib/lib/ExtUtils/Builder/Planner.pm ↑ Summary blib/lib/ExtUtils/Builder/Node.pm »
1 package ExtUtils::Builder::Action::Function;
2 2 $ExtUtils::Builder::Action::Function::VERSION = '0.020';
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  
6 2 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use ExtUtils::Builder::Util 'get_perl';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use parent 'ExtUtils::Builder::Action::Perl';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶sub new {
Subroutine new: called CC=5 SCAR=16.8
Pod undocumented
12 1 my ($class, %args) = @_;
13 1 ▶ croak 'Attribute module is not defined' if not defined $args{module};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"module"} 0 1 1
14 1 ▶ croak 'Attribute function is not defined' if not defined $args{function};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"function"} 0 1 1
15 1 $args{fullname} = join '::', $args{module}, $args{function};
16 1 ▶ $args{exports} ||= !!0;
Condition50%1/2
$args{"exports"} ||=
l!l
10
MC/DC0%0/1
$args{"exports"} ||=
$args{"exports"}
Truth table50%1/2
A
A= $args{"exports"}
Aresult
11
00
17 1 ▶ $args{arguments} //= [];
Condition50%1/2
$args{"arguments"} //= []
l!l
10
MC/DC0%0/1
$args{"arguments"} //= []
$args{"arguments"}
Truth table50%1/2
A
A= $args{"arguments"}
Aresult
11
00
18 1 my $self = $class->SUPER::new(%args);
19 1 return $self;
20 }
21  
22 0 ▶sub modules {
Subroutine modules: not called CC=1 SCAR=6.9
Pod documented
23 0 my ($self) = @_;
24 0 return $self->{module};
25 }
26  
27 0 ▶sub module {
Subroutine module: not called CC=1 SCAR=6.9
Pod documented
28 0 my ($self) = @_;
29 0 return $self->{module};
30 }
31  
32 0 ▶sub function {
Subroutine function: not called CC=1 SCAR=6.9
Pod documented
33 0 my ($self) = @_;
34 0 return $self->{function};
35 }
36  
37 6 ▶sub arguments {
Subroutine arguments: called CC=1 SCAR=0.0
Pod documented
38 6 my ($self) = @_;
39 6 return @{ $self->{arguments} };
40 }
41  
42 2 ▶sub execute {
Subroutine execute: called CC=3 SCAR=11.0
Pod documented
43 2 my ($self, %args) = @_;
44 2 my $module = $self->{module};
45 2 (my $filename = $module) =~ s{::}{/}g;
46 2 require "$filename.pm";
47  
48 2 ▶ if (!$args{quiet}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{"quiet"}) 1 1 2
49 1 ▶ my $message = $self->{message} // sprintf "%s(%s)", $self->{fullname}, join ", ", $self->arguments;
Condition50%1/2
$self->{"message"} // sprintf('%s(%s)', $self->{"fullname"}, join(", ", $self->arguments))
l!l
10
MC/DC0%0/1
$self->{"message"} // sprintf('%s(%s)', $self->{"fullname"}, join(", ", $self->arguments))
$self->{"message"}
Truth table50%1/2
A
A= $self->{"message"}
Aresult
11
00
50 1 print "$message\n";
51 }
52  
53 2 ▶ my $code = do { no strict 'refs'; \&{ $self->{fullname} } };
Subroutine BEGIN: called CC=1 SCAR=0.0
54 2 $code->($self->arguments);
55 }
56  
57 2 ▶sub to_code {
Subroutine to_code: called CC=6 SCAR=18.1
Pod documented
58 2 my ($self, %args) = @_;
59 2 ▶ my $shortcut = $args{skip_loading} && $args{skip_loading} eq 'main' && $self->{exports};
Condition66%4/6
$args{'skip_loading'} && $args{'skip_loading'} eq 'main' && $self->{'exports'}
!ll&&!rl&&r
101
$args{"skip_loading"} and $args{"skip_loading"} eq "main"
!ll&&!rl&&r
101
MC/DC33%1/3
$args{'skip_loading'} && $args{'skip_loading'} eq 'main' && $self->{'exports'}
$args{"skip_loading"} $args{"skip_loading"} eq "main" $self->{'exports'}
Truth table50%2/4
A and B && C
A= $args{"skip_loading"}B= $args{"skip_loading"} eq "main"C= $self->{'exports'}
ABCresult
0XX0
10X0
1100
1111
60 2 ▶ my $name = $shortcut ? $self->{function} : $self->{fullname};
Branch: 1 branch
BranchTrueFalseTotal
$shortcut ? : 1 1 2
61 2 ▶ my @modules = $args{skip_loading} ? () : "require $self->{module}";
Branch: 1 branch
BranchTrueFalseTotal
$args{'skip_loading'} ? : 1 1 2
62 2 ▶ my $arguments = $self->arguments ? do {
Branch: 1 branch
BranchTrueFalseTotal
$self->arguments ? : 2 0 2
63 2 require Data::Dumper; (Data::Dumper->new([ [ $self->arguments ] ])->Terse(1)->Indent(0)->Dump =~ /^ \[ (.*) \] $/x)[0]
64 } : '';
65 2 return join '; ', @modules, sprintf '%s(%s)', $name, $arguments;
66 }
67  
68 1 ▶sub to_command {
Subroutine to_command: called CC=3 SCAR=12.0
Pod documented
69 1 my ($self, %opts) = @_;
70 1 ▶ my $module = $self->{exports} eq 'explicit' ? "-M$self->{module}=$self->{function}" : "-M$self->{module}";
Branch: 1 branch
BranchTrueFalseTotal
$self->{'exports'} eq 'explicit' ? : 0 1 1
71 1 ▶ my $perl = $opts{perl} // get_perl(%opts);
Condition33%1/3
$opts{"perl"} // get_perl(%opts)
l!l&&r!l&&!r
010
MC/DC0%0/2
$opts{"perl"} // get_perl(%opts)
$opts{"perl"} get_perl(%opts)
Truth table33%1/3
A // B
A= $opts{"perl"}B= get_perl(%opts)
ABresult
1X1
011
000
72 1 return [ $perl, $module, '-e', $self->to_code(skip_loading => 'main') ];
73 }
74  
75 2 1;
76  
77 #ABSTRACT: Actions for perl function calls
78  
79 __END__
« blib/lib/ExtUtils/Builder/Planner.pm ↑ Summary blib/lib/ExtUtils/Builder/Node.pm »