| 1 | package Config::LNPath; | ||||||||||||
| 2 | |||||||||||||
| 3 | 2 | ▶ | use 5.006; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 2 | our $VERSION = '1.01'; | |||||||||||
| 8 | |||||||||||||
| 9 | 2 | ▶ | use YAML::XS qw/LoadFile/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 2 | ▶ | use Data::LNPath qw/lnpath/, { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | return_undef => 1 | ||||||||||||
| 12 | 2 | }; | |||||||||||
| 13 | 2 | ▶ | use Carp qw/croak/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | 2 | ▶ | use Blessed::Merge; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | |||||||||||||
| 16 | 4 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||
| 17 | 4 | ▶ | my $self = bless $_[1] // {}, $_[0]; | ||||||||||
|
Condition100%2/2
$_[1] // {}
MC/DC100%1/1
$_[1] // {}
$_[1]
Truth table100%2/2
A
A= $_[1]
| |||||||||||||
| 18 | 4 | ▶ | croak "no config path passed to new" unless $self->{config}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 19 | 3 | ▶ | my $blessed = Blessed::Merge->new({ blessed => 0, ($self->{merge} ? %{ $self->{merge} } : ()) }); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 20 | $self->{data} = ref $self->{config} eq 'ARRAY' | ||||||||||||
| 21 | 4 | ? $blessed->merge(map { LoadFile($_) } @{ $self->{config} }) | |||||||||||
| 22 | 3 | ▶ | : LoadFile($self->{config}); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | 3 | ▶ | $self->{data} = $self->{data}->{$self->{section}} if $self->{section}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 24 | 3 | $self; | |||||||||||
| 25 | } | ||||||||||||
| 26 | |||||||||||||
| 27 | 9 | ▶ | sub find { | ||||||||||
|
Subroutine
find: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 28 | 9 | ▶ | lnpath($_[0]->{data}, $_[1]) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | or croak sprintf "Could not find value from config using path -> %s", $_[1]; | ||||||||||||
| 30 | } | ||||||||||||
| 31 | |||||||||||||
| 32 | 3 | ▶ | sub section_find { | ||||||||||
|
Subroutine
section_find: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 33 | 3 | ▶ | lnpath($_[0]->{data}->{$_[1]}, $_[2]) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 34 | or croak sprintf "Could not find value from config section -> %s", $_[1]; | ||||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | 2 | 1; # End of Config::LNPath | |||||||||||
| 38 | |||||||||||||
| 39 | __END__ | ||||||||||||