ObjectGroup/Base.pm

filter: Statementstmt 91.8% 45 / 49 Branchbran 85.7% 12 / 14 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 2 totaltotal 83.5% 66 / 79 CC 9 SCAR 15.7
CC
9
Cov
88%
_init
8.7
push
2.0
dump
2.0
CRAP 4.8
« ObjectGroup/Network.pm ↑ Summary
1 package Net::Cisco::ObjectGroup::Base;
2 6 ▶use base qw(Class::Data::Inheritable);
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use base qw(Class::Accessor::Fast);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use warnings FATAL => qw(all);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use Symbol;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 __PACKAGE__->mk_classdata('__dict');
12  
13 6 __PACKAGE__->follow_best_practice;
14 6 __PACKAGE__->mk_accessors(qw( type name desc objs ));
15  
16 13 ▶sub _init {
Subroutine _init: called CC=8 SCAR=21.6
17 13 my $self = shift;
18 13 my $arg_ref = shift;
19  
20 13 ▶ return $self unless $arg_ref->{pretty_print};
Branch: 1 branch
BranchTrueFalseTotal
unless $arg_ref->{"pretty_print"} 10 3 13
21 3 my $pkg = ref $self;
22  
23 3 ▶ if (!defined $pkg->__dict) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pkg->__dict) 3 0 3
24 3 $pkg->__dict( {} );
25  
26 3 my $data = Symbol::qualify_to_ref('DATA', $pkg);
27 3 ▶ while (my $line = <$data>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $data)) 119 3 122
28 119 ▶ next if $line =~ m/^#/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^#/ 68 51 119
29 51 ▶ next if $line !~ m/:/;
Branch: 1 branch
BranchTrueFalseTotal
unless $line =~ /:/ 5 46 51
30  
31 46 $line =~ m/^\s*([0-9]+)\s*:\s*([a-z0-9-]{2,})\s*$/;
32 46 ▶ if (defined $1 and defined $2) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $1 and defined $2) { } 46 0 46
Condition33%1/3
defined $1 and defined $2
!ll&&!rl&&r
0046
MC/DC0%0/2
defined $1 and defined $2
defined $1 defined $2
Truth table33%1/3
A and B
A= defined $1B= defined $2
ABresult
0X0
100
111
33 46 $pkg->__dict->{$1} = $2;
34 }
35 else {
36 # pretty printing is nice but not essential,
37 # so just continue if there is some kind of error.
38 0 chomp $line;
39 0 carp "syntax error in __DATA__ portion of $pkg: '$line'";
40 0 next;
41 }
42 }
43 }
44  
45 3 return $self;
46 }
47  
48 0 ▶sub push {
Subroutine push: not called CC=1 SCAR=6.9
Pod undocumented
49 0 croak 'attempt to call push() in base class';
50 }
51  
52 17 ▶sub dump {
Subroutine dump: called CC=2 SCAR=6.9
Pod undocumented
53 17 my $self = shift;
54 17 my $output;
55  
56 17 $output .= sprintf "object-group %s %s\n",
57 $self->get_type, $self->get_name;
58  
59 17 ▶ $output .= sprintf " description %s\n",
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->get_desc 16 1 17
60 $self->get_desc if defined $self->get_desc;
61  
62 17 $output .= join "\n", map {' '. $_} @{$self->get_objs};
63  
64 17 chomp $output;
65 17 return $output;
66 }
67  
68 6 1;
69  
70 # Copyright (c) The University of Oxford 2006. All Rights Reserved.
71 #
72 # This program is free software; you can redistribute it and/or modify it
73 # under the terms of version 2 of the GNU General Public License as published
74 # by the Free Software Foundation.
75 #
76 # This program is distributed in the hope that it will be useful, but WITHOUT
77 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
79 # more details.
80 #
81 # You should have received a copy of the GNU General Public License along with
82 # this program; if not, write to the Free Software Foundation, Inc., 51
83 # Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
« ObjectGroup/Network.pm ↑ Summary