blib/lib/Dist/Zilla/Plugin/Prereqs/FromCPANfile.pm

filter: Statementstmt 97.5% 40 / 41 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 2 totaltotal 86.8% 53 / 61 CC 8 SCAR 9.6
CC
8
Cov
90%
metadata
4.1
register_prereqs
4.0
_build_cpanfile
2.1
CRAP 2.6
↑ Summary
1 package Dist::Zilla::Plugin::Prereqs::FromCPANfile;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 our $VERSION = '0.08';
5  
6 1 ▶use Module::CPANfile;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 with 'Dist::Zilla::Role::PrereqSource', 'Dist::Zilla::Role::MetaProvider';
10  
11 1 has cpanfile => (is => 'ro', lazy => 1, builder => '_build_cpanfile');
12  
13 1 ▶sub _build_cpanfile {
Subroutine _build_cpanfile: called CC=2 SCAR=7.2
14 1 my $self = shift;
15  
16 1 ▶ return unless -e 'cpanfile';
Branch: 1 branch
BranchTrueFalseTotal
unless -e "cpanfile" 0 1 1
17  
18 1 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
19 1 $self->log("Parsing 'cpanfile' to extract prereqs");
20 1 Module::CPANfile->load;
21 0 ▶ } catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 0 $self->log_fatal($_);
23 1 };
24 }
25  
26 1 ▶sub register_prereqs {
Subroutine register_prereqs: called CC=4 SCAR=13.9
Pod undocumented
27 1 my $self = shift;
28  
29 1 ▶ my $cpanfile = $self->cpanfile or return;
Branch: 1 branch
BranchTrueFalseTotal
my $cpanfile = $self->cpanfile or return 1 0 1
30  
31 1 my $prereqs = $cpanfile->prereq_specs;
32 1 for my $phase (keys %$prereqs) {
33 2 for my $type (keys %{$prereqs->{$phase}}) {
34 $self->zilla->register_prereqs(
35 { type => $type, phase => $phase },
36 3 %{$prereqs->{$phase}{$type}},
37 );
38 }
39 }
40 }
41  
42 1 ▶sub metadata {
Subroutine metadata: called CC=4 SCAR=14.1
Pod undocumented
43 1 my $self = shift;
44  
45 1 ▶ my $cpanfile = $self->cpanfile or return {};
Branch: 1 branch
BranchTrueFalseTotal
my $cpanfile = $self->cpanfile or return {} 1 0 1
46 1 ▶ my @features = $cpanfile->features or return {};
Branch: 1 branch
BranchTrueFalseTotal
my(@features) = $cpanfile->features or return {} 1 0 1
47  
48 1 my $features = {};
49  
50 1 for my $feature (@features) {
51 2 $features->{$feature->identifier} = {
52 description => $feature->description,
53 prereqs => $feature->prereqs->as_string_hash,
54 }
55 }
56  
57 1 return { optional_features => $features };
58 }
59  
60 1 __PACKAGE__->meta->make_immutable;
61 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
62  
63 1 1;
64 __END__
↑ Summary