Config/Statement.pm

filter: Statementstmt 30.4% 14 / 46 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 4 totaltotal 22.5% 18 / 80 CC 11 SCAR 38.4
CC
11
Cov
22%
substatement
90.0
new
6.0
parse_tree
6.0
CRAP 46.7
« Config/File/Nsd.pm ↑ Summary Config/Server.pm »
1 #!/usr/local/bin/perl -w
2 ######################################################################
3 #
4 # DNS/Config/Statement.pm
5 #
6 # $Id: Statement.pm,v 1.3 2003/02/16 10:15:31 awolf Exp $
7 # $Revision: 1.3 $
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::Statement;
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.3 $ =~ /(\d+)\.(\d+)/);
27  
28 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
29 0 my($pkg) = @_;
30 0 ▶ my $class = ref($pkg) || $pkg;
Condition0%0/3
ref $pkg || $pkg
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $pkg || $pkg
ref $pkg $pkg
Truth table0%0/3
A || B
A= ref $pkgB= $pkg
ABresult
1X1
011
000
31  
32 0 my $self = {
33 'TREE' => []
34 };
35
36 0 bless $self, $class;
37  
38 0 return $self;
39 }
40  
41 0 ▶sub parse_tree {
Subroutine parse_tree: not called CC=2 SCAR=17.9
Pod undocumented
42 0 my($self, @array) = @_;
43
44 0 ▶ return undef if(scalar(@{ $self->{'TREE'} }));
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$self->{"TREE"};} 0 0 0
45
46 0 push @{ $self->{'TREE'} }, @array;
47
48 0 return $self;
49 }
50  
51 0 ▶sub dump {
Subroutine dump: not called CC=1 SCAR=6.9
Pod undocumented
52 0 my($self) = @_;
53  
54 0 print $self->substatement(@{ $self->{'TREE'} });
55 0 print "\n";
56
57 0 return $self;
58 }
59  
60 0 ▶sub substatement {
Subroutine substatement: not called CC=9 SCAR=45.0
Pod undocumented
61 0 my($self, @array) = @_;
62 0 my $string;
63 0 my $flags = 0;
64  
65 0 my $arrays_only = 1;
66 0 foreach my $element (@array) {
67 0 ▶ $arrays_only = 0 if(ref($element) ne 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
if ref $element ne "ARRAY" 0 0 0
68 }
69  
70 0 ▶ $string .= "\{\n" if($arrays_only);
Branch: 1 branch
BranchTrueFalseTotal
if $arrays_only 0 0 0
71  
72 0 foreach my $element (@array) {
73 0 ▶ if(ref($element) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $element eq 'ARRAY') { } 0 0 0
74 0 $string .= $self->substatement(@$element);
75 0 $flags = 0;
76 }
77 else {
78 0 $string .= "$element ";
79 0 $flags = 1;
80 }
81 }
82  
83 0 ▶ $string .= "\} " if($arrays_only);
Branch: 1 branch
BranchTrueFalseTotal
if $arrays_only 0 0 0
84 0 ▶ $string .= "\;\n" if($flags || $arrays_only);
Branch: 1 branch
BranchTrueFalseTotal
if $flags or $arrays_only 0 0 0
Condition0%0/3
$flags or $arrays_only
l!l&&r!l&&!r
000
MC/DC0%0/2
$flags or $arrays_only
$flags $arrays_only
Truth table0%0/3
A or B
A= $flagsB= $arrays_only
ABresult
1X1
011
000
85  
86 0 return $string;
87 }
88  
89 2 1;
90  
91 __END__
« Config/File/Nsd.pm ↑ Summary Config/Server.pm »