CPAN/Maker/Bootstrapper/Role/DistFile.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 67 CC 7 SCAR 33.0
CC
7
Cov
0%
cmd_dist_file
56.0
BEGIN
2.0
BEGIN
2.0
CRAP 27.2
1 package CPAN::Maker::Bootstrapper::Role::DistFile;
2  
3 use strict;
4 use warnings;
5  
6 use CLI::Simple::Constants qw(:booleans);
7 use CLI::Simple::Utils qw(slurp);
8 use Data::Dumper;
9 use English qw(-no_match_vars);
10 use File::ShareDir qw(dist_dir);
11  
12 use Role::Tiny;
13  
14 ########################################################################
15 sub cmd_dist_file {
16 ########################################################################
17 my ($self) = @_;
18  
19 my ( $distribution, $file ) = $self->get_args;
20  
21 if ( !$file ) {
22 $file = $distribution;
23 $distribution = 'CPAN-Maker-Bootstrapper';
24 }
25  
26 die "usage: dist-file [--path-only] distribution file\n"
27 if !$file;
28  
29 my ( $path, $content ) = eval {
30 my $dist_dir = dist_dir($distribution);
31  
32 my ($path) = grep { -e $_ } ( "$dist_dir/$file", "$dist_dir/share/$file" );
33  
34 die "$file not found in $distribution\n"
35 if !$path;
36  
37 return ( $path, !$self->get_path_only ? slurp($path) : q{} );
38 };
39  
40 die "ERROR: could not fetch $file from $distribution\n$EVAL_ERROR"
41 if !$path || $EVAL_ERROR;
42  
43 print {*STDOUT} $self->get_path_only ? $path : $content;
44  
45 return $SUCCESS;
46 }
47  
48 1;