| 1 | 1 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Dist::Zilla::App::Command::lsplugins; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | our $VERSION = '0.003001'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Show all dzil plugins on your system, with descriptions | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Dist::Zilla::App '-command'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub _inc_scanner { ## no critic (RequireArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
_inc_scanner: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | return $_[0]->{_inc_scanner} if exists $_[0]->{_inc_scanner}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | 0 | return ( $_[0]->{_inc_scanner} = $_[0]->_build__inc_scanner ); | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub _plugin_dirs { ## no critic (RequireArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
_plugin_dirs: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | return $_[0]->{_plugin_dirs} if exists $_[0]->{_plugin_dirs}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | return ( $_[0]->{_plugin_dirs} = $_[0]->_build__plugin_dirs ); | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub _build__inc_scanner { | ||||||||||||||||||||||||||
|
Subroutine
_build__inc_scanner: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 26 | 0 | require Path::ScanINC; | |||||||||||||||||||||||||||
| 27 | 0 | return Path::ScanINC->new(); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub _build__plugin_dirs { | ||||||||||||||||||||||||||
|
Subroutine
_build__plugin_dirs: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 31 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 32 | 0 | return [ $self->_inc_scanner->all_dirs( 'Dist', 'Zilla', 'Plugin' ) ]; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub _plugin_dir_iterator { | ||||||||||||||||||||||||||
|
Subroutine
_plugin_dir_iterator: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 36 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 37 | 0 | my @dirs = @{ $self->_plugin_dirs }; | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | return unless @dirs; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | return shift @dirs; | |||||||||||||||||||||||||||
| 41 | 0 | }; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub _plugin_all_files_iterator { | ||||||||||||||||||||||||||
|
Subroutine
_plugin_all_files_iterator: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 45 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 46 | 0 | my $dir_iterator = $self->_plugin_dir_iterator; | |||||||||||||||||||||||||||
| 47 | 0 | my $dir; | |||||||||||||||||||||||||||
| 48 | my $file_iterator; | ||||||||||||||||||||||||||||
| 49 | 0 | my $code; | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | $code = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ( not defined $dir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ( not defined( $dir = $dir_iterator->() ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | return; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 0 | require Path::Tiny; | |||||||||||||||||||||||||||
| 56 | 0 | $file_iterator = Path::Tiny->new($dir)->iterator( | |||||||||||||||||||||||||||
| 57 | { | ||||||||||||||||||||||||||||
| 58 | recurse => 1, | ||||||||||||||||||||||||||||
| 59 | follow_symlinks => 0, | ||||||||||||||||||||||||||||
| 60 | }, | ||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | 0 | my $file = $file_iterator->(); | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ( not defined $file and defined $dir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $file and defined $dir
MC/DC0%0/2
not defined $file and defined $dir
not defined $file
defined $dir
Truth table0%0/3
not(A) and B
A= not defined $fileB= defined $dir
| |||||||||||||||||||||||||||||
| 65 | 0 | $dir = undef; | |||||||||||||||||||||||||||
| 66 | 0 | goto $code; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 0 | return [ $dir, $file ]; | |||||||||||||||||||||||||||
| 69 | 0 | }; | |||||||||||||||||||||||||||
| 70 | 0 | return $code; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub _plugin_iterator { | ||||||||||||||||||||||||||
|
Subroutine
_plugin_iterator: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 74 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | my $file_iterator = $self->_plugin_all_files_iterator; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my $is_plugin = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 79 | 0 | my ($file) = @_; | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | return unless $file =~ /[.]pm\z/msx; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | return if -d $file; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | return 1; | |||||||||||||||||||||||||||
| 83 | 0 | }; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | my $code; | |||||||||||||||||||||||||||
| 86 | my $end; | ||||||||||||||||||||||||||||
| 87 | 0 | ▶ | $code = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | return if $end; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | my $file = $file_iterator->(); | |||||||||||||||||||||||||||
| 90 | 0 | ▶ | if ( not defined $file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 0 | $end = 1; | |||||||||||||||||||||||||||
| 92 | 0 | return; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ( $is_plugin->( $file->[1] ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 0 | require Dist::Zilla::lsplugins::Module; | |||||||||||||||||||||||||||
| 96 | 0 | return Dist::Zilla::lsplugins::Module->new( | |||||||||||||||||||||||||||
| 97 | file => $file->[1], | ||||||||||||||||||||||||||||
| 98 | plugin_root => $file->[0], | ||||||||||||||||||||||||||||
| 99 | plugin_basename => 'Dist::Zilla::Plugin', | ||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | 0 | goto $code; | |||||||||||||||||||||||||||
| 103 | 0 | }; | |||||||||||||||||||||||||||
| 104 | 0 | return $code; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 0 | ▶ | sub opt_spec { | ||||||||||||||||||||||||||
|
Subroutine
opt_spec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 160 | return ( | ||||||||||||||||||||||||||||
| 161 | 0 | [ q[sort!], q[Sort by module name] ], | |||||||||||||||||||||||||||
| 162 | [ q[versions!], q[Show versions] ], | ||||||||||||||||||||||||||||
| 163 | [ q[abstract!], q[Show Abstracts] ], | ||||||||||||||||||||||||||||
| 164 | [ q[roles=s], q[Show applied roles] ], | ||||||||||||||||||||||||||||
| 165 | [ q[with=s], q[Filter plugins to ones that 'do' the specified role] ] | ||||||||||||||||||||||||||||
| 166 | ); | ||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | sub _filter_dzil { | ||||||||||||||||||||||||||
|
Subroutine
_filter_dzil: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 170 | 0 | my ($value) = @_; | |||||||||||||||||||||||||||
| 171 | 0 | return ( $value =~ /(\A|[|])Dist::Zilla::Role::/msx ); | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub _shorten_dzil { | ||||||||||||||||||||||||||
|
Subroutine
_shorten_dzil: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 175 | 0 | my ($value) = @_; | |||||||||||||||||||||||||||
| 176 | 0 | $value =~ s/(\A|[|])Dist::Zilla::Role::/$1-/msxg; | |||||||||||||||||||||||||||
| 177 | 0 | return $value; | |||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub _process_plugin { | ||||||||||||||||||||||||||
|
Subroutine
_process_plugin: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||
| 181 | 0 | my ( undef, $plugin, $opt, undef ) = @_; | |||||||||||||||||||||||||||
| 182 | 0 | ▶ | if ( defined $opt->with ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 0 | ▶ | return unless $plugin->loaded_module_does( $opt->with ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | 0 | printf q[%s], $plugin->plugin_name; | |||||||||||||||||||||||||||
| 186 | 0 | ▶ | if ( $opt->versions ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | 0 | printf q[ (%s)], $plugin->version; | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if ( $opt->abstract ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 0 | ▶ | printf q[ - %s], $plugin->abstract || ' NO ABSTRACT DEFINED'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$plugin->abstract || ' NO ABSTRACT DEFINED'
MC/DC0%0/1
$plugin->abstract || ' NO ABSTRACT DEFINED'
$plugin->abstract
Truth table0%0/2
A
A= $plugin->abstract
| |||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ( defined $opt->roles ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if ( 'all' eq $opt->roles ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 194 | 0 | printf q{ [%s]}, join q[, ], @{ $plugin->roles }; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | elsif ( 'dzil-full' eq $opt->roles ) { | ||||||||||||||||||||||||||||
| 197 | 0 | printf q{ [%s]}, join q[, ], grep { _filter_dzil($_) } @{ $plugin->roles }; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | elsif ( 'dzil' eq $opt->roles ) { | ||||||||||||||||||||||||||||
| 200 | 0 | printf q{ [%s]}, join q[, ], map { _shorten_dzil($_) } grep { _filter_dzil($_) } @{ $plugin->roles }; | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | 0 | printf "\n"; | |||||||||||||||||||||||||||
| 204 | 0 | return; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | ▶ | sub execute { | ||||||||||||||||||||||||||
|
Subroutine
execute: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 216 | 0 | my ( $self, $opt, $args ) = @_; | |||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if ( !$opt->sort ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 0 | my $plugin_iterator = $self->_plugin_iterator; | |||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 0 | ▶ | while ( my $plugin = $plugin_iterator->() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | 0 | $self->_process_plugin( $plugin, $opt, $args ); | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | 0 | return 0; | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 0 | my $plugin_iterator = $self->_plugin_iterator; | |||||||||||||||||||||||||||
| 228 | 0 | my @plugins; | |||||||||||||||||||||||||||
| 229 | 0 | ▶ | while ( my $plugin = $plugin_iterator->() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | 0 | push @plugins, $plugin; | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | 0 | for my $plugin ( sort { $a->plugin_name cmp $b->plugin_name } @plugins ) { | |||||||||||||||||||||||||||
| 233 | 0 | $self->_process_plugin( $plugin, $opt, $args ); | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | 0 | return 0; | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 1 | 1; | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | __END__ | ||||||||||||||||||||||||||||