line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::LNPath; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
139658
|
use 5.006; |
|
2
|
|
|
|
|
17
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
39
|
|
5
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
121
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1010
|
use YAML::XS qw/LoadFile/; |
|
2
|
|
|
|
|
5970
|
|
|
2
|
|
|
|
|
126
|
|
10
|
2
|
|
|
|
|
14
|
use Data::LNPath qw/lnpath/, { |
11
|
|
|
|
|
|
|
return_undef => 1 |
12
|
2
|
|
|
2
|
|
1011
|
}; |
|
2
|
|
|
|
|
3626
|
|
13
|
2
|
|
|
2
|
|
166
|
use Carp qw/croak/; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
95
|
|
14
|
2
|
|
|
2
|
|
1000
|
use Blessed::Merge; |
|
2
|
|
|
|
|
52268
|
|
|
2
|
|
|
|
|
548
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
4
|
|
100
|
4
|
1
|
828
|
my $self = bless $_[1] // {}, $_[0]; |
18
|
4
|
100
|
|
|
|
229
|
croak "no config path passed to new" unless $self->{config}; |
19
|
3
|
100
|
|
|
|
23
|
my $blessed = Blessed::Merge->new({ blessed => 0, ($self->{merge} ? %{ $self->{merge} } : ()) }); |
|
1
|
|
|
|
|
7
|
|
20
|
|
|
|
|
|
|
$self->{data} = ref $self->{config} eq 'ARRAY' |
21
|
4
|
|
|
|
|
317
|
? $blessed->merge(map { LoadFile($_) } @{ $self->{config} }) |
|
2
|
|
|
|
|
7
|
|
22
|
3
|
100
|
|
|
|
86
|
: LoadFile($self->{config}); |
23
|
3
|
100
|
|
|
|
844
|
$self->{data} = $self->{data}->{$self->{section}} if $self->{section}; |
24
|
3
|
|
|
|
|
18
|
$self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub find { |
28
|
9
|
100
|
|
9
|
1
|
42
|
lnpath($_[0]->{data}, $_[1]) |
29
|
|
|
|
|
|
|
or croak sprintf "Could not find value from config using path -> %s", $_[1]; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub section_find { |
33
|
3
|
100
|
|
3
|
1
|
772
|
lnpath($_[0]->{data}->{$_[1]}, $_[2]) |
34
|
|
|
|
|
|
|
or croak sprintf "Could not find value from config section -> %s", $_[1]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; # End of Config::LNPath |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |