blib/lib/Graph/Reader/OID.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 12 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 55 / 55 CC 8 SCAR 17.3
CC
8
Cov
100%
_read_graph
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.7
↑ Summary
1 package Graph::Reader::OID;
2  
3 4 ▶use base qw(Graph::Reader);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # Constants.
10 4 Readonly::Scalar our $DOT => q{.};
11 4 Readonly::Scalar our $EMPTY_STR => q{};
12  
13 # Version.
14 4 our $VERSION = 0.05;
15  
16 # Read graph subroutine.
17 4 ▶sub _read_graph {
Subroutine _read_graph: called CC=8 SCAR=20.8
18 4 my ($self, $graph, $fh) = @_;
19 4 ▶ while (my $line = <$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 8 4 12
20 8 chomp $line;
21  
22 # End of vertexes section.
23 8 ▶ if ($line =~ m/^#/ms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^#/ms) 1 7 8
24 1 next;
25 }
26  
27 # Process OID.
28 7 my ($line_oid, $line_label) = split m/\s+/ms, $line, 2;
29 7 my @oid = split m/\./ms, $line_oid;
30 7 my $last_oid;
31 7 my $act_oid = $EMPTY_STR;
32 7 foreach my $oid (@oid) {
33 14 ▶ if ($act_oid ne $EMPTY_STR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($act_oid ne $Graph::Reader::OID::EMPTY_STR) 7 7 14
34 7 $act_oid .= $DOT;
35 }
36 14 $act_oid .= $oid;
37 14 $graph->add_vertex($act_oid);
38 14 ▶ if ($act_oid eq $line_oid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($act_oid eq $line_oid) 7 7 14
39 7 ▶ if (! $line_label) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line_label) 2 5 7
40 2 $line_label = $line_oid;
41 }
42 7 $graph->set_vertex_attribute($act_oid, 'label',
43 $line_label);
44 }
45 14 ▶ if (defined $last_oid) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $last_oid) 7 7 14
46 7 $graph->add_edge($last_oid, $act_oid);
47 }
48 14 $last_oid = $act_oid;
49 }
50 }
51 4 return;
52 }
53  
54 4 1;
55  
56 __END__
↑ Summary