| 1 | package CPAN::Maker::Bootstrapper::Role::CreateDeps; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use CLI::Simple::Constants qw(:booleans); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use CLI::Simple::Utils qw(slurp); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use File::Find; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use List::Util qw(none); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Role::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | ######################################################################## | ||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub find_modules { | ||||||||||||||||||||||||||
|
Subroutine
find_modules: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | ######################################################################## | ||||||||||||||||||||||||||||
| 16 | 0 | my ($self); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | my @modules; | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | find( | ||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | return if !/[.]p[ml][.]in$/xsm; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | return if /^[.]?[#]/xsm; # ignore temp files | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | push @modules, $File::Find::name; | |||||||||||||||||||||||||||
| 26 | }, | ||||||||||||||||||||||||||||
| 27 | 0 | q{.} | |||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | return @modules; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | ######################################################################## | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub find_package_name { | ||||||||||||||||||||||||||
|
Subroutine
find_package_name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | ######################################################################## | ||||||||||||||||||||||||||||
| 36 | 0 | my ( $self, $path ) = @_; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | my $module = slurp($path); | |||||||||||||||||||||||||||
| 39 | 0 | my @package_names; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | while ( $module =~ /^package\s+([^;]+);/gxsm ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | push @package_names, $1; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | return [ $path, \@package_names ]; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | ######################################################################## | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub find_deps { | ||||||||||||||||||||||||||
|
Subroutine
find_deps: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 50 | ######################################################################## | ||||||||||||||||||||||||||||
| 51 | 0 | my ( $self, $modules ) = @_; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | my %requires; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | require Module::ScanDeps::Static; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | foreach my $m ( @{$modules} ) { | |||||||||||||||||||||||||||
| 58 | 0 | my $scanner = Module::ScanDeps::Static->new( { path => $m } ); | |||||||||||||||||||||||||||
| 59 | 0 | $scanner->parse; | |||||||||||||||||||||||||||
| 60 | 0 | $requires{$m} = [ keys %{ $scanner->get_require } ]; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | return \%requires; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | ######################################################################## | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub cmd_create_deps { | ||||||||||||||||||||||||||
|
Subroutine
cmd_create_deps: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 68 | ######################################################################## | ||||||||||||||||||||||||||||
| 69 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | my @output_modules = $self->get_args; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | my @modules = $self->find_modules(); | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | my @internal_packages; | |||||||||||||||||||||||||||
| 76 | my %lookup; | ||||||||||||||||||||||||||||
| 77 | 0 | my $fh = \*STDOUT; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | foreach my $m (@modules) { | |||||||||||||||||||||||||||
| 80 | 0 | my @p = @{ $self->find_package_name($m) }; | |||||||||||||||||||||||||||
| 81 | 0 | push @internal_packages, @{ $p[1] }; | |||||||||||||||||||||||||||
| 82 | 0 | $lookup{$_} = $m for @{ $p[1] }; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | my $packages = $self->find_deps( \@modules ); | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | foreach my $p ( sort keys %{$packages} ) { | |||||||||||||||||||||||||||
| 88 | 0 | ▶ | next if @output_modules && none { $p eq "./$_" } @output_modules; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
Condition0%0/3
@output_modules and &none(sub {
MC/DC0%0/2
@output_modules and &none(sub {
$p eq "./$_";
}
, @output_modules)
@output_modules
&none(sub {
$p eq "./$_";
}
, @output_modules)
Truth table0%0/3
A and B
A= @output_modulesB= &none(sub {
$p eq "./$_";
}
, @output_modules)
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | my $generated_p = $p; | |||||||||||||||||||||||||||
| 91 | 0 | $generated_p =~ s/[.](p[ml])[.]in/.$1/xsm; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | my @deps; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | foreach my $m ( sort @{ $packages->{$p} } ) { | |||||||||||||||||||||||||||
| 96 | 0 | ▶ | next if none { $m eq $_ } @internal_packages; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | next if $p eq $lookup{$m}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | push @deps, $lookup{$m}; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if (@deps) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | print {$fh} sprintf "# %s\n%s: \\\n", $p, $generated_p; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | foreach ( sort @deps ) { | |||||||||||||||||||||||||||
| 106 | 0 | s/\.in$//; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | 0 | print {$fh} sprintf " %s\n\n", join " \\\n ", @deps; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 0 | return $SUCCESS; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 2 | 1; | |||||||||||||||||||||||||||