line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::PluginManager; |
2
|
|
|
|
|
|
|
$Mason::PluginManager::VERSION = '2.24'; |
3
|
20
|
|
|
85
|
|
117
|
use Carp; |
|
20
|
|
|
|
|
48
|
|
|
20
|
|
|
|
|
1617
|
|
4
|
20
|
|
|
50
|
|
94
|
use Log::Any qw($log); |
|
20
|
|
|
|
|
32
|
|
|
20
|
|
|
|
|
170
|
|
5
|
20
|
|
|
50
|
|
1638
|
use Mason::Moose; |
|
20
|
|
|
|
|
34
|
|
|
20
|
|
|
|
|
143
|
|
6
|
20
|
|
|
50
|
|
32167
|
use Mason::Util qw(can_load uniq); |
|
20
|
|
|
|
|
38
|
|
|
20
|
|
|
|
|
1978
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my ( %apply_plugins_cache, %final_subclass_seen ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# CLASS METHODS |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $depth; |
14
|
|
|
|
|
|
|
our %visited; |
15
|
|
|
|
|
|
|
my $max_depth = 16; |
16
|
|
|
|
|
|
|
|
17
|
20
|
|
|
50
|
|
7357
|
method process_top_plugin_specs ($class: $plugin_specs) { |
|
111
|
|
|
111
|
|
259
|
|
|
111
|
|
|
|
|
207
|
|
|
111
|
|
|
|
|
160
|
|
18
|
111
|
|
|
|
|
288
|
local $depth = 0; |
19
|
111
|
|
|
|
|
372
|
local %visited = (); |
20
|
|
|
|
|
|
|
|
21
|
111
|
|
|
|
|
414
|
my @positive_plugin_specs = grep { !/^\-/ } @$plugin_specs; |
|
17
|
|
|
|
|
57
|
|
22
|
111
|
|
|
|
|
366
|
my @negative_plugin_specs = map { substr( $_, 1 ) } grep { /^\-/ } @$plugin_specs; |
|
3
|
|
|
|
|
7
|
|
|
17
|
|
|
|
|
40
|
|
23
|
111
|
|
|
|
|
276
|
push( @positive_plugin_specs, '@Default' ); |
24
|
7
|
|
|
|
|
12
|
my %exclude_plugin_modules = |
25
|
111
|
|
|
|
|
594
|
map { ( $_, 1 ) } $class->process_plugin_specs( \@negative_plugin_specs ); |
26
|
|
|
|
|
|
|
|
27
|
242
|
|
|
|
|
728
|
my @modules = |
28
|
111
|
|
|
|
|
362
|
grep { !$exclude_plugin_modules{$_} } $class->process_plugin_specs( \@positive_plugin_specs ); |
29
|
|
|
|
|
|
|
|
30
|
109
|
|
|
|
|
566
|
return @modules; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
20
|
|
|
50
|
|
9880
|
method process_plugin_specs ($class: $plugin_specs) { |
|
600
|
|
|
600
|
|
835
|
|
|
600
|
|
|
|
|
1060
|
|
|
600
|
|
|
|
|
773
|
|
34
|
600
|
|
|
|
|
1006
|
local $depth = $depth + 1; |
35
|
600
|
|
|
|
|
2290
|
local %visited = %visited; |
36
|
600
|
50
|
|
|
|
1637
|
die ">$max_depth levels deep in process_plugins_list (plugin cycle?)" if $depth >= $max_depth; |
37
|
600
|
50
|
|
|
|
1574
|
croak 'plugins must be an array reference' unless ref($plugin_specs) eq 'ARRAY'; |
38
|
600
|
|
|
|
|
1591
|
my @modules = ( uniq( map { $class->process_plugin_spec($_) } @$plugin_specs ) ); |
|
382
|
|
|
|
|
1110
|
|
39
|
598
|
|
|
|
|
1926
|
return @modules; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
20
|
|
|
50
|
|
8158
|
method process_plugin_spec ($class: $plugin_spec) { |
|
382
|
|
|
382
|
|
522
|
|
|
382
|
|
|
|
|
599
|
|
|
382
|
|
|
|
|
476
|
|
43
|
382
|
|
|
|
|
1066
|
my $module = $class->plugin_spec_to_module($plugin_spec); |
44
|
380
|
100
|
|
|
|
3399
|
my @modules = !$visited{$module}++ ? $module->expand_to_plugins : (); |
45
|
380
|
|
|
|
|
1261
|
return @modules; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
20
|
|
|
20
|
|
7066
|
method plugin_spec_to_module ($class: $plugin_spec) { |
|
382
|
|
|
382
|
|
520
|
|
|
382
|
|
|
|
|
464
|
|
|
382
|
|
|
|
|
427
|
|
49
|
382
|
100
|
|
|
|
2143
|
my $module = |
|
|
100
|
|
|
|
|
|
50
|
|
|
|
|
|
|
substr( $plugin_spec, 0, 1 ) eq '+' ? ( substr( $plugin_spec, 1 ) ) |
51
|
|
|
|
|
|
|
: substr( $plugin_spec, 0, 1 ) eq '@' |
52
|
|
|
|
|
|
|
? ( "Mason::PluginBundle::" . substr( $plugin_spec, 1 ) ) |
53
|
|
|
|
|
|
|
: "Mason::Plugin::$plugin_spec"; |
54
|
382
|
100
|
|
|
|
986
|
return can_load($module) |
55
|
|
|
|
|
|
|
? $module |
56
|
|
|
|
|
|
|
: die "could not load '$module' for plugin spec '$plugin_spec'"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
20
|
|
|
20
|
|
7573
|
method apply_plugins_to_class ($class: $base_subclass, $name, $plugins) { |
|
734
|
|
|
734
|
|
1788
|
|
|
734
|
|
|
|
|
1682
|
|
|
734
|
|
|
|
|
1613
|
|
60
|
734
|
|
|
|
|
1469
|
my $subclass; |
61
|
734
|
|
|
|
|
2918
|
my $key = join( ",", $base_subclass, @$plugins ); |
62
|
734
|
100
|
|
|
|
18280
|
return $apply_plugins_cache{$key} if defined( $apply_plugins_cache{$key} ); |
63
|
|
|
|
|
|
|
|
64
|
206
|
|
|
|
|
279
|
my $final_subclass; |
65
|
206
|
|
|
|
|
514
|
my @roles = map { $_->get_roles_for_mason_class($name) } @$plugins; |
|
467
|
|
|
|
|
2841
|
|
66
|
206
|
100
|
|
|
|
606
|
if (@roles) { |
67
|
74
|
|
|
|
|
926
|
my $meta = Moose::Meta::Class->create_anon_class( |
68
|
|
|
|
|
|
|
superclasses => [$base_subclass], |
69
|
|
|
|
|
|
|
roles => \@roles, |
70
|
|
|
|
|
|
|
cache => 1 |
71
|
|
|
|
|
|
|
); |
72
|
74
|
|
|
|
|
319979
|
$final_subclass = $meta->name; |
73
|
180
|
|
|
180
|
|
1156
|
$meta->add_method( 'meta' => sub { $meta } ) |
|
|
|
|
180
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
178
|
|
|
|
74
|
74
|
100
|
|
|
|
834
|
if !$final_subclass_seen{$final_subclass}++; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else { |
77
|
132
|
|
|
|
|
264
|
$final_subclass = $base_subclass; |
78
|
|
|
|
|
|
|
} |
79
|
206
|
50
|
|
|
|
4869
|
$log->debugf( "apply_plugins - base_subclass=%s, name=%s, plugins=%s, roles=%s - %s", |
80
|
|
|
|
|
|
|
$base_subclass, $name, $plugins, \@roles, $final_subclass ) |
81
|
|
|
|
|
|
|
if $log->is_debug; |
82
|
|
|
|
|
|
|
|
83
|
206
|
100
|
|
|
|
3734
|
$final_subclass->meta->make_immutable if $final_subclass->can('meta'); |
84
|
|
|
|
|
|
|
|
85
|
206
|
|
|
|
|
24323
|
$apply_plugins_cache{$key} = $final_subclass; |
86
|
206
|
|
|
|
|
6422
|
return $final_subclass; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |