| 1 | # Connector::Proxy::YAML | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # Proxy class for reading YAML configuration | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Written by Scott Hardin and Martin Bartosch for the OpenXPKI project 2012 | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | package Connector::Proxy::YAML; | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use English; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use YAML; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 3 | extends 'Connector::Builtin::Memory'; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # set Location required (unset by parent class) | ||||||||||||||||||||||||||||
| 20 | 3 | has '+LOCATION' => ( required => 1 ); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 3 | ▶ | sub _build_config { | ||||||||||||||||||||||||||
|
Subroutine
_build_config: called CC=4 SCAR=16.1
| |||||||||||||||||||||||||||||
| 23 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # File not exist or not readable | ||||||||||||||||||||||||||||
| 26 | 3 | my $config; | |||||||||||||||||||||||||||
| 27 | 3 | my $file = $self->LOCATION(); | |||||||||||||||||||||||||||
| 28 | 3 | ▶ | if ( ( -e $file ) && ( -r $file ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-e $file and -r $file
MC/DC0%0/2
-e $file and -r $file
-e $file
-r $file
Truth table33%1/3
A and B
A= -e $fileB= -r $file
| |||||||||||||||||||||||||||||
| 29 | 3 | eval { | |||||||||||||||||||||||||||
| 30 | 3 | $config = YAML::LoadFile( $file ); | |||||||||||||||||||||||||||
| 31 | }; | ||||||||||||||||||||||||||||
| 32 | 3 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 0 | $self->log()->error('Proxy::Yaml error parsing file '.$file); | |||||||||||||||||||||||||||
| 34 | 0 | $self->log()->debug( Dumper( $@ ) ); | |||||||||||||||||||||||||||
| 35 | 0 | return $self->_node_not_exists( $file ); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | 3 | $self->log()->debug('Proxy::Yaml loading configuration from file '.$file); | |||||||||||||||||||||||||||
| 38 | } else { | ||||||||||||||||||||||||||||
| 39 | 0 | $self->log()->warn('Proxy::Yaml configuration file '.$file.' not found or not readable'); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 3 | $self->_config($config); | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub set { shift; die "No set() method defined"; }; | ||||||||||||||||||||||||||
|
Subroutine
set: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 3 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 47 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 3 | 1; | |||||||||||||||||||||||||||
| 50 | __END__ | ||||||||||||||||||||||||||||