WE/DB/Info.pm

filter: Statementstmt 39.3% 24 / 61 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 63.6% 7 / 11 Podpod 33.3% 1 / 3 totaltotal 32.3% 32 / 99 CC 13 SCAR 39.2
CC
13
Cov
29%
getopt
110.0
new
12.0
load
6.0
CRAP 50.3
« WE_Frontend/TextImages.pm ↑ Summary WE/DB/Glossary.pm »
1 # -*- perl -*-
2  
3 #
4 # $Id: Info.pm,v 1.4 2005/02/02 20:43:45 eserte Exp $
5 # Author: Slaven Rezic
6 #
7 # Copyright (C) 2005 Slaven Rezic. All rights reserved.
8 # This package is free software; you can redistribute it and/or
9 # modify it under the same terms as Perl itself.
10 #
11 # Mail: slaven@rezic.de
12 # WWW: http://www.rezic.de/eserte/
13 #
14  
15 package WE::DB::Info;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 $VERSION = sprintf("%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/);
20  
21 1 ▶use base qw(Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 __PACKAGE__->mk_accessors(qw(Info File));
23  
24 1 ▶use Cwd qw(cwd);
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use File::Basename qw(dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use YAML ();
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
30 0 my($class, %args) = @_;
31 0 my $self = bless {}, $class;
32 0 ▶ if (!exists $args{File}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"File"}) 0 0 0
33 0 $args{File} = File::Spec->catfile(cwd, "INFO.yml");
34 }
35 0 ▶ while(my($k,$v) = each %args) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %args) 0 0 0
36 0 $self->$k($v);
37 }
38 0 $self;
39 }
40  
41 0 ▶sub load {
Subroutine load: not called CC=2 SCAR=17.9
Pod undocumented
42 0 my $self = shift;
43 0 local $^W = undef;
44 0 ▶ my $info = eval { YAML::LoadFile($self->File) } || {};
Condition0%0/2
eval { do { YAML::LoadFile($self->File) } } || {}
l!l
00
MC/DC0%0/1
eval { do { YAML::LoadFile($self->File) } } || {}
eval { do { YAML::LoadFile($self->File) } }
Truth table0%0/2
A
A= eval { do { YAML::LoadFile($self->File) } }
Aresult
11
00
45 0 $self->Info($info);
46 }
47  
48 0 ▶sub getopt {
Subroutine getopt: not called CC=10 SCAR=47.0
Pod undocumented
49 0 my($self, %args) = @_;
50 0 my $info = $self->Info;
51  
52 0 ▶ my $make_abs = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 0 my $f = shift;
54 0 File::Spec->rel2abs($f, dirname($self->File));
55 0 };
56  
57 0 my %opt;
58 0 for my $def ('inc@,abs', 'datadir,abs',
59 qw(rootclass
60 userdbclass userdbclass_file
61 objdbclass objdbclass_file)) {
62 0 my($key, $sigil, $attribs) = $def =~ m{^(.*?)([\@\$\%])?(,.*)?$};
63 0 my %attribs;
64 0 ▶ if ($attribs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attribs) 0 0 0
65 0 %attribs = map {($_,1)} split /,/, substr($attribs, 1);
66 }
67 0 ▶ if (exists $info->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{$key}) 0 0 0
68 0 ▶ if ($sigil && $sigil eq '@') {
Branch: 1 branch
BranchTrueFalseTotal
if ($sigil and $sigil eq '@') { } 0 0 0
Condition0%0/3
$sigil and $sigil eq "\@"
!ll&&!rl&&r
000
MC/DC0%0/2
$sigil and $sigil eq "\@"
$sigil $sigil eq "\@"
Truth table0%0/3
A and B
A= $sigilB= $sigil eq "\@"
ABresult
0X0
100
111
69 0 ▶ if (UNIVERSAL::isa($info->{$key}, "ARRAY")) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($info->{$key}, 'ARRAY')) { } 0 0 0
70 0 $opt{$key} = $info->{$key};
71 } else {
72 0 $opt{$key} = [ $info->{$key} ];
73 }
74 0 ▶ if ($attribs{'abs'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attribs{"abs"}) 0 0 0
75 0 for (@{$opt{$key}}) {
76 0 $_ = $make_abs->($_);
77 }
78 }
79 } else {
80 0 $opt{$key} = $info->{$key};
81 0 ▶ if ($attribs{'abs'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attribs{"abs"}) 0 0 0
82 0 $opt{$key} = $make_abs->($opt{$key});
83 }
84 }
85 }
86 }
87 0 %opt;
88 }
89  
90 1 1;
91  
92 __END__
« WE_Frontend/TextImages.pm ↑ Summary WE/DB/Glossary.pm »