blib/lib/Alien/Build/Plugin/Prefer/BadVersion.pm

filter: Statementstmt 97.6% 42 / 43 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 1 / 1 totaltotal 95.2% 60 / 63 CC 5 SCAR 6.6
CC
5
Cov
94%
init
4.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.9
« blib/lib/Alien/Build/Plugin/Core/CleanInstall.pm ↑ Summary blib/lib/Alien/Build/Plugin/Prefer/GoodVersion.pm »
1 package Alien::Build::Plugin::Prefer::BadVersion;
2  
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 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Alien::Build::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Plugin to filter out known bad versions
10 2 our $VERSION = '2.88'; # VERSION
11  
12  
13 1 ▶has '+filter' => sub { Carp::croak("The filter property is required for the Prefer::BadVersion plugin") };
Subroutine __ANON__: called CC=1 SCAR=0.0
14  
15 sub init
16 4 ▶{
Subroutine init: called CC=4 SCAR=13.9
Pod documented
17 4 my($self, $meta) = @_;
18  
19 4 $meta->add_requires('configure', __PACKAGE__, '1.05');
20  
21 4 my $filter;
22  
23 4 ▶ if(ref($self->filter) eq '')
Branch: 3 branches
BranchTrueFalseTotal
if (ref $self->filter eq '') { } 2 2 4
elsif (ref $self->filter eq 'ARRAY') { } 1 1 2
elsif (ref $self->filter eq 'CODE') { } 1 0 1
24 {
25 2 my $string = $self->filter;
26 3 ▶ $filter = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
27 3 my($file) = @_;
28 3 $file->{version} ne $string;
29 2 };
30 }
31 elsif(ref($self->filter) eq 'ARRAY')
32 {
33 1 my %filter = map { $_ => 1 } @{ $self->filter };
34 3 ▶ $filter = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
35 3 my($file) = @_;
36 3 ! $filter{$file->{version}};
37 1 };
38 }
39 elsif(ref($self->filter) eq 'CODE')
40 {
41 1 my $code = $self->filter;
42 1 ▶ $filter = sub { ! $code->($_[0]) };
Subroutine __ANON__: called CC=1 SCAR=0.0
43 }
44 else
45 {
46 0 Carp::croak("unknown filter type for Prefer::BadVersion");
47 }
48  
49 $meta->around_hook(
50 3 ▶ prefer => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
51 3 my($orig, $build, @therest) = @_;
52 3 my $res1 = $orig->($build, @therest);
53 3 ▶ return $res1 unless $res1->{type} eq 'list';
Branch: 1 branch
BranchTrueFalseTotal
unless $res1->{"type"} eq "list" 0 3 3
54  
55 return {
56 type => 'list',
57 list => [
58 3 grep { $filter->($_) } @{ $res1->{list} }
59 ],
60 };
61 },
62 4 );
63 }
64  
65 2 1;
66  
67 __END__
« blib/lib/Alien/Build/Plugin/Core/CleanInstall.pm ↑ Summary blib/lib/Alien/Build/Plugin/Prefer/GoodVersion.pm »