| 1 | package Perl::Analysis::Static::ModuleLister; | ||||||||||
| 2 | { | ||||||||||
| 3 | 1 | $Perl::Analysis::Static::ModuleLister::VERSION = '0.004'; # TRIAL | |||||||||
| 4 | } | ||||||||||
| 5 | # ABSTRACT: list all module below a namespace | ||||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Module::List qw(list_modules); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | 1 | has 'kind' => ( is => 'rw', isa => 'Str' ); | |||||||||
| 14 | |||||||||||
| 15 | |||||||||||
| 16 | 2 | ▶ | sub list { | ||||||||
|
Subroutine
list: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 17 | 2 | my ($self) = @_; | |||||||||
| 18 | |||||||||||
| 19 | # build the module stem for that kind of modules | ||||||||||
| 20 | 2 | my $stem = 'Perl::Analysis::Static::' . $self->kind . '::'; | |||||||||
| 21 | 2 | my $modules = list_modules( $stem, { list_modules => 1, recurse => 1 } ); | |||||||||
| 22 | |||||||||||
| 23 | # if the hash is empty we found nothing | ||||||||||
| 24 | 2 | ▶ | return unless keys %$modules; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | |||||||||||
| 26 | # remove the stem so the name is readable | ||||||||||
| 27 | 1 | my @result; | |||||||||
| 28 | 1 | for my $module (keys %$modules) { | |||||||||
| 29 | 8 | $module =~ s{$stem}{}; | |||||||||
| 30 | 8 | push @result, $module; | |||||||||
| 31 | } | ||||||||||
| 32 | 1 | return \@result; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | |||||||||||
| 36 | 1 | 1; | |||||||||
| 37 | |||||||||||
| 38 | __END__ | ||||||||||