File Coverage

blib/lib/Module/Install/Bundle.pm
Criterion Covered Total %
statement 18 57 31.5
branch 0 24 0.0
condition 0 2 0.0
subroutine 6 11 54.5
pod 4 4 100.0
total 28 98 28.5


line stmt bran cond sub pod time code
1             package Module::Install::Bundle;
2              
3 1     1   828 use strict;
  1         2  
  1         23  
4 1     1   4 use File::Spec;
  1         1  
  1         24  
5 1     1   6 use Module::Install::Base ();
  1         1  
  1         26  
6              
7 1     1   4 use vars qw{$VERSION @ISA $ISCORE};
  1         1  
  1         60  
8             BEGIN {
9 1     1   2 $VERSION = '1.18';
10 1         7 @ISA = 'Module::Install::Base';
11 1         305 $ISCORE = 1;
12             }
13              
14             sub auto_bundle {
15 0     0 1   my $self = shift;
16              
17 0 0         return $self->_install_bundled_dists unless $self->is_admin;
18              
19             # Flatten array of arrays into a single array
20 0           my @core = map @$_, map @$_, grep ref, $self->requires;
21              
22 0           $self->bundle(@core);
23             }
24              
25             sub bundle {
26 0     0 1   my $self = shift;
27              
28 0 0         return $self->_install_bundled_dists unless $self->is_admin;
29              
30 0           $self->admin->bundle(@_);
31             }
32              
33             sub auto_bundle_deps {
34 0     0 1   my $self = shift;
35              
36 0 0         return $self->_install_bundled_dists unless $self->is_admin;
37              
38             # Flatten array of arrays into a single array
39 0           my @core = map @$_, map @$_, grep ref, $self->requires;
40 0           while (my ($name, $version) = splice(@core, 0, 2)) {
41 0 0         next unless $name;
42 0           $self->bundle_deps($name, $version);
43             }
44             }
45              
46             sub bundle_deps {
47 0     0 1   my ($self, $pkg, $version) = @_;
48              
49 0 0         return $self->_install_bundled_dists unless $self->is_admin;
50              
51 0           my $deps = $self->admin->scan_dependencies($pkg);
52 0 0         if (scalar keys %$deps == 0) {
53             # Probably a user trying to install the package, read the dependencies from META.yml
54 0           %$deps = ( map { $$_[0] => undef } (@{$self->requires()}) );
  0            
  0            
55             }
56 0           foreach my $key (sort keys %$deps) {
57 0 0         $self->bundle($key, ($key eq $pkg) ? $version : 0);
58             }
59             }
60              
61             sub _install_bundled_dists {
62 0     0     my $self = shift;
63              
64             # process bundle only the first time this function is called
65 0 0         return if $self->{bundle_processed};
66              
67 0   0       $self->makemaker_args->{DIR} ||= [];
68              
69             # process all dists bundled in inc/BUNDLES/
70 0           my $bundle_dir = $self->_top->{bundle};
71 0           foreach my $sub_dir (glob File::Spec->catfile($bundle_dir,"*")) {
72              
73 0 0         next if -f $sub_dir;
74              
75             # ignore dot dirs/files if any
76 0           my $dot_file = File::Spec->catfile($bundle_dir,'\.');
77 1 0   1   428 next if index($sub_dir, $dot_file) >= $[;
  1         291  
  1         170  
  0            
78              
79             # EU::MM can't handle Build.PL based distributions
80 0 0         if (-f File::Spec->catfile($sub_dir, 'Build.PL')) {
81 0           warn "Skipped: $sub_dir has Build.PL.";
82 0           next;
83             }
84              
85             # EU::MM can't handle distributions without Makefile.PL
86             # (actually this is to cut blib in a wrong directory)
87 0 0         if (!-f File::Spec->catfile($sub_dir, 'Makefile.PL')) {
88 0           warn "Skipped: $sub_dir has no Makefile.PL.";
89 0           next;
90             }
91 0           push @{ $self->makemaker_args->{DIR} }, $sub_dir;
  0            
92             }
93              
94 0           $self->{bundle_processed} = 1;
95             }
96              
97             1;
98              
99             __END__