line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Morpheus::Overrides; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Morpheus::Overrides::VERSION = '0.46'; |
4
|
|
|
|
|
|
|
} |
5
|
4
|
|
|
4
|
|
25
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
155
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: plugin for overriding configuration from perl code |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
1660
|
use Morpheus::Utils qw(merge normalize); |
|
4
|
|
|
|
|
172
|
|
|
4
|
|
|
|
|
1717
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $cache = {}; |
12
|
|
|
|
|
|
|
sub cache { |
13
|
145
|
|
|
145
|
0
|
244
|
return $cache; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub import ($$) { |
17
|
23
|
|
|
23
|
|
52
|
my ($class, $patch) = @_; |
18
|
23
|
100
|
|
|
|
876
|
return unless $patch; |
19
|
7
|
50
|
|
|
|
33
|
die "unexpected $patch" unless ref $patch eq "HASH"; |
20
|
7
|
|
|
|
|
42
|
my $cache = $class->cache(); |
21
|
7
|
|
|
|
|
15
|
push @{$cache->{list}}, $patch; |
|
7
|
|
|
|
|
48
|
|
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub list ($$) { |
25
|
288
|
|
|
288
|
0
|
1393
|
return ('' => ''); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub get ($$) { |
29
|
288
|
|
|
288
|
0
|
522
|
my ($class, $ns) = @_; |
30
|
288
|
50
|
|
|
|
887
|
die "mystery" if $ns; |
31
|
|
|
|
|
|
|
|
32
|
288
|
|
|
|
|
776
|
my $cache = $class->cache(); |
33
|
288
|
|
100
|
|
|
905
|
while($cache->{list} and @{$cache->{list}}) { |
|
253
|
|
|
|
|
1038
|
|
34
|
7
|
|
|
|
|
26
|
my $patch = shift @{$cache->{list}}; |
|
7
|
|
|
|
|
22
|
|
35
|
7
|
|
|
|
|
26
|
$patch = normalize($patch); |
36
|
7
|
|
|
|
|
31
|
$cache->{data} = merge($cache->{data}, $patch); |
37
|
|
|
|
|
|
|
} |
38
|
288
|
|
|
|
|
1171
|
return $cache->{data}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |