| 1 | #line 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2 | #line 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3 | package Module::Install; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | # For any maintainers: | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # The load order for Module::Install is a bit magic. | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # It goes something like this... | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # IF ( host has Module::Install installed, creating author mode ) { | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # 1. Makefile.PL calls "use inc::Module::Install" | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # 3. The installed version of inc::Module::Install loads | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # 4. inc::Module::Install calls "require Module::Install" | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # 5. The ./inc/ version of Module::Install loads | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # } ELSE { | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # 1. Makefile.PL calls "use inc::Module::Install" | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # 3. The ./inc/ version of Module::Install loads | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | # } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 21 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | require 5.004; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use strict 'vars'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | use vars qw{$VERSION}; | ||||||||||||||||||||||||||||||||||||||||||
| 27 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # All Module::Install core packages now require synchronised versions. | ||||||||||||||||||||||||||||||||||||||||||
| 29 | # This will be used to ensure we don't accidentally load old or | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # different versions of modules. | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # This is not enforced yet, but will be some time in the next few | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | # releases once we can make sure it won't clash with custom | |||||||||||||||||||||||||||||||||||||||||
| 33 | # Module::Install extensions. | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | $VERSION = '0.77'; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 36 | *inc::Module::Install::VERSION = *VERSION; | ||||||||||||||||||||||||||||||||||||||||||
| 37 | @inc::Module::Install::ISA = __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | # Whether or not inc::Module::Install is actually loaded, the | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # $INC{inc/Module/Install.pm} is what will still get set as long as | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # the caller loaded module this in the documented manner. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # If not set, the caller may NOT have loaded the bundled version, and thus | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | # they may not have a MI version that works with the Makefile.PL. This would | |||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | # result in false errors or unexpected behaviour. And we don't want that. | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm'; | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | unless ( $INC{$file} ) { die <<"END_DIE" } | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | Please invoke ${\__PACKAGE__} with: | |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | use inc::${\__PACKAGE__}; | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | not: | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | use ${\__PACKAGE__}; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | END_DIE | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | # If the script that is loading Module::Install is from the future, | ||||||||||||||||||||||||||||||||||||||||||
| 69 | # then make will detect this and cause it to re-run over and over | ||||||||||||||||||||||||||||||||||||||||||
| 70 | # again. This is bad. Rather than taking action to touch it (which | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | # is unreliable on some platforms and requires write permissions) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-f $0 and (stat $0)[9] > time
MC/DC0%0/2
-f $0 and (stat $0)[9] > time
-f $0
(stat $0)[9] > time
Truth table33%1/3
A and B
A= -f $0B= (stat $0)[9] > time
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | # for now we should catch this and refuse to run. | ||||||||||||||||||||||||||||||||||||||||||
| 73 | if ( -f $0 and (stat($0))[9] > time ) { die <<"END_DIE" } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | Your installer $0 has a modification time in the future. | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | This is known to create infinite loops in make. | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | Please correct this, then run $0 again. | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | END_DIE | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | # Build.PL was formerly supported, but no longer is due to excessive | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | # difficulty in implementing every single feature twice. | ||||||||||||||||||||||||||||||||||||||||||
| 89 | if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | Module::Install no longer supports Build.PL. | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | It was impossible to maintain duel backends, and has been deprecated. | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | Please remove all Build.PL files and only use the Makefile.PL installer. | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | END_DIE | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | # To save some more typing in Module::Install installers, every... | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | # use inc::Module::Install | |||||||||||||||||||||||||||||||||||||||||
| 105 | # ...also acts as an implicit use strict. | ||||||||||||||||||||||||||||||||||||||||||
| 106 | $^H |= strict::bits(qw(refs subs vars)); | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | ▶ | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | ▶ | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | use Cwd (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | ▶ | use File::Find (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | use File::Path (); | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 19 | ▶ | use FindBin; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autoload: called CC=1 SCAR=0.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 19 | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 19 | sub autoload { | |||||||||||||||||||||||||||||||||||||||||
| 118 | 19 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 19 | my $who = $self->_caller; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 26 | ▶ | my $cwd = Cwd::cwd(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 26 | my $sym = "${who}::AUTOLOAD"; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 26 | ▶ | $sym->{$cwd} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | my $pwd = Cwd::cwd(); | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 26 | ▶ | if ( my $code = $sym->{$pwd} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | # delegate back to parent dirs | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 26 | ▶ | goto &$code unless $cwd eq $pwd; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 26 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 26 | $$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym"; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 26 | unless ( uc($1) eq $1 ) { | |||||||||||||||||||||||||||||||||||||||||
| 130 | unshift @_, ( $self, $1 ); | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 19 | goto &{$self->can('call')}; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=8.3
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | sub import { | |||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 138 | my $self = $class->new(@_); | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | ▶ | my $who = $self->_caller; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | unless ( -f $self->{file} ) { | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | require "$self->{path}/$self->{dispatch}.pm"; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | File::Path::mkpath("$self->{prefix}/$self->{author}"); | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self ); | |||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $self->{admin}->init; | |||||||||||||||||||||||||||||||||||||||||
| 146 | @_ = ($class, _self => $self); | ||||||||||||||||||||||||||||||||||||||||||
| 147 | goto &{"$self->{name}::import"}; | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 150 | *{"${who}::AUTOLOAD"} = $self->autoload; | ||||||||||||||||||||||||||||||||||||||||||
| 151 | $self->preload; | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | # Unregister loader and worker packages so subdirs can use them again | |||||||||||||||||||||||||||||||||||||||||
| 154 | delete $INC{"$self->{file}"}; | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | delete $INC{"$self->{path}.pm"}; | |||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | return 1; | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preload: called CC=9 SCAR=22.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | ▶ | sub preload { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 162 | unless ( $self->{extensions} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 163 | $self->load_extensions( | ||||||||||||||||||||||||||||||||||||||||||
| 164 | "$self->{prefix}/$self->{path}", $self | ||||||||||||||||||||||||||||||||||||||||||
| 165 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | ▶ | |||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my @exts = @{$self->{extensions}}; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | unless ( @exts ) { | |||||||||||||||||||||||||||||||||||||||||
| 170 | my $admin = $self->{admin}; | ||||||||||||||||||||||||||||||||||||||||||
| 171 | @exts = $admin->load_all_extensions; | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 4 | ▶ | my %seen; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 104 | ▶ | foreach my $obj ( @exts ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 89 | ▶ | while (my ($method, $glob) = each %{ref($obj) . '::'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 87 | ▶ | next unless $obj->can($method); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 81 | next if $method =~ /^_/; | |||||||||||||||||||||||||||||||||||||||||
| 179 | next if $method eq uc($method); | ||||||||||||||||||||||||||||||||||||||||||
| 180 | $seen{$method}++; | ||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 68 | ▶ | my $who = $self->_caller; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 8 | foreach my $name ( sort keys %seen ) { | |||||||||||||||||||||||||||||||||||||||||
| 186 | 8 | *{"${who}::$name"} = sub { | |||||||||||||||||||||||||||||||||||||||||
| 187 | 68 | ${"${who}::AUTOLOAD"} = "${who}::$name"; | |||||||||||||||||||||||||||||||||||||||||
| 188 | goto &{"${who}::AUTOLOAD"}; | ||||||||||||||||||||||||||||||||||||||||||
| 189 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=13 SCAR=30.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 193 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 194 | my ($class, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | ▶ | # ignore the prefix on extension modules built from top level. | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $base_path = Cwd::abs_path($FindBin::Bin); | |||||||||||||||||||||||||||||||||||||||||
| 198 | unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) { | ||||||||||||||||||||||||||||||||||||||||||
| 199 | delete $args{prefix}; | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | return $args{_self} if $args{_self}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"dispatch"} ||= "Admin"
MC/DC0%0/1
$args{"dispatch"} ||= "Admin"
$args{"dispatch"}
Truth table50%1/2
A
A= $args{"dispatch"}
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | ▶ | |||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"prefix"} ||= "inc"
MC/DC0%0/1
$args{"prefix"} ||= "inc"
$args{"prefix"}
Truth table50%1/2
A
A= $args{"prefix"}
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | ▶ | $args{dispatch} ||= 'Admin'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{"author"} ||= $^O eq "VMS" ? "_author" : ".author"
MC/DC0%0/2
$args{"author"} ||= $^O eq "VMS" ? "_author" : ".author"
$args{"author"}
$^O eq "VMS" ? "_author" : ".author"
Truth table33%1/3
A ||= B
A= $args{"author"}B= $^O eq "VMS" ? "_author" : ".author"
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | ▶ | $args{prefix} ||= 'inc'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"bundle"} ||= "inc/BUNDLES"
MC/DC0%0/1
$args{"bundle"} ||= "inc/BUNDLES"
$args{"bundle"}
Truth table50%1/2
A
A= $args{"bundle"}
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | ▶ | $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args{"base"} ||= $base_path
MC/DC0%0/2
$args{"base"} ||= $base_path
$args{"base"}
$base_path
Truth table33%1/3
A ||= B
A= $args{"base"}B= $base_path
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | $args{bundle} ||= 'inc/BUNDLES'; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | ▶ | $args{base} ||= $base_path; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args{"name"} ||= $class
MC/DC0%0/2
$args{"name"} ||= $class
$args{"name"}
$class
Truth table33%1/3
A ||= B
A= $args{"name"}B= $class
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | ▶ | $class =~ s/^\Q$args{prefix}\E:://; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args{"version"} ||= $class->VERSION
MC/DC0%0/2
$args{"version"} ||= $class->VERSION
$args{"version"}
$class->VERSION
Truth table33%1/3
A ||= B
A= $args{"version"}B= $class->VERSION
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | ▶ | $args{name} ||= $class; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | $args{version} ||= $class->VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | unless ( $args{path} ) { | |||||||||||||||||||||||||||||||||||||||||
| 213 | $args{path} = $args{name}; | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | ▶ | $args{path} =~ s!::!/!g; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"file"} ||= qq[$args{"base"}/$args{"prefix"}/$args{"path"}.pm]
MC/DC0%0/1
$args{"file"} ||= qq[$args{"base"}/$args{"prefix"}/$args{"path"}.pm]
$args{"file"}
Truth table50%1/2
A
A= $args{"file"}
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 216 | $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm"; | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | $args{wrote} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | bless( \%args, $class ); | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 26 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 26 | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 26 | ▶ | sub call { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 26 | my ($self, $method) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 26 | my $obj = $self->load($method) or return; | |||||||||||||||||||||||||||||||||||||||||
| 225 | splice(@_, 0, 2, $obj); | ||||||||||||||||||||||||||||||||||||||||||
| 226 | goto &{$obj->can($method)}; | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 27 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=5 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 27 | ||||||||||||||||||||||||||||||||||||||||||
| 229 | sub load { | ||||||||||||||||||||||||||||||||||||||||||
| 230 | my ($self, $method) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 27 | ▶ | $self->load_extensions( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | "$self->{prefix}/$self->{path}", $self | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 27 | ) unless $self->{extensions}; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 55 | ▶ | |||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | foreach my $obj (@{$self->{extensions}}) { | ||||||||||||||||||||||||||||||||||||||||||
| 237 | return $obj if $obj->can($method); | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | my $admin = $self->{admin} or die <<"END_DIE"; | ||||||||||||||||||||||||||||||||||||||||||
| 241 | The '$method' method does not exist in the '$self->{prefix}' path! | ||||||||||||||||||||||||||||||||||||||||||
| 242 | Please remove the '$self->{prefix}' directory and run $0 again to load it. | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | END_DIE | |||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 245 | my $obj = $admin->load($method, 1); | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | push @{$self->{extensions}}, $obj; | |||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | $obj; | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_extensions: called CC=7 SCAR=20.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 251 | sub load_extensions { | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | ▶ | my ($self, $path, $top) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 254 | unless ( grep { lc $_ eq lc $self->{prefix} } @INC ) { | ||||||||||||||||||||||||||||||||||||||||||
| 255 | unshift @INC, $self->{prefix}; | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 4 | ▶ | foreach my $rv ( $self->find_extensions($path) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | my ($file, $pkg) = @{$rv}; | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 4 | next if $self->{pathnames}{$pkg}; | |||||||||||||||||||||||||||||||||||||||||
| 261 | 4 | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 4 | ▶ | local $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | my $new = eval { require $file; $pkg->can('new') }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | unless ( $new ) { | |||||||||||||||||||||||||||||||||||||||||
| 265 | warn $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 4 | next; | |||||||||||||||||||||||||||||||||||||||||
| 267 | 4 | } | |||||||||||||||||||||||||||||||||||||||||
| 268 | $self->{pathnames}{$pkg} = delete $INC{$file}; | ||||||||||||||||||||||||||||||||||||||||||
| 269 | push @{$self->{extensions}}, &{$new}($pkg, _top => $top ); | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"extensions"} ||= []
MC/DC0%0/1
$self->{"extensions"} ||= []
$self->{"extensions"}
Truth table50%1/2
A
A= $self->{"extensions"}
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | $self->{extensions} ||= []; | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_extensions: called CC=2 SCAR=10.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 275 | sub find_extensions { | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 5 | ▶ | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=12 SCAR=39.7
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 5 | my @found; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 5 | ▶ | File::Find::find( sub { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 4 | my $file = $File::Find::name; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 4 | ▶ | return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | my $subpath = $1; | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 4 | return if lc($subpath) eq lc($self->{dispatch}); | |||||||||||||||||||||||||||||||||||||||||
| 284 | 4 | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 4 | $file = "$self->{path}/$subpath.pm"; | |||||||||||||||||||||||||||||||||||||||||
| 286 | my $pkg = "$self->{name}::$subpath"; | ||||||||||||||||||||||||||||||||||||||||||
| 287 | $pkg =~ s!/!::!g; | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | # If we have a mixed-case package name, assume case has been preserved | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 4 | ▶ | # correctly. Otherwise, root through the file to locate the case-preserved | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$subpath eq lc $subpath or $subpath eq uc $subpath
MC/DC0%0/2
$subpath eq lc $subpath or $subpath eq uc $subpath
$subpath eq lc $subpath
$subpath eq uc $subpath
Truth table33%1/3
A or B
A= $subpath eq lc $subpathB= $subpath eq uc $subpath
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | # version of the package name. | |||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) { | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my $content = Module::Install::_read($subpath . '.pm'); | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | my $in_pod = 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | foreach ( split //, $content ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | $in_pod = 1 if /^=\w/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$in_pod or /^=cut/
MC/DC0%0/2
$in_pod or /^=cut/
$in_pod
/^=cut/
Truth table0%0/3
A or B
A= $in_podB= /^=cut/
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | $in_pod = 0 if /^=cut/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | next if ($in_pod || /^=cut/); # skip pod text | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | next if /^\s*#/; # and comments | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | if ( m/^\s*package\s+($pkg)\s*;/i ) { | |||||||||||||||||||||||||||||||||||||||||
| 301 | $pkg = $1; | ||||||||||||||||||||||||||||||||||||||||||
| 302 | last; | ||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 4 | } | |||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | ▶ | |||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | push @found, [ $file, $pkg ]; | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 1 | }, $path ) if -d $path; | |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | @found; | ||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 21 | ▶ | # Utility Functions | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_caller: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 21 | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 21 | sub _caller { | |||||||||||||||||||||||||||||||||||||||||
| 321 | 21 | ▶ | my $depth = 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 23 | my $call = caller($depth); | |||||||||||||||||||||||||||||||||||||||||
| 323 | 23 | while ( $call eq __PACKAGE__ ) { | |||||||||||||||||||||||||||||||||||||||||
| 324 | $depth++; | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 21 | $call = caller($depth); | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | return $call; | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | ▶ | sub _read { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | local *FH; | |||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | ▶ | open FH, "< $_[0]" or die "open($_[0]): $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | my $str = do { local $/; <FH> }; | |||||||||||||||||||||||||||||||||||||||||
| 334 | close FH or die "close($_[0]): $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 335 | return $str; | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | sub _write { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | local *FH; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | open FH, "> $_[0]" or die "open($_[0]): $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!" } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | close FH or die "close($_[0]): $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | # _version is for processing module versions (eg, 1.03_05) not | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | # Perl versions (eg, 5.8.1). | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_version: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | sub _version ($) { | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | my $s = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$1 || 0
MC/DC0%0/1
$1 || 0
$1
Truth table0%0/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $s =~ s/^(\d+)\.?//; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | my $l = $1 || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g; | |||||||||||||||||||||||||||||||||||||||||
| 353 | $l = $l . '.' . join '', @v if @v; | ||||||||||||||||||||||||||||||||||||||||||
| 354 | return $l + 0; | ||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_CLASS: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | # Cloned from Params::Util::_CLASS | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | sub _CLASS ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*$/s
defined $_[0] and not ref $_[0]
MC/DC0%0/3
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*$/s
defined $_[0]
not ref $_[0]
$_[0] =~ /^[^\W\d]\w*(?:::\w+)*$/s
Truth table0%0/4
A and not(B) and C
A= defined $_[0]B= not ref $_[0]C= $_[0] =~ /^[^\W\d]\w*(?:::\w+)*$/s
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 360 | defined $_[0] | ||||||||||||||||||||||||||||||||||||||||||
| 361 | and | ||||||||||||||||||||||||||||||||||||||||||
| 362 | ! ref $_[0] | ||||||||||||||||||||||||||||||||||||||||||
| 363 | and | ||||||||||||||||||||||||||||||||||||||||||
| 364 | $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*$/s | ||||||||||||||||||||||||||||||||||||||||||
| 365 | ) ? $_[0] : undef; | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 1; | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | # Copyright 2008 Adam Kennedy. | ||||||||||||||||||||||||||||||||||||||||||