| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#line 1 |
|
2
|
|
|
|
|
|
|
package Module::Pluggable::Object; |
|
3
|
4
|
|
|
4
|
|
1704
|
|
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
114
|
|
|
4
|
4
|
|
|
4
|
|
24
|
use strict; |
|
|
4
|
|
|
|
|
18
|
|
|
|
4
|
|
|
|
|
70
|
|
|
5
|
4
|
|
|
4
|
|
21
|
use File::Find (); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
350
|
|
|
6
|
4
|
|
|
4
|
|
1766
|
use File::Basename; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
332
|
|
|
7
|
4
|
|
|
4
|
|
63
|
use File::Spec::Functions qw(splitdir catdir curdir catfile abs2rel); |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
258
|
|
|
8
|
4
|
|
|
4
|
|
1694
|
use Carp qw(croak carp confess); |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
194
|
|
|
9
|
4
|
|
|
4
|
|
25
|
use Devel::InnerPackage; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
212
|
|
|
10
|
|
|
|
|
|
|
use vars qw($VERSION $MR); |
|
11
|
4
|
|
|
4
|
|
23
|
|
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
|
|
use if $] > 5.017, 'deprecate'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$VERSION = '5.2'; |
|
15
|
|
|
|
|
|
|
|
|
16
|
4
|
|
|
4
|
|
16
|
BEGIN { |
|
|
4
|
|
|
|
|
2039
|
|
|
17
|
4
|
50
|
|
|
|
7068
|
eval { require Module::Runtime }; |
|
18
|
4
|
|
|
|
|
25
|
unless ($@) { |
|
19
|
|
|
|
|
|
|
Module::Runtime->import('require_module'); |
|
20
|
|
|
|
|
|
|
} else { |
|
21
|
0
|
|
|
|
|
0
|
*require_module = sub { |
|
22
|
0
|
|
|
|
|
0
|
my $module = shift; |
|
23
|
0
|
|
|
|
|
0
|
my $path = $module . ".pm"; |
|
24
|
0
|
|
|
|
|
0
|
$path =~ s{::}{/}g; |
|
25
|
0
|
|
|
|
|
0
|
require $path; |
|
26
|
|
|
|
|
|
|
}; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
9
|
|
|
9
|
0
|
205
|
sub new { |
|
32
|
9
|
|
|
|
|
33
|
my $class = shift; |
|
33
|
|
|
|
|
|
|
my %opts = @_; |
|
34
|
9
|
|
|
|
|
45
|
|
|
35
|
|
|
|
|
|
|
return bless \%opts, $class; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
### Eugggh, this code smells |
|
40
|
|
|
|
|
|
|
### This is what happens when you keep adding patches |
|
41
|
|
|
|
|
|
|
### *sigh* |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
38
|
|
|
38
|
0
|
290
|
sub plugins { |
|
45
|
38
|
|
|
|
|
87
|
my $self = shift; |
|
46
|
|
|
|
|
|
|
my @args = @_; |
|
47
|
|
|
|
|
|
|
|
|
48
|
38
|
50
|
|
|
|
137
|
# override 'require' |
|
49
|
|
|
|
|
|
|
$self->{'require'} = 1 if $self->{'inner'}; |
|
50
|
38
|
|
|
|
|
119
|
|
|
51
|
38
|
|
|
|
|
74
|
my $filename = $self->{'filename'}; |
|
52
|
|
|
|
|
|
|
my $pkg = $self->{'package'}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
38
|
|
|
|
|
159
|
# Get the exception params instantiated |
|
55
|
|
|
|
|
|
|
$self->_setup_exceptions; |
|
56
|
|
|
|
|
|
|
|
|
57
|
38
|
|
|
|
|
106
|
# automatically turn a scalar search path or namespace into a arrayref |
|
58
|
76
|
100
|
100
|
|
|
387
|
for (qw(search_path search_dirs)) { |
|
59
|
|
|
|
|
|
|
$self->{$_} = [ $self->{$_} ] if exists $self->{$_} && !ref($self->{$_}); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
38
|
|
50
|
|
|
140
|
# default search path is '::::Plugin' |
|
63
|
|
|
|
|
|
|
$self->{'search_path'} ||= ["${pkg}::Plugin"]; |
|
64
|
|
|
|
|
|
|
|
|
65
|
38
|
|
100
|
0
|
|
151
|
# default error handler |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
66
|
38
|
|
100
|
0
|
|
140
|
$self->{'on_require_error'} ||= sub { my ($plugin, $err) = @_; carp "Couldn't require $plugin : $err"; return 0 }; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
67
|
|
|
|
|
|
|
$self->{'on_instantiate_error'} ||= sub { my ($plugin, $err) = @_; carp "Couldn't instantiate $plugin: $err"; return 0 }; |
|
68
|
|
|
|
|
|
|
|
|
69
|
38
|
100
|
|
|
|
105
|
# default whether to follow symlinks |
|
70
|
|
|
|
|
|
|
$self->{'follow_symlinks'} = 1 unless exists $self->{'follow_symlinks'}; |
|
71
|
|
|
|
|
|
|
|
|
72
|
38
|
100
|
66
|
|
|
529
|
# check to see if we're running under test |
|
|
407
|
|
|
|
|
977
|
|
|
73
|
|
|
|
|
|
|
my @SEARCHDIR = exists $INC{"blib.pm"} && defined $filename && $filename =~ m!(^|/)blib/! && !$self->{'force_search_all_paths'} ? grep {/blib/} @INC : @INC; |
|
74
|
|
|
|
|
|
|
|
|
75
|
38
|
50
|
|
|
|
143
|
# add any search_dir params |
|
|
0
|
|
|
|
|
0
|
|
|
76
|
|
|
|
|
|
|
unshift @SEARCHDIR, @{$self->{'search_dirs'}} if defined $self->{'search_dirs'}; |
|
77
|
|
|
|
|
|
|
|
|
78
|
38
|
|
|
|
|
146
|
# set our @INC up to include and prefer our search_dirs if necessary |
|
79
|
38
|
50
|
|
|
|
74
|
my @tmp = @INC; |
|
|
38
|
|
|
|
|
177
|
|
|
80
|
38
|
50
|
|
|
|
126
|
unshift @tmp, @{$self->{'search_dirs'} || []}; |
|
81
|
|
|
|
|
|
|
local @INC = @tmp if defined $self->{'search_dirs'}; |
|
82
|
38
|
|
|
|
|
130
|
|
|
83
|
38
|
|
|
|
|
95
|
my @plugins = $self->search_directories(@SEARCHDIR); |
|
|
38
|
|
|
|
|
186
|
|
|
84
|
38
|
|
|
|
|
86
|
push(@plugins, $self->handle_inc_hooks($_, @SEARCHDIR)) for @{$self->{'search_path'}}; |
|
|
38
|
|
|
|
|
123
|
|
|
85
|
|
|
|
|
|
|
push(@plugins, $self->handle_innerpackages($_)) for @{$self->{'search_path'}}; |
|
86
|
|
|
|
|
|
|
|
|
87
|
38
|
50
|
|
|
|
105
|
# return blank unless we've found anything |
|
88
|
|
|
|
|
|
|
return () unless @plugins; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# remove duplicates |
|
91
|
38
|
|
|
|
|
94
|
# probably not necessary but hey ho |
|
92
|
38
|
|
|
|
|
97
|
my %plugins; |
|
93
|
346
|
50
|
|
|
|
587
|
for(@plugins) { |
|
94
|
346
|
|
|
|
|
683
|
next unless $self->_is_legit($_); |
|
95
|
|
|
|
|
|
|
$plugins{$_} = 1; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
38
|
50
|
|
|
|
99
|
# are we instantiating or requiring? |
|
99
|
0
|
|
|
|
|
0
|
if (defined $self->{'instantiate'}) { |
|
100
|
0
|
|
|
|
|
0
|
my $method = $self->{'instantiate'}; |
|
101
|
0
|
|
|
|
|
0
|
my @objs = (); |
|
102
|
0
|
0
|
|
|
|
0
|
foreach my $package (sort keys %plugins) { |
|
103
|
0
|
|
|
|
|
0
|
next unless $package->can($method); |
|
|
0
|
|
|
|
|
0
|
|
|
104
|
0
|
0
|
|
|
|
0
|
my $obj = eval { $package->$method(@_) }; |
|
105
|
0
|
0
|
|
|
|
0
|
$self->{'on_instantiate_error'}->($package, $@) if $@; |
|
106
|
|
|
|
|
|
|
push @objs, $obj if $obj; |
|
107
|
0
|
|
|
|
|
0
|
} |
|
108
|
|
|
|
|
|
|
return @objs; |
|
109
|
|
|
|
|
|
|
} else { |
|
110
|
38
|
|
|
|
|
186
|
# no? just return the names |
|
111
|
38
|
|
|
|
|
350
|
my @objs= sort keys %plugins; |
|
112
|
|
|
|
|
|
|
return @objs; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
38
|
|
|
38
|
|
73
|
sub _setup_exceptions { |
|
117
|
|
|
|
|
|
|
my $self = shift; |
|
118
|
38
|
|
|
|
|
133
|
|
|
119
|
|
|
|
|
|
|
my %only; |
|
120
|
38
|
|
|
|
|
0
|
my %except; |
|
121
|
38
|
|
|
|
|
0
|
my $only; |
|
122
|
|
|
|
|
|
|
my $except; |
|
123
|
38
|
50
|
|
|
|
114
|
|
|
124
|
0
|
0
|
|
|
|
0
|
if (defined $self->{'only'}) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
0
|
if (ref($self->{'only'}) eq 'ARRAY') { |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
126
|
|
|
|
|
|
|
%only = map { $_ => 1 } @{$self->{'only'}}; |
|
127
|
0
|
|
|
|
|
0
|
} elsif (ref($self->{'only'}) eq 'Regexp') { |
|
128
|
|
|
|
|
|
|
$only = $self->{'only'} |
|
129
|
0
|
|
|
|
|
0
|
} elsif (ref($self->{'only'}) eq '') { |
|
130
|
|
|
|
|
|
|
$only{$self->{'only'}} = 1; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
38
|
50
|
|
|
|
113
|
|
|
135
|
0
|
0
|
|
|
|
0
|
if (defined $self->{'except'}) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
0
|
if (ref($self->{'except'}) eq 'ARRAY') { |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
137
|
|
|
|
|
|
|
%except = map { $_ => 1 } @{$self->{'except'}}; |
|
138
|
0
|
|
|
|
|
0
|
} elsif (ref($self->{'except'}) eq 'Regexp') { |
|
139
|
|
|
|
|
|
|
$except = $self->{'except'} |
|
140
|
0
|
|
|
|
|
0
|
} elsif (ref($self->{'except'}) eq '') { |
|
141
|
|
|
|
|
|
|
$except{$self->{'except'}} = 1; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
38
|
|
|
|
|
142
|
} |
|
144
|
38
|
|
|
|
|
80
|
$self->{_exceptions}->{only_hash} = \%only; |
|
145
|
38
|
|
|
|
|
98
|
$self->{_exceptions}->{only} = $only; |
|
146
|
38
|
|
|
|
|
115
|
$self->{_exceptions}->{except_hash} = \%except; |
|
147
|
|
|
|
|
|
|
$self->{_exceptions}->{except} = $except; |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
692
|
|
|
692
|
|
959
|
sub _is_legit { |
|
152
|
692
|
|
|
|
|
928
|
my $self = shift; |
|
153
|
692
|
50
|
|
|
|
865
|
my $plugin = shift; |
|
|
692
|
|
|
|
|
1775
|
|
|
154
|
692
|
50
|
|
|
|
981
|
my %only = %{$self->{_exceptions}->{only_hash}||{}}; |
|
|
692
|
|
|
|
|
1462
|
|
|
155
|
692
|
|
|
|
|
1087
|
my %except = %{$self->{_exceptions}->{except_hash}||{}}; |
|
156
|
692
|
|
|
|
|
965
|
my $only = $self->{_exceptions}->{only}; |
|
157
|
692
|
|
|
|
|
1995
|
my $except = $self->{_exceptions}->{except}; |
|
158
|
|
|
|
|
|
|
my $depth = () = split '::', $plugin, -1; |
|
159
|
692
|
50
|
33
|
|
|
1883
|
|
|
160
|
692
|
50
|
33
|
|
|
1392
|
return 0 if (keys %only && !$only{$plugin} ); |
|
161
|
|
|
|
|
|
|
return 0 unless (!defined $only || $plugin =~ m!$only! ); |
|
162
|
692
|
0
|
33
|
|
|
1169
|
|
|
163
|
692
|
50
|
33
|
|
|
1345
|
return 0 if (keys %except && $except{$plugin} ); |
|
164
|
|
|
|
|
|
|
return 0 if (defined $except && $plugin =~ m!$except! ); |
|
165
|
692
|
50
|
33
|
|
|
1459
|
|
|
166
|
692
|
50
|
33
|
|
|
1308
|
return 0 if defined $self->{max_depth} && $depth>$self->{max_depth}; |
|
167
|
|
|
|
|
|
|
return 0 if defined $self->{min_depth} && $depth<$self->{min_depth}; |
|
168
|
692
|
|
|
|
|
1615
|
|
|
169
|
|
|
|
|
|
|
return 1; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
38
|
|
|
38
|
0
|
69
|
sub search_directories { |
|
173
|
38
|
|
|
|
|
106
|
my $self = shift; |
|
174
|
|
|
|
|
|
|
my @SEARCHDIR = @_; |
|
175
|
38
|
|
|
|
|
60
|
|
|
176
|
|
|
|
|
|
|
my @plugins; |
|
177
|
38
|
|
|
|
|
82
|
# go through our @INC |
|
178
|
149
|
|
|
|
|
404
|
foreach my $dir (@SEARCHDIR) { |
|
179
|
|
|
|
|
|
|
push @plugins, $self->search_paths($dir); |
|
180
|
38
|
|
|
|
|
157
|
} |
|
181
|
|
|
|
|
|
|
return @plugins; |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
|
185
|
149
|
|
|
149
|
0
|
256
|
sub search_paths { |
|
186
|
149
|
|
|
|
|
230
|
my $self = shift; |
|
187
|
149
|
|
|
|
|
226
|
my $dir = shift; |
|
188
|
|
|
|
|
|
|
my @plugins; |
|
189
|
149
|
|
33
|
|
|
804
|
|
|
190
|
|
|
|
|
|
|
my $file_regex = $self->{'file_regex'} || qr/\.pm$/; |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
|
|
193
|
149
|
|
|
|
|
256
|
# and each directory in our search path |
|
|
149
|
|
|
|
|
351
|
|
|
194
|
|
|
|
|
|
|
foreach my $searchpath (@{$self->{'search_path'}}) { |
|
195
|
149
|
|
|
|
|
1030
|
# create the search directory in a cross platform goodness way |
|
196
|
|
|
|
|
|
|
my $sp = catdir($dir, (split /::/, $searchpath)); |
|
197
|
|
|
|
|
|
|
|
|
198
|
149
|
100
|
66
|
|
|
2712
|
# if it doesn't exist or it's not a dir then skip it |
|
199
|
|
|
|
|
|
|
next unless ( -e $sp && -d _ ); # Use the cached stat the second time |
|
200
|
38
|
|
|
|
|
203
|
|
|
201
|
|
|
|
|
|
|
my @files = $self->find_files($sp); |
|
202
|
|
|
|
|
|
|
|
|
203
|
38
|
|
|
|
|
103
|
# foreach one we've found |
|
204
|
|
|
|
|
|
|
foreach my $file (@files) { |
|
205
|
124
|
50
|
|
|
|
914
|
# untaint the file; accept .pm only |
|
206
|
|
|
|
|
|
|
next unless ($file) = ($file =~ /(.*$file_regex)$/); |
|
207
|
124
|
|
|
|
|
2991
|
# parse the file to get the name |
|
208
|
|
|
|
|
|
|
my ($name, $directory, $suffix) = fileparse($file, $file_regex); |
|
209
|
124
|
50
|
33
|
|
|
668
|
|
|
210
|
|
|
|
|
|
|
next if (!$self->{include_editor_junk} && $self->_is_editor_junk($name)); |
|
211
|
124
|
|
|
|
|
435
|
|
|
212
|
|
|
|
|
|
|
$directory = abs2rel($directory, $sp); |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# If we have a mixed-case package name, assume case has been preserved |
|
215
|
|
|
|
|
|
|
# correctly. Otherwise, root through the file to locate the case-preserved |
|
216
|
124
|
|
|
|
|
331
|
# version of the package name. |
|
217
|
124
|
50
|
33
|
|
|
628
|
my @pkg_dirs = (); |
|
218
|
0
|
|
|
|
|
0
|
if ( $name eq lc($name) || $name eq uc($name) ) { |
|
219
|
0
|
0
|
|
|
|
0
|
my $pkg_file = catfile($sp, $directory, "$name$suffix"); |
|
220
|
0
|
|
|
|
|
0
|
open PKGFILE, "<$pkg_file" or die "search_paths: Can't open $pkg_file: $!"; |
|
221
|
0
|
|
|
|
|
0
|
my $in_pod = 0; |
|
222
|
0
|
0
|
|
|
|
0
|
while ( my $line = ) { |
|
223
|
0
|
0
|
|
|
|
0
|
$in_pod = 1 if $line =~ m/^=\w/; |
|
224
|
0
|
0
|
0
|
|
|
0
|
$in_pod = 0 if $line =~ /^=cut/; |
|
225
|
0
|
0
|
|
|
|
0
|
next if ($in_pod || $line =~ /^=cut/); # skip pod text |
|
226
|
0
|
0
|
|
|
|
0
|
next if $line =~ /^\s*#/; # and comments |
|
227
|
0
|
0
|
|
|
|
0
|
if ( $line =~ m/^\s*package\s+(.*::)?($name)\s*;/i ) { |
|
228
|
0
|
|
|
|
|
0
|
@pkg_dirs = split /::/, $1 if defined $1;; |
|
229
|
0
|
|
|
|
|
0
|
$name = $2; |
|
230
|
|
|
|
|
|
|
last; |
|
231
|
|
|
|
|
|
|
} |
|
232
|
0
|
|
|
|
|
0
|
} |
|
233
|
|
|
|
|
|
|
close PKGFILE; |
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
|
|
236
|
124
|
50
|
|
|
|
588
|
# then create the class name in a cross platform way |
|
237
|
124
|
|
|
|
|
231
|
$directory =~ s/^[a-z]://i if($^O =~ /MSWin32|dos/); # remove volume |
|
238
|
124
|
50
|
|
|
|
277
|
my @dirs = (); |
|
239
|
124
|
|
|
|
|
444
|
if ($directory) { |
|
240
|
124
|
100
|
|
|
|
373
|
($directory) = ($directory =~ /(.*)/); |
|
241
|
|
|
|
|
|
|
@dirs = grep(length($_), splitdir($directory)) |
|
242
|
124
|
|
|
|
|
282
|
unless $directory eq curdir(); |
|
243
|
11
|
|
|
|
|
30
|
for my $d (reverse @dirs) { |
|
244
|
11
|
50
|
|
|
|
30
|
my $pkg_dir = pop @pkg_dirs; |
|
245
|
0
|
|
|
|
|
0
|
last unless defined $pkg_dir; |
|
246
|
|
|
|
|
|
|
$d =~ s/\Q$pkg_dir\E/$pkg_dir/i; # Correct case |
|
247
|
|
|
|
|
|
|
} |
|
248
|
0
|
|
|
|
|
0
|
} else { |
|
249
|
|
|
|
|
|
|
$directory = ""; |
|
250
|
124
|
|
|
|
|
408
|
} |
|
251
|
|
|
|
|
|
|
my $plugin = join '::', $searchpath, @dirs, $name; |
|
252
|
124
|
50
|
|
|
|
447
|
|
|
253
|
|
|
|
|
|
|
next unless $plugin =~ m!(?:[a-z\d]+)[a-z\d]*!i; |
|
254
|
124
|
|
|
|
|
376
|
|
|
255
|
|
|
|
|
|
|
$self->handle_finding_plugin($plugin, \@plugins) |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
# now add stuff that may have been in package |
|
259
|
|
|
|
|
|
|
# NOTE we should probably use all the stuff we've been given already |
|
260
|
38
|
|
|
|
|
148
|
# but then we can't unload it :( |
|
261
|
|
|
|
|
|
|
push @plugins, $self->handle_innerpackages($searchpath); |
|
262
|
|
|
|
|
|
|
} # foreach $searchpath |
|
263
|
149
|
|
|
|
|
692
|
|
|
264
|
|
|
|
|
|
|
return @plugins; |
|
265
|
|
|
|
|
|
|
} |
|
266
|
|
|
|
|
|
|
|
|
267
|
124
|
|
|
124
|
|
238
|
sub _is_editor_junk { |
|
268
|
124
|
|
|
|
|
218
|
my $self = shift; |
|
269
|
|
|
|
|
|
|
my $name = shift; |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
# Emacs (and other Unix-y editors) leave temp files ending in a |
|
272
|
124
|
50
|
|
|
|
333
|
# tilde as a backup. |
|
273
|
|
|
|
|
|
|
return 1 if $name =~ /~$/; |
|
274
|
|
|
|
|
|
|
# Emacs makes these files while a buffer is edited but not yet |
|
275
|
124
|
50
|
|
|
|
275
|
# saved. |
|
276
|
|
|
|
|
|
|
return 1 if $name =~ /^\.#/; |
|
277
|
124
|
50
|
|
|
|
291
|
# Vim can leave these files behind if it crashes. |
|
278
|
|
|
|
|
|
|
return 1 if $name =~ /\.sw[po]$/; |
|
279
|
124
|
|
|
|
|
425
|
|
|
280
|
|
|
|
|
|
|
return 0; |
|
281
|
|
|
|
|
|
|
} |
|
282
|
|
|
|
|
|
|
|
|
283
|
346
|
|
|
346
|
0
|
532
|
sub handle_finding_plugin { |
|
284
|
346
|
|
|
|
|
513
|
my $self = shift; |
|
285
|
346
|
|
|
|
|
504
|
my $plugin = shift; |
|
286
|
346
|
|
100
|
|
|
778
|
my $plugins = shift; |
|
287
|
|
|
|
|
|
|
my $no_req = shift || 0; |
|
288
|
346
|
50
|
|
|
|
681
|
|
|
289
|
346
|
100
|
66
|
|
|
1228
|
return unless $self->_is_legit($plugin); |
|
290
|
13
|
|
|
|
|
27
|
unless (defined $self->{'instantiate'} || $self->{'require'}) { |
|
291
|
13
|
|
|
|
|
34
|
push @$plugins, $plugin; |
|
292
|
|
|
|
|
|
|
return; |
|
293
|
|
|
|
|
|
|
} |
|
294
|
333
|
50
|
0
|
|
|
640
|
|
|
295
|
333
|
100
|
|
|
|
622
|
$self->{before_require}->($plugin) || return if defined $self->{before_require}; |
|
296
|
111
|
|
|
|
|
177
|
unless ($no_req) { |
|
297
|
111
|
|
|
|
|
166
|
my $tmp = $@; |
|
|
111
|
|
|
|
|
354
|
|
|
298
|
111
|
|
|
|
|
2937
|
my $res = eval { require_module($plugin) }; |
|
299
|
111
|
|
|
|
|
168
|
my $err = $@; |
|
300
|
111
|
50
|
|
|
|
268
|
$@ = $tmp; |
|
301
|
0
|
0
|
|
|
|
0
|
if ($err) { |
|
302
|
0
|
0
|
|
|
|
0
|
if (defined $self->{on_require_error}) { |
|
303
|
|
|
|
|
|
|
$self->{on_require_error}->($plugin, $err) || return; |
|
304
|
0
|
|
|
|
|
0
|
} else { |
|
305
|
|
|
|
|
|
|
return; |
|
306
|
|
|
|
|
|
|
} |
|
307
|
|
|
|
|
|
|
} |
|
308
|
333
|
50
|
0
|
|
|
657
|
} |
|
309
|
333
|
|
|
|
|
826
|
$self->{after_require}->($plugin) || return if defined $self->{after_require}; |
|
310
|
|
|
|
|
|
|
push @$plugins, $plugin; |
|
311
|
|
|
|
|
|
|
} |
|
312
|
|
|
|
|
|
|
|
|
313
|
38
|
|
|
38
|
0
|
81
|
sub find_files { |
|
314
|
38
|
|
|
|
|
70
|
my $self = shift; |
|
315
|
38
|
|
33
|
|
|
237
|
my $search_path = shift; |
|
316
|
|
|
|
|
|
|
my $file_regex = $self->{'file_regex'} || qr/\.pm$/; |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
# find all the .pm files in it |
|
320
|
|
|
|
|
|
|
# this isn't perfect and won't find multiple plugins per file |
|
321
|
38
|
|
|
|
|
96
|
#my $cwd = Cwd::getcwd; |
|
322
|
|
|
|
|
|
|
my @files = (); |
|
323
|
38
|
|
|
|
|
66
|
{ # for the benefit of perl 5.6.1's Find, localize topic |
|
|
38
|
|
|
|
|
62
|
|
|
324
|
|
|
|
|
|
|
local $_; |
|
325
|
|
|
|
|
|
|
File::Find::find( { no_chdir => 1, |
|
326
|
|
|
|
|
|
|
follow => $self->{'follow_symlinks'}, |
|
327
|
|
|
|
|
|
|
wanted => sub { |
|
328
|
168
|
100
|
|
168
|
|
5692
|
# Inlined from File::Find::Rule C< name => '*.pm' > |
|
329
|
124
|
|
|
|
|
314
|
return unless $File::Find::name =~ /$file_regex/; |
|
330
|
124
|
|
|
|
|
2987
|
(my $path = $File::Find::name) =~ s#^\\./##; |
|
331
|
|
|
|
|
|
|
push @files, $path; |
|
332
|
38
|
|
|
|
|
4602
|
} |
|
333
|
|
|
|
|
|
|
}, $search_path ); |
|
334
|
|
|
|
|
|
|
} |
|
335
|
38
|
|
|
|
|
325
|
#chdir $cwd; |
|
336
|
|
|
|
|
|
|
return @files; |
|
337
|
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
} |
|
339
|
|
|
|
|
|
|
|
|
340
|
38
|
|
|
38
|
0
|
83
|
sub handle_inc_hooks { |
|
341
|
38
|
|
|
|
|
66
|
my $self = shift; |
|
342
|
38
|
|
|
|
|
104
|
my $path = shift; |
|
343
|
|
|
|
|
|
|
my @SEARCHDIR = @_; |
|
344
|
38
|
|
|
|
|
51
|
|
|
345
|
38
|
|
|
|
|
71
|
my @plugins; |
|
346
|
149
|
50
|
33
|
|
|
345
|
for my $dir ( @SEARCHDIR ) { |
|
|
0
|
|
|
|
|
0
|
|
|
347
|
|
|
|
|
|
|
next unless ref $dir && eval { $dir->can( 'files' ) }; |
|
348
|
0
|
|
|
|
|
0
|
|
|
349
|
0
|
|
|
|
|
0
|
foreach my $plugin ( $dir->files ) { |
|
350
|
0
|
|
|
|
|
0
|
$plugin =~ s/\.pm$//; |
|
351
|
0
|
0
|
|
|
|
0
|
$plugin =~ s{/}{::}g; |
|
352
|
0
|
|
|
|
|
0
|
next unless $plugin =~ m!^${path}::!; |
|
353
|
|
|
|
|
|
|
$self->handle_finding_plugin( $plugin, \@plugins ); |
|
354
|
|
|
|
|
|
|
} |
|
355
|
38
|
|
|
|
|
135
|
} |
|
356
|
|
|
|
|
|
|
return @plugins; |
|
357
|
|
|
|
|
|
|
} |
|
358
|
|
|
|
|
|
|
|
|
359
|
76
|
|
|
76
|
0
|
124
|
sub handle_innerpackages { |
|
360
|
76
|
50
|
33
|
|
|
227
|
my $self = shift; |
|
361
|
|
|
|
|
|
|
return () if (exists $self->{inner} && !$self->{inner}); |
|
362
|
76
|
|
|
|
|
126
|
|
|
363
|
76
|
|
|
|
|
132
|
my $path = shift; |
|
364
|
|
|
|
|
|
|
my @plugins; |
|
365
|
76
|
|
|
|
|
245
|
|
|
366
|
222
|
|
|
|
|
496
|
foreach my $plugin (Devel::InnerPackage::list_packages($path)) { |
|
367
|
|
|
|
|
|
|
$self->handle_finding_plugin($plugin, \@plugins, 1); |
|
368
|
76
|
|
|
|
|
267
|
} |
|
369
|
|
|
|
|
|
|
return @plugins; |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
} |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
1; |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
#line 428 |
|
376
|
|
|
|
|
|
|
|