line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::LNPath; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
111718
|
use 5.006; |
|
2
|
|
|
|
|
13
|
|
4
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
32
|
|
5
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
99
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
773
|
use YAML::XS qw/LoadFile/; |
|
2
|
|
|
|
|
4698
|
|
|
2
|
|
|
|
|
101
|
|
10
|
2
|
|
|
|
|
12
|
use Data::LNPath qw/lnpath/, { |
11
|
|
|
|
|
|
|
return_undef => 1 |
12
|
2
|
|
|
2
|
|
782
|
}; |
|
2
|
|
|
|
|
2932
|
|
13
|
2
|
|
|
2
|
|
113
|
use Carp qw/croak/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
83
|
|
14
|
2
|
|
|
2
|
|
760
|
use Blessed::Merge; |
|
2
|
|
|
|
|
32074
|
|
|
2
|
|
|
|
|
453
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
4
|
|
100
|
4
|
1
|
598
|
my $self = bless $_[1] // {}, $_[0]; |
18
|
4
|
100
|
|
|
|
155
|
croak "no config path passed to new" unless $self->{config}; |
19
|
3
|
100
|
|
|
|
16
|
my $blessed = Blessed::Merge->new({ blessed => 0, ($self->{merge} ? %{ $self->{merge} } : ()) }); |
|
1
|
|
|
|
|
6
|
|
20
|
|
|
|
|
|
|
$self->{data} = ref $self->{config} eq 'ARRAY' |
21
|
4
|
|
|
|
|
248
|
? $blessed->merge(map { LoadFile($_) } @{ $self->{config} }) |
|
2
|
|
|
|
|
6
|
|
22
|
3
|
100
|
|
|
|
60
|
: LoadFile($self->{config}); |
23
|
3
|
100
|
|
|
|
505
|
$self->{data} = $self->{data}->{$self->{section}} if $self->{section}; |
24
|
3
|
|
|
|
|
26
|
$self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub find { |
28
|
9
|
100
|
|
9
|
1
|
32
|
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
|
637
|
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__ |