lib/FFI/Build/Plugin.pm

filter: Statementstmt 97.5% 39 / 40 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 85.2% 52 / 61 CC 9 SCAR 15.1
CC
9
Cov
90%
new
7.2
call
3.0
BEGIN
1.0
CRAP 4.5
« blib/lib/FFI/Platypus/Type/WideString.pm ↑ Summary lib/FFI/Temp.pm »
1 package FFI::Build::Plugin;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use File::Spec::Functions qw( catdir catfile );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # ABSTRACT: Platform and local customizations of FFI::Build
9 11 our $VERSION = '2.12'; # VERSION
10  
11  
12 sub new
13 13 ▶{
Subroutine new: called CC=7 SCAR=19.8
Pod undocumented
14 13 my($class) = @_;
15  
16 13 my %plugins;
17  
18 13 foreach my $inc (@INC)
19 {
20 # CAVEAT: won't work with an @INC hook. Plugins must be in a "real" directory.
21 98 my $path = catdir($inc, 'FFI', 'Build', 'Plugin');
22 98 ▶ next unless -d $path;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $path 96 2 98
23 2 my $dh;
24 2 opendir $dh, $path;
25 2 my @list = readdir $dh;
26 2 closedir $dh;
27  
28 2 foreach my $name (map { my $x = $_; $x =~ s/\.pm$//; $x } grep /\.pm$/, @list)
29 {
30 4 ▶ next if defined $plugins{$name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $plugins{$name} 0 4 4
31 4 my $pm = catfile('FFI', 'Build', 'Plugin', "$name.pm");
32 4 require $pm;
33 4 my $class = "FFI::Build::Plugin::$name";
34 4 ▶ if($class->can("api_version") && $class->api_version == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($class->can('api_version') and $class->api_version == 0) { } 4 0 4
Condition33%1/3
$class->can("api_version") and $class->api_version == 0
!ll&&!rl&&r
004
MC/DC0%0/2
$class->can("api_version") and $class->api_version == 0
$class->can("api_version") $class->api_version == 0
Truth table33%1/3
A and B
A= $class->can("api_version")B= $class->api_version == 0
ABresult
0X0
100
111
35 {
36 4 $plugins{$name} = $class->new;
37 }
38 else
39 {
40 0 warn "$class is not the correct api version. You may need to upgrade the plugin, platypus or uninstall the plugin";
41 }
42 }
43 }
44  
45 13 bless \%plugins, $class;
46 }
47  
48 sub call
49 256 ▶{
Subroutine call: called CC=3 SCAR=11.0
Pod undocumented
50 256 my($self, $method, @args) = @_;
51  
52 256 foreach my $name (sort keys %$self)
53 {
54 2 my $plugin = $self->{$name};
55 2 ▶ $plugin->$method(@args) if $plugin->can($method);
Branch: 1 branch
BranchTrueFalseTotal
if $plugin->can($method) 1 1 2
56 }
57  
58 256 1;
59 }
60  
61 11 1;
62  
63 __END__
« blib/lib/FFI/Platypus/Type/WideString.pm ↑ Summary lib/FFI/Temp.pm »