| 1 | package Alzabo::Config; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 19 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 19 | ▶ | use vars qw($VERSION %CONFIG); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 19 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 19 | $VERSION = 2.0; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 19 | %CONFIG = ( | |||||||||||||||||||||||||||||||||||||||||
| 12 | 'root_dir' => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 19 | my $curdir = File::Spec->curdir; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 19 | my $updir = File::Spec->updir; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | sub root_dir | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 19 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
root_dir: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 19 | ▶ | $CONFIG{root_dir} = $_[0] if defined $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 19 | return $CONFIG{root_dir}; | |||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | sub schema_dir | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
schema_dir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | Alzabo::Exception->throw( error => "No Alzabo root directory defined" ) | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | unless defined $CONFIG{root_dir}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return File::Spec->catdir( $CONFIG{root_dir}, 'schemas' ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | sub available_schemas | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
available_schemas: not called CC=9 SCAR=42.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $dirname = Alzabo::Config::schema_dir; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | local *DIR; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | opendir DIR, $dirname | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | or Alzabo::Exception::System->throw( error => "can't open $dirname: $!\n" ); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my @s; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | foreach my $e (readdir DIR) | |||||||||||||||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | next if $e eq $curdir || $e eq $updir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$e eq $curdir or $e eq $updir
MC/DC0%0/2
$e eq $curdir or $e eq $updir
$e eq $curdir
$e eq $updir
Truth table0%0/3
A or B
A= $e eq $curdirB= $e eq $updir
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $dir = File::Spec->catdir( $dirname, $e ); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | push @s, $e | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
-d $dir and -r _ and glob "$dir/*.alz"
-d $dir and -r _
MC/DC0%0/3
-d $dir and -r _ and glob "$dir/*.alz"
-d $dir
-r _
glob "$dir/*.alz"
Truth table0%0/4
A and B and C
A= -d $dirB= -r _C= glob "$dir/*.alz"
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 19 | ▶ | if -d $dir && -r _ && glob "$dir/*.alz"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | closedir DIR | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | or Alzabo::Exception::System->throw( error => "can't close $dirname: $!\n" ); | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | return @s; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||||||||||||||||||||||||