line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::LNPath; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
132684
|
use 5.006; |
|
2
|
|
|
|
|
17
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
38
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
126
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
876
|
use YAML::XS qw/LoadFile/; |
|
2
|
|
|
|
|
5682
|
|
|
2
|
|
|
|
|
126
|
|
10
|
2
|
|
|
|
|
15
|
use Data::LNPath qw/lnpath/, { |
11
|
|
|
|
|
|
|
return_undef => 1 |
12
|
2
|
|
|
2
|
|
901
|
}; |
|
2
|
|
|
|
|
3529
|
|
13
|
2
|
|
|
2
|
|
153
|
use Carp qw/croak/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
92
|
|
14
|
2
|
|
|
2
|
|
899
|
use Blessed::Merge; |
|
2
|
|
|
|
|
38530
|
|
|
2
|
|
|
|
|
538
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
4
|
|
100
|
4
|
1
|
736
|
my $self = bless $_[1] // {}, $_[0]; |
18
|
4
|
100
|
|
|
|
195
|
croak "no config path passed to new" unless $self->{config}; |
19
|
3
|
100
|
|
|
|
21
|
my $blessed = Blessed::Merge->new({ blessed => 0, ($self->{merge} ? %{ $self->{merge} } : ()) }); |
|
1
|
|
|
|
|
7
|
|
20
|
|
|
|
|
|
|
$self->{data} = ref $self->{config} eq 'ARRAY' |
21
|
4
|
|
|
|
|
298
|
? $blessed->merge(map { LoadFile($_) } @{ $self->{config} }) |
|
2
|
|
|
|
|
5
|
|
22
|
3
|
100
|
|
|
|
74
|
: LoadFile($self->{config}); |
23
|
3
|
100
|
|
|
|
597
|
$self->{data} = $self->{data}->{$self->{section}} if $self->{section}; |
24
|
3
|
|
|
|
|
16
|
$self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub find { |
28
|
9
|
100
|
|
9
|
1
|
41
|
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
|
739
|
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__ |