line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
10
|
|
|
10
|
|
271
|
use 5.008; |
|
10
|
|
|
|
|
41
|
|
|
10
|
|
|
|
|
376
|
|
2
|
10
|
|
|
10
|
|
53
|
use strict; |
|
10
|
|
|
|
|
37
|
|
|
10
|
|
|
|
|
304
|
|
3
|
10
|
|
|
10
|
|
52
|
use warnings; |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
537
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Hook::Modular::ConfigLoader; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
10
|
|
|
10
|
|
206
|
$Hook::Modular::ConfigLoader::VERSION = '1.101050'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: Configuration loader for Hook::Modular |
10
|
10
|
|
|
10
|
|
55
|
use Carp; |
|
10
|
|
|
|
|
30
|
|
|
10
|
|
|
|
|
760
|
|
11
|
10
|
|
|
10
|
|
8110
|
use Hook::Modular::Walker; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
106
|
|
12
|
10
|
|
|
10
|
|
993
|
use YAML; |
|
10
|
|
|
|
|
10810
|
|
|
10
|
|
|
|
|
965
|
|
13
|
10
|
|
|
10
|
|
12721
|
use Storable; |
|
10
|
|
|
|
|
79711
|
|
|
10
|
|
|
|
|
8582
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
12
|
|
|
12
|
1
|
34
|
my $class = shift; |
17
|
12
|
|
|
|
|
56
|
bless {}, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub load { |
21
|
12
|
|
|
12
|
1
|
32
|
my ($self, $stuff, $context) = @_; |
22
|
12
|
|
|
|
|
23
|
my $config; |
23
|
12
|
100
|
66
|
|
|
774
|
if ( (!ref($stuff) && $stuff eq '-') |
|
|
100
|
66
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
24
|
|
|
|
|
|
|
|| (-e $stuff && -r _)) { |
25
|
7
|
|
|
|
|
66
|
$config = YAML::LoadFile($stuff); |
26
|
7
|
50
|
|
|
|
68896
|
$context->{config_path} = $stuff if $context; |
27
|
|
|
|
|
|
|
} elsif (ref($stuff) && ref $stuff eq 'SCALAR') { |
28
|
2
|
|
|
|
|
7
|
$config = YAML::Load(${$stuff}); |
|
2
|
|
|
|
|
16
|
|
29
|
|
|
|
|
|
|
} elsif (ref($stuff) && ref $stuff eq 'HASH') { |
30
|
3
|
|
|
|
|
386
|
$config = Storable::dclone($stuff); |
31
|
|
|
|
|
|
|
} else { |
32
|
0
|
|
|
|
|
0
|
croak "Hook::Modular::ConfigLoader->load: $stuff: $!"; |
33
|
|
|
|
|
|
|
} |
34
|
12
|
50
|
33
|
|
|
47458
|
unless ($config->{global} && $config->{global}->{no_decode_utf8}) { |
35
|
12
|
|
|
|
|
131
|
Hook::Modular::Walker->decode_utf8($config); |
36
|
|
|
|
|
|
|
} |
37
|
12
|
|
|
|
|
66
|
return $config; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub load_include { |
41
|
12
|
|
|
12
|
1
|
36
|
my ($self, $config) = @_; |
42
|
12
|
50
|
|
|
|
71
|
my $includes = $config->{include} or return; |
43
|
0
|
0
|
|
|
|
0
|
$includes = [$includes] unless ref $includes; |
44
|
0
|
|
|
|
|
0
|
for my $file (@$includes) { |
45
|
0
|
|
|
|
|
0
|
my $include = YAML::LoadFile($file); |
46
|
0
|
|
|
|
|
0
|
for my $key (keys %{$include}) { |
|
0
|
|
|
|
|
0
|
|
47
|
0
|
|
|
|
|
0
|
my $add = $include->{$key}; |
48
|
0
|
0
|
|
|
|
0
|
unless ($config->{$key}) { |
49
|
0
|
|
|
|
|
0
|
$config->{$key} = $add; |
50
|
0
|
|
|
|
|
0
|
next; |
51
|
|
|
|
|
|
|
} |
52
|
0
|
0
|
|
|
|
0
|
if (ref $config->{$key} eq 'HASH') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
0
|
next unless ref $add eq 'HASH'; |
54
|
0
|
|
|
|
|
0
|
for (keys %{ $include->{$key} }) { |
|
0
|
|
|
|
|
0
|
|
55
|
0
|
|
|
|
|
0
|
$config->{$key}->{$_} = $include->{$key}->{$_}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} elsif (ref $include->{$key} eq 'ARRAY') { |
58
|
0
|
0
|
|
|
|
0
|
$add = [$add] unless ref $add eq 'ARRAY'; |
59
|
0
|
|
|
|
|
0
|
push(@{ $config->{$key} }, @{ $include->{$key} }); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
} elsif ($add) { |
61
|
0
|
|
|
|
|
0
|
$config->{$key} = $add; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub load_recipes { |
68
|
12
|
|
|
12
|
1
|
33
|
my ($self, $config) = @_; |
69
|
12
|
|
|
|
|
25
|
for (@{ $config->{recipes} }) { |
|
12
|
|
|
|
|
362
|
|
70
|
0
|
0
|
|
|
|
|
$self->error("no such recipe to $_") |
71
|
|
|
|
|
|
|
unless $config->{define_recipes}->{$_}; |
72
|
0
|
|
|
|
|
|
my $plugin = $config->{define_recipes}->{$_}; |
73
|
0
|
0
|
|
|
|
|
$plugin = [$plugin] unless ref $plugin eq 'ARRAY'; |
74
|
0
|
|
|
|
|
|
push(@{ $config->{plugins} }, @{$plugin}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |