Config/File.pm

filter: Statementstmt 75.5% 34 / 45 Branchbran 33.3% 2 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 5 totaltotal 61.9% 44 / 71 CC 5 SCAR 7.4
CC
5
Cov
69%
debug
3.4
read
3.2
new
2.0
CRAP 2.1
« Config/Statement/Options.pm ↑ Summary
1 #!/usr/local/bin/perl -w
2 ######################################################################
3 #
4 # DNS/Config/File.pm
5 #
6 # $Id: File.pm,v 1.5 2003/02/16 10:15:31 awolf Exp $
7 # $Revision: 1.5 $
8 # $Author: awolf $
9 # $Date: 2003/02/16 10:15:31 $
10 #
11 # Copyright (C)2001-2003 Andy Wolf. All rights reserved.
12 #
13 # This library is free software; you can redistribute it and/or
14 # modify it under the same terms as Perl itself.
15 #
16 ######################################################################
17  
18 package DNS::Config::File;
19  
20 2 ▶no warnings 'portable';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use 5.6.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 2 my $VERSION = '0.66';
26 2 my $REVISION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/);
27  
28 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
29 1 my($pkg, %hash) = @_;
30 1 my $ref;
31
32 1 my $type = 'DNS::Config::File::' . ucfirst $hash{'type'};
33 1 my $file = $hash{'file'};
34 1 my $conf = $hash{'config'};
35
36 1 eval "require $type";
37
38 1 ▶ if(!$@) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $@) { } 1 0 1
39 1 $ref = $type->new($file, $conf);
40 }
41 else {
42 0 warn $@;
43 }
44
45 1 return $ref;
46 }
47  
48 1 ▶sub read {
Subroutine read: called CC=3 SCAR=11.7
Pod undocumented
49 1 my($self, $file) = @_;
50 1 my @lines;
51  
52 1 ▶ $file = $file || $self->{'FILE'};
Condition33%1/3
$file || $self->{'FILE'}
l!l&&r!l&&!r
010
MC/DC0%0/2
$file || $self->{'FILE'}
$file $self->{'FILE'}
Truth table33%1/3
A || B
A= $fileB= $self->{'FILE'}
ABresult
1X1
011
000
53
54 1 ▶ if(open(FILE, $file)) {
Branch: 1 branch
BranchTrueFalseTotal
if (open FILE, $file) { } 1 0 1
55 1 @lines = <FILE>;
56 1 chomp @lines;
57 1 close FILE;
58 }
59 0 else { warn "File $file not found !\n"; }
60  
61 1 return @lines;
62 }
63  
64 0 ▶sub parse {
Subroutine parse: not called CC=1 SCAR=6.9
Pod undocumented
65 0 my($self, $file) = @_;
66
67 # Overwrite in sub classes !
68
69 0 return $self;
70 }
71  
72 0 ▶sub dump {
Subroutine dump: not called CC=1 SCAR=6.9
Pod undocumented
73 0 my($self, $file) = @_;
74
75 # Overwrite in sub classes !
76
77 0 return $self;
78 }
79  
80 0 ▶sub debug {
Subroutine debug: not called CC=2 SCAR=12.2
Pod undocumented
81 0 my($self) = @_;
82
83 0 ▶ return undef unless($self->{'CONFIG'});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"CONFIG"} 0 0 0
84
85 0 eval {
86 2 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
87
88 0 print Dumper($self->{'CONFIG'});
89 };
90  
91 0 return 1;
92 }
93  
94 2 1;
95  
96 __END__
« Config/Statement/Options.pm ↑ Summary