| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::MockFile::Plugins; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
63
|
use strict; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
338
|
|
|
4
|
7
|
|
|
7
|
|
48
|
use warnings; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
3197
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.037'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @NAMESPACES = (q[Test::MockFile::Plugin]); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub load_plugin { |
|
11
|
7
|
|
|
7
|
1
|
21
|
my ($name_or_array) = @_; |
|
12
|
|
|
|
|
|
|
|
|
13
|
7
|
100
|
|
|
|
30
|
my $list = ref $name_or_array ? $name_or_array : [$name_or_array]; |
|
14
|
|
|
|
|
|
|
|
|
15
|
7
|
|
|
|
|
15
|
my @plugins; |
|
16
|
7
|
|
|
|
|
22
|
foreach my $name (@$list) { |
|
17
|
7
|
|
|
|
|
23
|
push @plugins, _load_plugin($name); |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
6
|
|
|
|
|
61
|
return @plugins; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _load_plugin { |
|
24
|
7
|
|
|
7
|
|
14
|
my ($name) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
7
|
|
|
|
|
21
|
my @candidates = map { "${_}::$name" } @NAMESPACES; |
|
|
8
|
|
|
|
|
34
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
7
|
|
|
|
|
14
|
foreach my $c (@candidates) { |
|
29
|
8
|
100
|
|
|
|
27
|
next unless _load($c); |
|
30
|
|
|
|
|
|
|
|
|
31
|
6
|
|
|
|
|
48
|
my $plugin = $c->new(); |
|
32
|
6
|
|
|
|
|
24
|
return $plugin->register; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
718
|
die qq[Cannot find a Test::MockFile plugin for $name]; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _load { |
|
39
|
8
|
|
|
8
|
|
16
|
my ($pkg) = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
8
|
100
|
|
|
|
2005
|
return unless eval qq{ require $pkg; 1 }; |
|
42
|
|
|
|
|
|
|
|
|
43
|
6
|
|
|
|
|
100
|
return $pkg->isa('Test::MockFile::Plugin'); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=encoding utf8 |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Test::MockFile::Plugins - Plugin loader |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
use Test::MockFile::Plugins; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
unshift @Test::MockFile::Plugins::NAMESPACES, q[Your::NameSpace]; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Test::MockFile::Plugins::load_plugins( 'YourPlugin' ); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
L is responsible for loading plugins. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
BETA WARNING: This is a preliminary plugins implementation. It might |
|
67
|
|
|
|
|
|
|
change in the future. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 METHODS |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 load_plugin( $plugin_name ) |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Test::MockFile::Plugins::load_plugin( 'YourPlugin' ); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L, L |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |