line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Setup::Flavor; |
2
|
28
|
|
|
28
|
|
4427
|
use strict; |
|
28
|
|
|
|
|
40
|
|
|
28
|
|
|
|
|
708
|
|
3
|
28
|
|
|
28
|
|
101
|
use warnings; |
|
28
|
|
|
|
|
39
|
|
|
28
|
|
|
|
|
635
|
|
4
|
|
|
|
|
|
|
|
5
|
28
|
|
|
28
|
|
103
|
use Carp (); |
|
28
|
|
|
|
|
38
|
|
|
28
|
|
|
|
|
317
|
|
6
|
28
|
|
|
28
|
|
16857
|
use Storable (); |
|
28
|
|
|
|
|
81414
|
|
|
28
|
|
|
|
|
721
|
|
7
|
28
|
|
|
28
|
|
202
|
use YAML (); |
|
28
|
|
|
|
|
42
|
|
|
28
|
|
|
|
|
17125
|
|
8
|
|
|
|
|
|
|
|
9
|
54
|
|
|
54
|
0
|
15040
|
sub new { bless {}, shift } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my %data_cache; |
12
|
|
|
|
|
|
|
sub loader { |
13
|
66
|
|
|
66
|
0
|
118
|
my $self = shift; |
14
|
66
|
|
|
|
|
142
|
my $class = ref($self); |
15
|
66
|
100
|
|
|
|
188
|
$class = $self unless $class; |
16
|
|
|
|
|
|
|
|
17
|
66
|
100
|
|
|
|
240
|
unless ($data_cache{$class}) { |
18
|
40
|
|
|
|
|
151
|
local $/; |
19
|
40
|
|
|
|
|
2880
|
my $data = eval "package $class; "; ## no critic |
20
|
40
|
100
|
|
|
|
347
|
Carp::croak "flavor template class is invalid: $class" unless $data; |
21
|
|
|
|
|
|
|
|
22
|
39
|
|
|
|
|
301
|
my @template = YAML::Load(join '', $data); |
23
|
39
|
100
|
100
|
|
|
742093
|
if (scalar(@template) == 1 && !defined $template[0]) { |
24
|
1
|
|
|
|
|
5
|
$data_cache{$class} = []; |
25
|
|
|
|
|
|
|
} else { |
26
|
38
|
|
|
|
|
259
|
$data_cache{$class} = \@template; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
}; |
29
|
65
|
|
|
|
|
111
|
@{ Storable::dclone($data_cache{$class}) }; |
|
65
|
|
|
|
|
5662
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _import_template { |
33
|
7
|
|
|
7
|
|
14
|
my($self, $base_class, $args) = @_; |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
|
|
|
533
|
eval "require $base_class"; ## no critic |
36
|
7
|
100
|
|
|
|
586
|
Carp::croak $@ if $@; |
37
|
|
|
|
|
|
|
|
38
|
6
|
|
|
|
|
42
|
my @base_template = $base_class->loader; |
39
|
6
|
|
|
|
|
16
|
my @template; |
40
|
|
|
|
|
|
|
LOOP: |
41
|
6
|
|
|
|
|
18
|
for my $tmpl (@base_template) { |
42
|
44
|
100
|
|
|
|
122
|
if (exists $tmpl->{config}) { |
43
|
5
|
100
|
|
|
|
20
|
$args->{template_config} = $tmpl unless $args->{template_config}; |
44
|
5
|
|
|
|
|
12
|
next; |
45
|
|
|
|
|
|
|
} |
46
|
39
|
|
|
|
|
49
|
for my $type (qw/ file plugin dir /) { |
47
|
55
|
100
|
|
|
|
100
|
next unless exists $tmpl->{$type}; |
48
|
37
|
|
|
|
|
74
|
my $key = "$type - $tmpl->{$type}"; |
49
|
37
|
100
|
|
|
|
118
|
next LOOP if $args->{template_loaded}->{$key}++; |
50
|
36
|
|
|
|
|
55
|
my $template = delete $args->{template_index}->{$key}; |
51
|
36
|
100
|
|
|
|
60
|
$template = $tmpl unless $template; |
52
|
36
|
|
|
|
|
44
|
push @template, $template; |
53
|
36
|
|
|
|
|
57
|
next LOOP; |
54
|
|
|
|
|
|
|
} |
55
|
2
|
|
|
|
|
5
|
push @template, $tmpl; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
6
|
|
|
|
|
39
|
@template; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub import_template { |
62
|
6
|
|
|
6
|
0
|
21
|
my($self, @base_classes) = @_; |
63
|
6
|
|
|
|
|
13
|
my $class = ref($self); |
64
|
|
|
|
|
|
|
|
65
|
6
|
|
|
|
|
22
|
my @local_template = loader($self); |
66
|
|
|
|
|
|
|
|
67
|
6
|
|
|
|
|
12
|
my %template_index; |
68
|
|
|
|
|
|
|
my $template_config; |
69
|
6
|
|
|
|
|
15
|
my $anthor_key_count = 0; |
70
|
|
|
|
|
|
|
LOOP: |
71
|
6
|
|
|
|
|
19
|
for my $tmpl (@local_template) { |
72
|
13
|
100
|
|
|
|
27
|
if (exists $tmpl->{config}) { |
73
|
2
|
|
|
|
|
3
|
$template_config = $tmpl; |
74
|
2
|
|
|
|
|
1
|
next; |
75
|
|
|
|
|
|
|
} |
76
|
11
|
|
|
|
|
19
|
for my $type (qw/ file plugin dir /) { |
77
|
21
|
100
|
|
|
|
38
|
next unless exists $tmpl->{$type}; |
78
|
9
|
|
|
|
|
31
|
$template_index{"$type - $tmpl->{$type}"} = $tmpl; |
79
|
9
|
|
|
|
|
21
|
next LOOP; |
80
|
|
|
|
|
|
|
} |
81
|
2
|
|
|
|
|
5
|
$template_index{'anthor - ' . $anthor_key_count++} = $tmpl; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
6
|
|
|
|
|
26
|
my $args = { |
85
|
|
|
|
|
|
|
template_config => $template_config, |
86
|
|
|
|
|
|
|
template_index => \%template_index, |
87
|
|
|
|
|
|
|
}; |
88
|
6
|
|
|
|
|
10
|
my @template; |
89
|
6
|
|
|
|
|
12
|
for my $base_class (reverse @base_classes) { |
90
|
7
|
|
|
|
|
63
|
push @template, $self->_import_template($base_class, $args); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
5
|
|
|
|
|
8
|
for my $tmpl (values %{ $args->{template_index} }) { |
|
5
|
|
|
|
|
22
|
|
94
|
2
|
|
|
|
|
5
|
push @template, $tmpl; |
95
|
|
|
|
|
|
|
} |
96
|
5
|
100
|
|
|
|
28
|
push @template, $args->{template_config} if $args->{template_config}; |
97
|
|
|
|
|
|
|
|
98
|
5
|
|
|
|
|
50
|
@template; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
46
|
|
|
46
|
1
|
216
|
sub setup_flavor { 1 } |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub setup_config { |
104
|
11
|
|
|
11
|
0
|
37
|
my($self, $context, $config) = @_; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub setup_additional { |
108
|
5
|
|
|
5
|
0
|
16
|
my($self, $context, $config) = @_; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 NAME |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Module::Setup::Flavor - Module::Setup Flavor |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 Flavor Hook Point |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 setup_flavor |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
flavor setup, if return value is false is exit create flavor |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 setup_config |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
before flavors plugin load |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 setup_additional |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
end of additional flavor install |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
__DATA__ |