File Coverage

blib/lib/Dist/Zilla/App/Command/listdeps_darkpan.pm
Criterion Covered Total %
statement 11 44 25.0
branch 0 6 0.0
condition n/a
subroutine 4 9 44.4
pod 3 3 100.0
total 18 62 29.0


line stmt bran cond sub pod time code
1 1     1   418 use 5.006; # our
  1         3  
2 1     1   4 use strict;
  1         1  
  1         18  
3 1     1   10 use warnings;
  1         1  
  1         72  
4              
5             package Dist::Zilla::App::Command::listdeps_darkpan;
6              
7             our $VERSION = 'v0.3.0';
8              
9             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
10              
11             # FILENAME: listdeps_darkpan.pm
12             # CREATED: 30/10/11 11:07:09 by Kent Fredric (kentnl) <kentfredric@gmail.com>
13             # ABSTRACT: List DarkPAN dependencies
14              
15 1     1   370 use Dist::Zilla::App '-command';
  1         28438  
  1         10  
16              
17              
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30              
31              
32              
33              
34              
35 0     0 1   sub abstract { return 'list your distributions prerequisites from darkpans' } ## no critic (ProhibitAmbiguousNames)
36              
37             sub opt_spec {
38 0     0 1   return [ 'missing', 'list only the missing dependencies' ],;
39             }
40              
41             sub _extract_dependencies {
42 0     0     my ( undef, $zilla, $missing ) = @_;
43 0           $_->before_build for @{ $zilla->plugins_with('-BeforeBuild') };
  0            
44 0           $_->gather_files for @{ $zilla->plugins_with('-FileGatherer') };
  0            
45 0           $_->prune_files for @{ $zilla->plugins_with('-FilePruner') };
  0            
46 0           $_->munge_files for @{ $zilla->plugins_with('-FileMunger') };
  0            
47 0           $_->register_prereqs for @{ $zilla->plugins_with('-PrereqSource') };
  0            
48 0           my @dark;
49             my $callback = sub {
50 0 0   0     shift @_ if 'HASH' eq ref $_[0];
51 0           push @dark, @_;
52 0           };
53              
54 0           $_->register_external_prereqs($callback) for @{ $zilla->plugins_with('-PrereqSource::External') };
  0            
55              
56 0 0         if ($missing) {
57 0           @dark = grep { not $_->is_satisfied } @dark;
  0            
58             }
59 0           @dark = sort { lc $a->uri cmp lc $b->uri } @dark;
  0            
60 0           return @dark;
61             }
62              
63             sub execute {
64 0     0 1   my ( $self, $opt, ) = @_;
65 0           my $logger = $self->app->chrome->logger;
66 0           $logger->mute;
67 0           for ( $self->_extract_dependencies( $self->zilla, $opt->missing, ) ) {
68 0 0         say $_->uri or do {
69 0           $logger->unmute;
70 0           $logger->log_fatal('Error writing to output');
71             };
72             }
73 0           return 1;
74             }
75             1;
76              
77             __END__
78              
79             =pod
80              
81             =encoding UTF-8
82              
83             =head1 NAME
84              
85             Dist::Zilla::App::Command::listdeps_darkpan - List DarkPAN dependencies
86              
87             =head1 VERSION
88              
89             version v0.3.0
90              
91             =head1 SYNOPSIS
92              
93             This code is mostly borged from the C<listdeps> command as a temporary measure till upstream
94             add native support.
95              
96             =begin MetaPOD::JSON v1.1.0
97              
98             {
99             "namespace":"Dist::Zilla::App::Command::listdeps_darkpan",
100             "interface":"class",
101             "inherits":"Dist::Zilla::App::Command"
102             }
103              
104              
105             =end MetaPOD::JSON
106              
107             =head1 AUTHOR
108              
109             Kent Fredric <kentnl@cpan.org>
110              
111             =head1 COPYRIGHT AND LICENSE
112              
113             This software is copyright (c) 2017 by Kent Fredric <kentnl@cpan.org>.
114              
115             This is free software; you can redistribute it and/or modify it under
116             the same terms as the Perl 5 programming language system itself.
117              
118             =cut