NASA_Ames/FFI2160.pm

filter: Statementstmt 90.3% 84 / 93 Branchbran 62.5% 15 / 24 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 80.8% 110 / 136 CC 16 SCAR 21.5
CC
16
Cov
82%
_refillBuffer
15.2
new
4.2
_parseAuxDeclaration
3.0
CRAP 8.6
↑ Summary NASA_Ames/FFI1020.pm »
1 package Pure::Text::NASA_Ames::FFI2160;
2 1 ▶use base (Text::NASA_Ames);
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 __PACKAGE__->mk_accessors(qw(xScal1 xMiss1));
4  
5 package Text::NASA_Ames::FFI2160;
6 1 ▶use base qw(Pure::Text::NASA_Ames::FFI2160);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use 5.00600;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our $VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf " %d." . "%02d" x $#r, @r };
13  
14  
15 =head1 NAME
16  
17 Text::NASA_Ames::FFI2160 - Implementation of FFI2160 NASA_Ames format
18  
19 =head1 SYNOPSIS
20  
21  
22 =head1 DESCRIPTION
23  
24 This class should normally not be called directly but through the
25 L<Text::NASA_Ames> class indirectly.
26  
27 =head1 PUBLIC METHODS
28  
29 =over 4
30  
31 =item new (Text::NASA_Ames-object || options for new NASA_Ames)
32  
33 parses the (rest of the) header (body and comments)
34  
35 =cut
36  
37 2 ▶sub new {
Subroutine new: called CC=4 SCAR=14.4
Pod documented
38 2 my ($class, $fileObj) = @_;
39 2 ▶ $class = ref $class || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
40 2 ▶ if (! (ref $fileObj && (ref($fileObj) eq 'Text::NASA_Ames'))) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $fileObj and ref $fileObj eq "Text::NASA_Ames") 0 2 2
Condition33%1/3
ref $fileObj and ref $fileObj eq "Text::NASA_Ames"
!ll&&!rl&&r
002
MC/DC0%0/2
ref $fileObj and ref $fileObj eq "Text::NASA_Ames"
ref $fileObj ref $fileObj eq "Text::NASA_Ames"
Truth table33%1/3
A and B
A= ref $fileObjB= ref $fileObj eq "Text::NASA_Ames"
ABresult
0X0
100
111
41 0 return new Text::NASA_Ames($fileObj);
42 }
43 2 my $self = $fileObj;
44 2 bless $self, $class;
45  
46 2 $self->_parseList('dX', 1);
47 2 push @{ $self->dX }, undef; # undef for string X2
48 2 $self->_parseList('lenX', 1);
49 2 unshift @{ $self->lenX }, undef; # undef for numeric X1
50 2 $self->_parseLines('xName', $self->nIV);
51 2 $self->_parseVDeclaration;
52 2 $self->_parseAuxDeclaration;
53 2 $self->_parseTailHeader;
54  
55 2 return $self;
56 }
57  
58 2 ▶sub _parseAuxDeclaration {
Subroutine _parseAuxDeclaration: called CC=3 SCAR=11.0
59 2 my $self = shift;
60 2 $self->nAuxV($self->nextLine); # includes NX1 on first pos!
61 2 $self->nAuxC($self->nextLine);
62 2 foreach my $type (qw(aScal aMiss)) {
63 4 $self->_parseList($type, ($self->nAuxV - $self->nAuxC));
64 }
65 2 $self->_parseList('lenA', $self->nAuxC);
66 2 my @stringMissA;
67 2 ▶ for (my $i = 0; $i < $self->nAuxC; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $self->nAuxC) 4 2 6
68 4 push @stringMissA, $self->nextLine;
69 }
70 2 push @{ $self->aMiss }, @stringMissA;
71 2 push @{ $self->aScal }, map { undef } @stringMissA;
72 2 $self->_parseLines('aName', $self->nAuxV);
73  
74 # move first aux value to NX1
75 2 $self->nAuxV($self->nAuxV - 1);
76 2 my @aScal = @{ $self->aScal };
77 2 $self->xScal1(shift @aScal);
78 2 $self->aScal(\@aScal);
79 2 my @aMiss = @{ $self->aMiss };
80 2 $self->xMiss1(shift @aMiss);
81 2 $self->aMiss(\@aMiss);
82 2 my @aName = @{ $self->aName };
83 2 shift @aName;
84 2 $self->aName(\@aName);
85 }
86  
87 4 ▶sub _refillBuffer {
Subroutine _refillBuffer: called CC=11 SCAR=27.2
88 4 my $self = shift;
89  
90 4 my $x2 = $self->nextLine;
91 4 ▶ return unless defined $x2;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x2 1 3 4
92  
93 3 my $line = $self->nextLine;
94 3 ▶ return unless defined $line;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $line 0 3 3
95  
96 3 my ($nX1, @a) = split ' ', $line;
97 3 ▶ while (@a < ($self->nAuxV - $self->nAuxC)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a < $self->nAuxV - $self->nAuxC) 0 3 3
98 0 push @a, split ' ', $self->nextLine;
99 }
100 3 ▶ if (@a > ($self->nAuxV - $self->nAuxC)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a > $self->nAuxV - $self->nAuxC) 0 3 3
101 0 $self->_carp("to much elements for numeric Aux, expected ".
102 ($self->nAuxV() - $self->nAuxC). ", got ". scalar @a);
103 0 return;
104 }
105 3 push @a, map {$self->nextLine} (1..$self->nAuxC);
106 3 ▶ $self->_cleanAndScaleVals($self->aMiss, $self->aScal, \@a)
Branch: 1 branch
BranchTrueFalseTotal
if $self->nAuxV > 0 3 0 3
107 if $self->nAuxV > 0;
108  
109 3 ▶ for (my $i = 0; $i < $nX1; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $nX1) 21 3 24
110 21 $line = $self->nextLine;
111 21 ▶ unless ($line) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line) 0 21 21
112 0 $self->_carp("not enough elements for V".
113 " in row ". $self->currentLine);
114 0 return;
115 }
116
117 21 my ($x1, @v) = split ' ', $line;
118 21 ▶ if (@v != $self->nV) {
Branch: 1 branch
BranchTrueFalseTotal
if (@v != $self->nV) 0 21 21
119 0 $self->_carp("not enough elements for v, expected ".
120 $self->nV . ", got ". scalar @v .
121 " in row ". $self->currentLine);
122 0 return;
123 }
124 21 ▶ if ($x1 == $self->xMiss1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x1 == $self->xMiss1) { } 0 21 21
125 0 $x1 = undef;
126 } else {
127 21 $x1 *= $self->xScal1;
128 }
129 21 ▶ $self->_cleanAndScaleVals($self->vMiss, $self->vScal, \@v)
Branch: 1 branch
BranchTrueFalseTotal
if $self->nV > 0 21 0 21
130 if $self->nV > 0;
131 21 push @{ $self->dataBuffer },
132 new Text::NASA_Ames::DataEntry({X => [ $x1, $x2 ],
133 V => \@v,
134 A => \@a});
135 }
136 }
137  
138 1 1;
139 __END__
↑ Summary NASA_Ames/FFI1020.pm »