| 1 | package Module::Install::Admin::Include; | ||||||||||||
| 2 | |||||||||||||
| 3 | 46 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 46 | ▶ | use Module::Install::Base; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 46 | ▶ | use vars qw{$VERSION @ISA}; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 46 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 46 | $VERSION = '1.21'; | |||||||||||
| 9 | 46 | @ISA = qw{Module::Install::Base}; | |||||||||||
| 10 | } | ||||||||||||
| 11 | |||||||||||||
| 12 | 1 | ▶ | sub include { | ||||||||||
|
Subroutine
include: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||
| 13 | 1 | my $self = shift; | |||||||||||
| 14 | 1 | foreach my $rv ( $self->admin->glob_in_inc($_[0]) ) { | |||||||||||
| 15 | 1 | $self->admin->copy_package(@$rv); | |||||||||||
| 16 | 1 | my @build_requires; | |||||||||||
| 17 | 1 | ▶ | foreach (@{ $self->build_requires || [] }) { | ||||||||||
|
Condition50%1/2
$self->build_requires || []
MC/DC0%0/1
$self->build_requires || []
$self->build_requires
Truth table50%1/2
A
A= $self->build_requires
| |||||||||||||
| 18 | 1 | ▶ | next if $_->[0] eq $rv->[0]; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 19 | 0 | push @build_requires, $_; | |||||||||||
| 20 | } | ||||||||||||
| 21 | 1 | $self->Meta->{values}{build_requires} = \@build_requires; | |||||||||||
| 22 | } | ||||||||||||
| 23 | } | ||||||||||||
| 24 | |||||||||||||
| 25 | 0 | ▶ | sub include_deps { | ||||||||||
|
Subroutine
include_deps: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||
| 26 | 0 | my ($self, $module, $version) = @_; | |||||||||||
| 27 | 0 | ▶ | my $deps = $self->admin->scan_dependencies($module, $self->perl_version, $version) or return; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 28 | 0 | foreach my $key ( sort keys %$deps ) { | |||||||||||
| 29 | 0 | $self->include($key); | |||||||||||
| 30 | } | ||||||||||||
| 31 | } | ||||||||||||
| 32 | |||||||||||||
| 33 | 0 | ▶ | sub auto_include { | ||||||||||
|
Subroutine
auto_include: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 34 | 0 | my $self = shift; | |||||||||||
| 35 | 0 | foreach my $module ( | |||||||||||
| 36 | 0 | map { $_->[0] } | |||||||||||
| 37 | 0 | map { @$_ } | |||||||||||
| 38 | 0 | grep { $_ } | |||||||||||
| 39 | $self->build_requires | ||||||||||||
| 40 | ) { | ||||||||||||
| 41 | 0 | $self->include($module); | |||||||||||
| 42 | } | ||||||||||||
| 43 | } | ||||||||||||
| 44 | |||||||||||||
| 45 | 0 | ▶ | sub auto_include_deps { | ||||||||||
|
Subroutine
auto_include_deps: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 46 | 0 | my $self = shift; | |||||||||||
| 47 | 0 | foreach my $module ( | |||||||||||
| 48 | 0 | map { $_ } | |||||||||||
| 49 | 0 | map { @$_ } | |||||||||||
| 50 | 0 | grep { $_ } | |||||||||||
| 51 | $self->build_requires | ||||||||||||
| 52 | ) { | ||||||||||||
| 53 | 0 | my ($name, $version) = @{$module}; | |||||||||||
| 54 | 0 | $self->include_deps($name, $version); | |||||||||||
| 55 | } | ||||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | =pod | ||||||||||||
| 59 | |||||||||||||
| 60 | =head1 NAME | ||||||||||||
| 61 | |||||||||||||
| 62 | Module::Install::Admin::Include - include methods for Module::Install | ||||||||||||
| 63 | |||||||||||||
| 64 | =head2 auto_include_dependent_dists | ||||||||||||
| 65 | |||||||||||||
| 66 | Grabs everything in this module's build_requires and attempts to | ||||||||||||
| 67 | include everything (at the whole distribution level) recursively. | ||||||||||||
| 68 | |||||||||||||
| 69 | =cut | ||||||||||||
| 70 | |||||||||||||
| 71 | 0 | ▶ | sub auto_include_dependent_dists { | ||||||||||
|
Subroutine
auto_include_dependent_dists: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 72 | 0 | my $self = shift; | |||||||||||
| 73 | 0 | foreach my $module ( | |||||||||||
| 74 | 0 | map { $_->[0] } | |||||||||||
| 75 | 0 | map { @$_ } | |||||||||||
| 76 | 0 | grep { $_ } | |||||||||||
| 77 | $self->build_requires | ||||||||||||
| 78 | ) { | ||||||||||||
| 79 | 0 | $self->include_dependent_dists($module); | |||||||||||
| 80 | } | ||||||||||||
| 81 | } | ||||||||||||
| 82 | |||||||||||||
| 83 | =pod | ||||||||||||
| 84 | |||||||||||||
| 85 | =head2 include_dependent_dists $package | ||||||||||||
| 86 | |||||||||||||
| 87 | Given a module package name, recursively include every package that | ||||||||||||
| 88 | module needs. | ||||||||||||
| 89 | |||||||||||||
| 90 | =cut | ||||||||||||
| 91 | |||||||||||||
| 92 | 0 | ▶ | sub include_dependent_dists { | ||||||||||
|
Subroutine
include_dependent_dists: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||
| 93 | 0 | my $self = shift; | |||||||||||
| 94 | 0 | my $pkg = shift; | |||||||||||
| 95 | 0 | ▶ | return unless $pkg; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 96 | 0 | ▶ | return if $self->{including_dep_dist}->{ $self->_pkg_to_dist($pkg) }++; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 97 | 0 | $self->include_one_dist($pkg); | |||||||||||
| 98 | 0 | foreach my $mod ( @{ $self->_dist_to_mods( $self->_pkg_to_dist($pkg) ) } ) { | |||||||||||
| 99 | 0 | ▶ | my $deps = $self->admin->scan_dependencies($mod) or return; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 100 | 0 | foreach my $key ( sort grep { $_ } keys %$deps ) { | |||||||||||
| 101 | 0 | $self->include_dependent_dists($key); | |||||||||||
| 102 | } | ||||||||||||
| 103 | } | ||||||||||||
| 104 | } | ||||||||||||
| 105 | |||||||||||||
| 106 | =pod | ||||||||||||
| 107 | |||||||||||||
| 108 | =head2 include_one_dist $module | ||||||||||||
| 109 | |||||||||||||
| 110 | Given a module name, C<$module>, figures out which modules are in the | ||||||||||||
| 111 | dist containing that module and copies all those files to ./inc. I bet | ||||||||||||
| 112 | there's a way to harness smarter logic from L<PAR>. | ||||||||||||
| 113 | |||||||||||||
| 114 | =cut | ||||||||||||
| 115 | |||||||||||||
| 116 | 0 | ▶ | sub include_one_dist { | ||||||||||
|
Subroutine
include_one_dist: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||
| 117 | 0 | my $self = shift; | |||||||||||
| 118 | 0 | my @mods = $self->_dist_to_mods( $self->_pkg_to_dist($_[0]) ); | |||||||||||
| 119 | 0 | foreach my $pattern ( grep { $_ } @mods ) { | |||||||||||
| 120 | 0 | foreach my $rv ( $self->admin->glob_in_inc($pattern) ) { | |||||||||||
| 121 | 0 | $self->admin->copy_package(@$rv); | |||||||||||
| 122 | 0 | my @build_requires; | |||||||||||
| 123 | 0 | ▶ | foreach (@{ $self->build_requires || [] }) { | ||||||||||
|
Condition0%0/2
$self->build_requires || []
MC/DC0%0/1
$self->build_requires || []
$self->build_requires
Truth table0%0/2
A
A= $self->build_requires
| |||||||||||||
| 124 | 0 | ▶ | next if $_->[0] eq $rv->[0]; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 125 | 0 | push @build_requires, $_; | |||||||||||
| 126 | } | ||||||||||||
| 127 | 0 | $self->Meta->{values}{build_requires} = \@build_requires; | |||||||||||
| 128 | } | ||||||||||||
| 129 | } | ||||||||||||
| 130 | } | ||||||||||||
| 131 | |||||||||||||
| 132 | =pod | ||||||||||||
| 133 | |||||||||||||
| 134 | =for private _pkg_to_dist $modname | ||||||||||||
| 135 | |||||||||||||
| 136 | Given a module name, returns the file on CPAN containing | ||||||||||||
| 137 | its latest version. | ||||||||||||
| 138 | |||||||||||||
| 139 | =cut | ||||||||||||
| 140 | |||||||||||||
| 141 | 0 | ▶ | sub _pkg_to_dist { | ||||||||||
|
Subroutine
_pkg_to_dist: not called CC=2 SCAR=17.9
| |||||||||||||
| 142 | 0 | require CPAN; | |||||||||||
| 143 | 0 | ▶ | my $mod = CPAN::Shell->expand( Module => $_[1] ) or return; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 144 | 0 | $mod->cpan_file; | |||||||||||
| 145 | } | ||||||||||||
| 146 | |||||||||||||
| 147 | =pod | ||||||||||||
| 148 | |||||||||||||
| 149 | =for private _dist_to_mods $distname | ||||||||||||
| 150 | |||||||||||||
| 151 | Takes the output of CPAN::Module->cpan_file and return all the modules | ||||||||||||
| 152 | that CPAN.pm knows are in that dist. There's probably a better way using CPANPLUS | ||||||||||||
| 153 | |||||||||||||
| 154 | =cut | ||||||||||||
| 155 | |||||||||||||
| 156 | 0 | ▶ | sub _dist_to_mods { | ||||||||||
|
Subroutine
_dist_to_mods: not called CC=1 SCAR=6.9
| |||||||||||||
| 157 | 0 | CPAN::Shell->expand( Distribution => $_[1] )->containsmods; | |||||||||||
| 158 | } | ||||||||||||
| 159 | |||||||||||||
| 160 | 46 | 1; | |||||||||||