Reader.pm

filter: Statementstmt 54.2% 19 / 35 Branchbran 16.6% 1 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 100% 2 / 2 totaltotal 54.9% 28 / 51 CC 4 SCAR 14.5
CC
4
Cov
49%
read_graph
12.0
new
2.5
BEGIN
1.0
CRAP 4.3
« Writer/XML.pm ↑ Summary ReadWrite.pm »
1 #
2 # Graph::Reader - perl base class for Graph file format readers
3 #
4 package Graph::Reader;
5 2 $Graph::Reader::VERSION = '2.10';
6 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Graph;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #=======================================================================
14 #
15 # new () - constructor
16 #
17 #=======================================================================
18 sub new
19 1 ▶{
Subroutine new: called CC=2 SCAR=9.2
Pod documented
20 1 my $class = shift;
21 1 my %args = @_;
22  
23 1 ▶ die "don't create an instance of $class!\n" if $class eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $class eq __PACKAGE__ 1 0 1
24  
25 0 my $self = bless {}, $class;
26  
27 0 $self->_init(\%args);
28  
29 0 return $self;
30 }
31  
32 #=======================================================================
33 #
34 # _init() - initialise instance
35 #
36 # This is for any instance-specific initialisation. The idea is that
37 # a sub-class will define an _init() method if it needs one.
38 # For future compatibility the class-specific method should invoke
39 # this.
40 #
41 #=======================================================================
42 sub _init
43 0 ▶{
Subroutine _init: not called CC=1 SCAR=0.0
44 }
45  
46 #=======================================================================
47 #
48 # read_graph() - create a Graph and read the given file into it
49 #
50 # This is the public method that will be invoked to read a graph.
51 # The file can be specified either as a filename, or a filehandle.
52 #
53 #=======================================================================
54 sub read_graph
55 0 ▶{
Subroutine read_graph: not called CC=3 SCAR=24.8
Pod documented
56 0 my $self = shift;
57 0 my $filename = shift;
58  
59 0 my $graph = Graph->new();
60 0 my $FILE;
61  
62  
63 0 ▶ if (ref $filename)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $filename) { } 0 0 0
64 {
65 0 $self->_read_graph($graph, $filename);
66 }
67 else
68 {
69 0 $FILE = IO::File->new("< $filename");
70 0 ▶ if (not defined $FILE)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $FILE) 0 0 0
71 {
72 0 warn "couldn't read from $filename: $!\n";
73 0 return 0;
74 }
75 0 $self->_read_graph($graph, $FILE);
76 0 $FILE->close();
77 }
78  
79 0 return $graph;
80 }
81  
82 2 1;
83  
84 __END__
« Writer/XML.pm ↑ Summary ReadWrite.pm »