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

filter: Statementstmt 100% 49 / 49 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 1 totaltotal 92.6% 63 / 68 CC 4 SCAR 4.6
CC
4
Cov
95%
__ANON__
3.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.6
↑ Summary
1 5 ▶use 5.006; # our
Subroutine BEGIN: called CC=1 SCAR=0.0
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Dist::Zilla::Plugin::lib;
6  
7 5 our $VERSION = '0.001002';
8  
9 # ABSTRACT: A simpler bootstrap for a more civilised world
10  
11 5 our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12  
13 5 ▶use Moose qw( with around has );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use MooseX::Types::Moose qw( ArrayRef Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use Path::Tiny qw( path );
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use lib qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 5 with 'Dist::Zilla::Role::Plugin';
19  
20  
21  
22  
23  
24  
25 4 ▶sub mvp_multivalue_args { return qw( lib ) }
Subroutine mvp_multivalue_args: called CC=1 SCAR=0.0
Pod undocumented
26  
27 5 has 'lib' => (
28 is => 'ro',
29 isa => ArrayRef [Str],
30 required => 1,
31 );
32  
33 4 ▶around dump_config => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
34 4 my ( $orig, $self, @args ) = @_;
35 4 my $config = $self->$orig(@args);
36 4 my $localconf = $config->{ +__PACKAGE__ } = {};
37  
38 4 $localconf->{lib} = $self->lib;
39  
40 4 ▶ $localconf->{ q[$] . __PACKAGE__ . '::VERSION' } = $VERSION
Branch: 1 branch
BranchTrueFalseTotal
unless __PACKAGE__ eq ref $self 0 4 4
41 unless __PACKAGE__ eq ref $self;
42  
43 4 return $config;
44 5 };
45  
46 # Injecting at init time
47 4 ▶around plugin_from_config => sub {
Subroutine __ANON__: called CC=3 SCAR=11.1
48 4 my ( $orig, $plugin_class, $name, $payload, $section ) = @_;
49 4 my $instance = $plugin_class->$orig( $name, $payload, $section );
50 4 my $root = path( $instance->zilla->root )->absolute; # https://github.com/rjbs/Dist-Zilla/issues/579
51 4 $instance->log_debug("zilla root: $root");
52  
53 lib->import(
54 5 map { "$_" }
55 5 ▶ grep { $_->is_dir ? 1 : ( $instance->log("library path \"$_\" does not exist or is not a directory"), undef ) }
Branch: 1 branch
BranchTrueFalseTotal
$_->is_dir ? : 5 0 5
56 4 ▶ map { path($_)->absolute($root) } @{ $instance->lib || [] },
Condition50%1/2
$instance->lib || []
l!l
40
MC/DC0%0/1
$instance->lib || []
$instance->lib
Truth table50%1/2
A
A= $instance->lib
Aresult
11
00
57 );
58 4 $instance->log_debug("\@INC is [@INC]");
59 4 return $instance;
60 5 };
61  
62 5 __PACKAGE__->meta->make_immutable;
63 5 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
64  
65 5 1;
66  
67 __END__
↑ Summary