Base.pm

filter: Statementstmt 51.9% 27 / 52 Branchbran 0.0% 0 / 14 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 57.1% 8 / 14 Podpod 60.0% 3 / 5 totaltotal 43.3% 39 / 90 CC 9 SCAR 29.6
CC
9
Cov
41%
open
56.0
close
6.0
new
2.1
CRAP 19.2
« Simple.pm ↑ Summary Column.pm »
1 package Astro::STSDAS::Table::Base;
2  
3 2 our $VERSION = '0.12';
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use POSIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 2 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Carp qw( carp croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶use Astro::STSDAS::Table::HeaderPars;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Astro::STSDAS::Table::Columns;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 sub new
17 1 ▶{
Subroutine new: called CC=2 SCAR=7.4
Pod documented
18 1 my $this = shift;
19 1 ▶ my $class = ref($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
20  
21 1 my $self = {
22 # the filehandle to the table
23 fh => undef,
24
25 pars => Astro::STSDAS::Table::HeaderPars->new(),
26
27 cols => Astro::STSDAS::Table::Columns->new(),
28  
29 nrows => undef,
30  
31 file => undef,
32  
33 mode => undef,
34  
35 fh => undef
36  
37 };
38  
39  
40 1 bless $self, $class;
41 }
42  
43 sub open
44 0 ▶{
Subroutine open: not called CC=7 SCAR=40.3
Pod documented
45 0 ▶ @_ >=2 or croak 'usage : $self->open( $file [, $mode] )';
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or croak("usage : \$self->open( \$file [, \$mode] )") 0 0 0
46 0 my ( $self, $file, $mode ) = @_;
47  
48 0 ▶ $mode = '<' if ! defined $mode;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mode 0 0 0
49 0 $self->{mode} = $mode;
50 0 my $fh = new IO::File;
51  
52 0 ▶ if ( ref($file) )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $file) { } 0 0 0
53 {
54 0 ▶ $fh->fdopen( $file, $mode ) || return undef;
Branch: 1 branch
BranchTrueFalseTotal
$fh->fdopen($file, $mode) or return undef 0 0 0
55 }
56 else
57 {
58 0 ▶ $fh->open( $file, $mode ) || return undef;
Branch: 1 branch
BranchTrueFalseTotal
$fh->open($file, $mode) or return undef 0 0 0
59 }
60  
61 0 $self->{file} = $file;
62 0 $self->{fh} = $fh;
63  
64 # if this is open for reading, suck in the header
65 0 ▶ if ( $mode =~ /[<+]/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /[<+]/) 0 0 0
66 {
67 0 $self->_read_hdr;
68 }
69  
70 0 1;
71 }
72  
73 sub METHOD::ABSTRACT
74 0 ▶{
Subroutine ABSTRACT: not called CC=1 SCAR=6.9
75 0 my ($self) = @_;
76 0 my $object_class = ref($self);
77 0 my ($file, $line, $method) = (caller(1))[1..3];
78 0 my $loc = "at $file, line $line\n";
79 0 die "call to abstract method ${method} $loc";
80 }
81  
82  
83 0 ▶sub _read_hdr { ABSTRACT METHOD @_ }
Subroutine _read_hdr: not called CC=1 SCAR=6.9
84 0 ▶sub read_cols { ABSTRACT METHOD }
Subroutine read_cols: not called CC=1 SCAR=6.9
Pod undocumented
85 0 ▶sub read_rows { ABSTRACT METHOD }
Subroutine read_rows: not called CC=1 SCAR=6.9
Pod undocumented
86  
87 sub close
88 0 ▶{
Subroutine close: not called CC=2 SCAR=17.9
Pod documented
89 0 my $self = shift;
90  
91 0 ▶ if ( defined $self->{fh} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"fh"}) 0 0 0
92 {
93 0 close $self->{fh};
94 0 $self->{fh} = undef;
95 }
96 }
97  
98  
99 2 1;
100  
101 __END__
« Simple.pm ↑ Summary Column.pm »