line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Factory::Util; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6659
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Carp qw(confess); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
66
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '1.7'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
1; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import |
13
|
|
|
|
|
|
|
{ |
14
|
1
|
|
|
1
|
|
9
|
my $caller = caller(0); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
{ |
17
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
357
|
|
|
1
|
|
|
|
|
2
|
|
18
|
1
|
|
|
|
|
1
|
*{"${caller}::subclasses"} = \&_subclasses; |
|
1
|
|
|
|
|
20
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# deprecated |
23
|
0
|
|
|
0
|
0
|
0
|
sub subclasses { _subclasses(@_) } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _subclasses |
26
|
|
|
|
|
|
|
{ |
27
|
1
|
|
|
1
|
|
717
|
my $base = shift; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
4
|
$base =~ s,::,/,g; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
3
|
my %dirs = map { $_ => 1 } @INC; |
|
12
|
|
|
|
|
32
|
|
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
10
|
my $dir = substr( $INC{"$base.pm"}, 0, (length $INC{"$base.pm"}) - 3 ); |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
3
|
$dirs{$dir} = 1; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
4
|
my @packages = map { _scandir( "$_/$base" ) } keys %dirs; |
|
13
|
|
|
|
|
48
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Make list of unique elements |
40
|
1
|
|
|
|
|
4
|
my %packages = map { $_ => 1 } @packages; |
|
3
|
|
|
|
|
10
|
|
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
11
|
return sort keys %packages; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _scandir |
46
|
|
|
|
|
|
|
{ |
47
|
13
|
|
|
13
|
|
18
|
my $dir = shift; |
48
|
|
|
|
|
|
|
|
49
|
13
|
100
|
|
|
|
281
|
return unless -d $dir; |
50
|
|
|
|
|
|
|
|
51
|
2
|
50
|
|
|
|
50
|
opendir DIR, $dir |
52
|
|
|
|
|
|
|
or confess ("Cannot open directory $dir: $!"); |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
10
|
my @packages = |
55
|
7
|
100
|
|
|
|
74
|
( map { substr($_, 0, length($_) - 3) } |
56
|
2
|
|
|
|
|
34
|
grep { substr($_, -3) eq '.pm' && -f "$dir/$_" } |
57
|
|
|
|
|
|
|
readdir DIR |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
2
|
50
|
|
|
|
29
|
closedir DIR |
61
|
|
|
|
|
|
|
or confess("Cannot close directory $dir: $!" ); |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
11
|
return @packages; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |