| 1 | package Module::Install::Base; | ||||||||||||
| 2 | |||||||||||||
| 3 | 49 | ▶ | use strict 'vars'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 49 | ▶ | use vars qw{$VERSION}; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 49 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 49 | $VERSION = '1.21'; | |||||||||||
| 7 | } | ||||||||||||
| 8 | |||||||||||||
| 9 | # Suspend handler for "redefined" warnings | ||||||||||||
| 10 | 49 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 49 | my $w = $SIG{__WARN__}; | |||||||||||
| 12 | 49 | ▶ | $SIG{__WARN__} = sub { $w }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | } | ||||||||||||
| 14 | |||||||||||||
| 15 | =pod | ||||||||||||
| 16 | |||||||||||||
| 17 | =head1 NAME | ||||||||||||
| 18 | |||||||||||||
| 19 | Module::Install::Base - Base class for Module::Install extensions | ||||||||||||
| 20 | |||||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||||
| 22 | |||||||||||||
| 23 | In a B<Module::Install> extension: | ||||||||||||
| 24 | |||||||||||||
| 25 | use Module::Install::Base (); | ||||||||||||
| 26 | @ISA = qw(Module::Install::Base); | ||||||||||||
| 27 | |||||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||||
| 29 | |||||||||||||
| 30 | This module provide essential methods for all B<Module::Install> | ||||||||||||
| 31 | extensions, in particular the common constructor C<new> and method | ||||||||||||
| 32 | dispatcher C<AUTOLOAD>. | ||||||||||||
| 33 | |||||||||||||
| 34 | =head1 METHODS | ||||||||||||
| 35 | |||||||||||||
| 36 | =over 4 | ||||||||||||
| 37 | |||||||||||||
| 38 | =item new(%args) | ||||||||||||
| 39 | |||||||||||||
| 40 | Constructor -- need to preserve at least _top | ||||||||||||
| 41 | |||||||||||||
| 42 | =cut | ||||||||||||
| 43 | |||||||||||||
| 44 | 1306 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||
| 45 | 1306 | my $class = shift; | |||||||||||
| 46 | 1306 | ▶ | unless ( defined &{"${class}::call"} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 47 | 0 | ▶ | *{"${class}::call"} = sub { shift->_top->call(@_) }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||
| 48 | } | ||||||||||||
| 49 | 1306 | ▶ | unless ( defined &{"${class}::load"} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 50 | 1306 | ▶ | *{"${class}::load"} = sub { shift->_top->load(@_) }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 51 | } | ||||||||||||
| 52 | 1306 | bless { @_ }, $class; | |||||||||||
| 53 | } | ||||||||||||
| 54 | |||||||||||||
| 55 | =pod | ||||||||||||
| 56 | |||||||||||||
| 57 | =item AUTOLOAD | ||||||||||||
| 58 | |||||||||||||
| 59 | The main dispatcher - copy extensions if missing | ||||||||||||
| 60 | |||||||||||||
| 61 | =cut | ||||||||||||
| 62 | |||||||||||||
| 63 | 1367 | ▶ | sub AUTOLOAD { | ||||||||||
|
Subroutine
AUTOLOAD: called CC=2 SCAR=7.0
| |||||||||||||
| 64 | 1367 | local $@; | |||||||||||
| 65 | 1367 | ▶ | my $func = eval { shift->_top->autoload } or return; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 66 | 1367 | goto &$func; | |||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | =pod | ||||||||||||
| 70 | |||||||||||||
| 71 | =item _top() | ||||||||||||
| 72 | |||||||||||||
| 73 | Returns the top-level B<Module::Install> object. | ||||||||||||
| 74 | |||||||||||||
| 75 | =cut | ||||||||||||
| 76 | |||||||||||||
| 77 | 2229 | ▶ | sub _top { | ||||||||||
|
Subroutine
_top: called CC=1 SCAR=0.0
| |||||||||||||
| 78 | 2229 | $_[0]->{_top}; | |||||||||||
| 79 | } | ||||||||||||
| 80 | |||||||||||||
| 81 | =pod | ||||||||||||
| 82 | |||||||||||||
| 83 | =item admin() | ||||||||||||
| 84 | |||||||||||||
| 85 | Returns the C<_top> object's associated B<Module::Install::Admin> object | ||||||||||||
| 86 | on the first run (i.e. when there was no F<inc/> when the program | ||||||||||||
| 87 | started); on subsequent (user-side) runs, returns a fake admin object | ||||||||||||
| 88 | with an empty C<AUTOLOAD> method that does nothing at all. | ||||||||||||
| 89 | |||||||||||||
| 90 | =cut | ||||||||||||
| 91 | |||||||||||||
| 92 | 288 | ▶ | sub admin { | ||||||||||
|
Subroutine
admin: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||
| 93 | $_[0]->_top->{admin} | ||||||||||||
| 94 | or | ||||||||||||
| 95 | 288 | ▶ | Module::Install::Base::FakeAdmin->new; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 96 | } | ||||||||||||
| 97 | |||||||||||||
| 98 | =pod | ||||||||||||
| 99 | |||||||||||||
| 100 | =item is_admin() | ||||||||||||
| 101 | |||||||||||||
| 102 | Tells whether this is the first run of the installer (on | ||||||||||||
| 103 | author's side). That is when there was no F<inc/> at | ||||||||||||
| 104 | program start. True if that's the case. False, otherwise. | ||||||||||||
| 105 | |||||||||||||
| 106 | =cut | ||||||||||||
| 107 | |||||||||||||
| 108 | 123 | ▶ | sub is_admin { | ||||||||||
|
Subroutine
is_admin: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 109 | 123 | ! $_[0]->admin->isa('Module::Install::Base::FakeAdmin'); | |||||||||||
| 110 | } | ||||||||||||
| 111 | |||||||||||||
| 112 | 0 | ▶ | sub DESTROY {} | ||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||
| 113 | |||||||||||||
| 114 | package Module::Install::Base::FakeAdmin; | ||||||||||||
| 115 | |||||||||||||
| 116 | 49 | ▶ | use vars qw{$VERSION}; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 117 | 49 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 118 | 49 | $VERSION = $Module::Install::Base::VERSION; | |||||||||||
| 119 | } | ||||||||||||
| 120 | |||||||||||||
| 121 | 49 | my $fake; | |||||||||||
| 122 | |||||||||||||
| 123 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
| |||||||||||||
| 124 | 0 | ▶ | $fake ||= bless(\@_, $_[0]); | ||||||||||
|
Condition0%0/2
$fake ||= bless(\@_, $_[0])
MC/DC0%0/1
$fake ||= bless(\@_, $_[0])
$fake
Truth table0%0/2
A
A= $fake
| |||||||||||||
| 125 | } | ||||||||||||
| 126 | |||||||||||||
| 127 | 0 | ▶ | sub AUTOLOAD {} | ||||||||||
|
Subroutine
AUTOLOAD: not called CC=1 SCAR=0.0
| |||||||||||||
| 128 | |||||||||||||
| 129 | 0 | ▶ | sub DESTROY {} | ||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||
| 130 | |||||||||||||
| 131 | # Restore warning handler | ||||||||||||
| 132 | 49 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 133 | 49 | $SIG{__WARN__} = $SIG{__WARN__}->(); | |||||||||||
| 134 | } | ||||||||||||
| 135 | |||||||||||||
| 136 | 49 | 1; | |||||||||||
| 137 | |||||||||||||
| 138 | =pod | ||||||||||||
| 139 | |||||||||||||
| 140 | =back | ||||||||||||
| 141 | |||||||||||||
| 142 | =head1 SEE ALSO | ||||||||||||
| 143 | |||||||||||||
| 144 | L<Module::Install> | ||||||||||||
| 145 | |||||||||||||
| 146 | =head1 AUTHORS | ||||||||||||
| 147 | |||||||||||||
| 148 | Audrey Tang E<lt>autrijus@autrijus.orgE<gt> | ||||||||||||
| 149 | |||||||||||||
| 150 | =head1 COPYRIGHT | ||||||||||||
| 151 | |||||||||||||
| 152 | Copyright 2003, 2004 by Audrey Tang E<lt>autrijus@autrijus.orgE<gt>. | ||||||||||||
| 153 | |||||||||||||
| 154 | This program is free software; you can redistribute it and/or modify it | ||||||||||||
| 155 | under the same terms as Perl itself. | ||||||||||||
| 156 | |||||||||||||
| 157 | See L<http://www.perl.com/perl/misc/Artistic.html> | ||||||||||||
| 158 | |||||||||||||
| 159 | =cut | ||||||||||||