| 1 | 2 | ▶ | use 5.008; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | package Property::Lookup::File; | ||||||||||||
| 6 | 2 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 2 | $Property::Lookup::File::VERSION = '1.101400'; | |||||||||||
| 8 | } | ||||||||||||
| 9 | # ABSTRACT: File-based property lookup layer | ||||||||||||
| 10 | 2 | ▶ | use File::Basename; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 2 | ▶ | use parent 'Property::Lookup::Hash'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 2 | __PACKAGE__->mk_scalar_accessors(qw(filename)); | |||||||||||
| 13 | |||||||||||||
| 14 | 1 | ▶ | sub init { | ||||||||||
|
Subroutine
init: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||
| 15 | 1 | my $self = shift; | |||||||||||
| 16 | 1 | $self->SUPER::init(@_); | |||||||||||
| 17 | 1 | ▶ | if (my $conf_file = $self->filename) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | |||||||||||||
| 19 | # replace dollar-variables with their environment equivalent; also | ||||||||||||
| 20 | # some special definitions | ||||||||||||
| 21 | 1 | ▶ | open my $fh, '<', $conf_file or die "can't open $conf_file: $!\n"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 22 | 1 | my $yaml = do { local $/; <$fh> }; | |||||||||||
| 23 | 1 | ▶ | close $fh or die "can't close $conf_file: $!\n"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 24 | 1 | $ENV{SELF} = dirname($self->filename); | |||||||||||
| 25 | 1 | ▶ | $yaml =~ s/\$(\w+)/$ENV{$1} || "\$$1"/ge; | ||||||||||
|
Condition50%1/2
$ENV{$1} || "\$$1"
MC/DC0%0/1
$ENV{$1} || "\$$1"
$ENV{$1}
Truth table50%1/2
A
A= $ENV{$1}
| |||||||||||||
| 26 | 1 | require YAML; | |||||||||||
| 27 | 1 | $self->hash(YAML::Load($yaml)); | |||||||||||
| 28 | } | ||||||||||||
| 29 | } | ||||||||||||
| 30 | 2 | 1; | |||||||||||
| 31 | |||||||||||||
| 32 | |||||||||||||
| 33 | __END__ | ||||||||||||