blib/lib/CPAN/Plugin.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 74 CC 5 SCAR 19.5
CC
5
Cov
0%
new
20.0
is_xs
6.0
plugin_requires
2.0
CRAP 7.0
1 package CPAN::Plugin;
2  
3 use strict;
4 use warnings;
5  
6 our $VERSION = '0.97';
7  
8 require CPAN;
9  
10 ######################################################################
11  
12 sub new { # ;
13 my ($class, %params) = @_;
14  
15 my $self = +{
16 (ref $class ? (%$class) : ()),
17 %params,
18 };
19  
20 $self = bless $self, ref $class ? ref $class : $class;
21  
22 unless (ref $class) {
23 local $_;
24 no warnings 'once';
25 $CPAN::META->use_inst ($_) for $self->plugin_requires;
26 }
27  
28 $self;
29 }
30  
31 ######################################################################
32 sub plugin_requires { # ;
33 }
34  
35 ######################################################################
36 sub distribution_object { # ;
37 my ($self) = @_;
38 $self->{distribution_object};
39 }
40  
41 ######################################################################
42 sub distribution { # ;
43 my ($self) = @_;
44  
45 my $distribution = $self->distribution_object->id;
46 CPAN::Shell->expand("Distribution",$distribution)
47 or $self->frontend->mydie("Unknowns distribution '$distribution'\n");
48 }
49  
50 ######################################################################
51 sub distribution_info { # ;
52 my ($self) = @_;
53  
54 CPAN::DistnameInfo->new ($self->distribution->id);
55 }
56  
57 ######################################################################
58 sub build_dir { # ;
59 my ($self) = @_;
60  
61 my $build_dir = $self->distribution->{build_dir}
62 or $self->frontend->mydie("Distribution has not been built yet, cannot proceed");
63 }
64  
65 ######################################################################
66 sub is_xs { #
67 my ($self) = @_;
68  
69 my @xs = glob File::Spec->catfile ($self->build_dir, '*.xs'); # quick try
70  
71 unless (@xs) {
72 require ExtUtils::Manifest;
73 my $manifest_file = File::Spec->catfile ($self->build_dir, "MANIFEST");
74 my $manifest = ExtUtils::Manifest::maniread($manifest_file);
75 @xs = grep /\.xs$/, keys %$manifest;
76 }
77  
78 scalar @xs;
79 }
80  
81 ######################################################################
82  
83 package CPAN::Plugin;
84  
85 1;
86  
87 __END__