blib/lib/Astro/App/Satpass2/FormatValue.pm

filter: Statementstmt 94.9% 729 / 768 Branchbran 74.6% 324 / 434 Conditioncond 58.7% 107 / 182 MC/DCmcdc 28.5% 32 / 112 Subroutinesub 95.1% 138 / 145 Podpod 100% 20 / 20 totaltotal 81.2% 1350 / 1661 CC 305 SCAR 20.9
CC
305
Cov
84%
reflections
22.6
new
22.3
_format_number_scientific
21.3
CRAP 8.1
« blib/lib/Astro/App/Satpass2/Locale.pm ↑ Summary blib/lib/Astro/App/Satpass2/Geocode/OSM.pm »
1 package Astro::App::Satpass2::FormatValue;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 ▶use parent qw{ Astro::App::Satpass2::Copier };
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 ▶use Astro::App::Satpass2::FormatTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use Astro::App::Satpass2::FormatValue::Formatter;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 11 ▶use Astro::App::Satpass2::Locale qw{ __localize };
Subroutine BEGIN: called CC=1 SCAR=0.0
11 11 ▶use Astro::App::Satpass2::Utils qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
12 has_method instance merge_hashes
13 ARRAY_REF CODE_REF HASH_REF
14 @CARP_NOT
15 11 };
16 11 ▶use Astro::App::Satpass2::Warner;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 11 ▶use Astro::Coord::ECI::Sun 0.059;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 11 ▶use Astro::Coord::ECI::TLE 0.059 qw{ :constants };
Subroutine BEGIN: called CC=1 SCAR=0.0
19 11 ▶use Astro::Coord::ECI::Utils 0.059 qw{ deg2rad embodies julianday PI rad2deg TWOPI };
Subroutine BEGIN: called CC=1 SCAR=0.0
20 11 ▶use Clone ();
Subroutine BEGIN: called CC=1 SCAR=0.0
21 11 ▶use List::Util qw{ max min };
Subroutine BEGIN: called CC=1 SCAR=0.0
22 11 ▶use POSIX qw{ floor };
Subroutine BEGIN: called CC=1 SCAR=0.0
23 11 ▶use Scalar::Util 1.26 qw{ isdual reftype };
Subroutine BEGIN: called CC=1 SCAR=0.0
24 11 ▶use Text::Wrap ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 11 our $VERSION = '0.059';
27  
28 11 ▶use constant NONE => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 11 ▶use constant RE_ALL_DIGITS => qr{ \A [0-9]+ \z }smx;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 11 ▶use constant TITLE_GRAVITY_BOTTOM => 'bottom';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 11 ▶use constant TITLE_GRAVITY_TOP => 'top';
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 # Instantiator
34  
35 {
36  
37 749 ▶ sub new {
Subroutine new: called CC=21 SCAR=31.0
Pod documented
38 749 my ( $class, %args ) = @_;
39 749 ▶ ref $class and $class = ref $class;
Branch: 1 branch
BranchTrueFalseTotal
ref $class and $class = ref $class 731 18 749
40 749 my $self = {};
41 749 bless $self, $class;
42  
43 749 $self->warner( delete $args{warner} );
44  
45 749 foreach my $name ( qw{ data default } ) {
46 1498 ▶ $self->{$name} = $args{$name} || {};
Condition100%2/2
$args{$name} || {}
l!l
147028
MC/DC100%1/1
$args{$name} || {}
$args{$name}
Truth table100%2/2
A
A= $args{$name}
Aresult
11
00
47 ref $self->{$name}
48 and HASH_REF eq reftype( $self->{$name} )
49 or $self->{warner}->wail(
50 1498 ▶ "Argument '$name' must be a hash reference" );
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{$name} and "HASH" eq builtin::reftype($self->{$name}) or $self->{"warner"}->wail("Argument '${name}' must be a hash reference") 1498 0 1498
Condition33%1/3
ref $self->{$name} and "HASH" eq builtin::reftype($self->{$name})
!ll&&!rl&&r
001498
MC/DC0%0/2
ref $self->{$name} and "HASH" eq builtin::reftype($self->{$name})
ref $self->{$name} "HASH" eq builtin::reftype($self->{$name})
Truth table33%1/3
A and B
A= ref $self->{$name}B= "HASH" eq builtin::reftype($self->{$name})
ABresult
0X0
100
111
51 }
52  
53 $self->{desired_equinox_dynamical} =
54 749 ▶ $args{desired_equinox_dynamical} || 0;
Condition50%1/2
$args{'desired_equinox_dynamical'} || 0
l!l
0749
MC/DC0%0/1
$args{'desired_equinox_dynamical'} || 0
$args{'desired_equinox_dynamical'}
Truth table50%1/2
A
A= $args{'desired_equinox_dynamical'}
Aresult
11
00
55  
56 $self->{fixed_width} = exists $args{fixed_width} ?
57 $args{fixed_width} :
58 749 ▶ 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'fixed_width'} ? : 282 467 749
59  
60 749 ▶ $self->{overflow} = $args{overflow} || 0;
Condition50%1/2
$args{'overflow'} || 0
l!l
0749
MC/DC0%0/1
$args{'overflow'} || 0
$args{'overflow'}
Truth table50%1/2
A
A= $args{'overflow'}
Aresult
11
00
61  
62 defined( $self->{local_coordinates} = $args{local_coordinates} )
63 749 ▶ or $self->{local_coordinates} = \&__local_coord_azel_rng;
Branch: 1 branch
BranchTrueFalseTotal
defined($self->{"local_coordinates"} = $args{"local_coordinates"}) or $self->{"local_coordinates"} = \&Astro::App::Satpass2::FormatValue::__local_coord_azel_rng 731 18 749
64 ref $self->{local_coordinates}
65 or $self->{local_coordinates} = $self->can(
66 "__local_coord_$self->{local_coordinates}" )
67 or $self->{warner}->wail(
68 749 ▶ "Unknown local_coordinates $self->{local_coordinates}" );
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{"local_coordinates"} or $self->{"local_coordinates"} = $self->can(qq[__local_coord_$self->{"local_coordinates"}]) or $self->{"warner"}->wail(qq[Unknown local_coordinates $self->{"local_coordinates"}]) 749 0 749
Condition66%2/3
ref $self->{"local_coordinates"} or $self->{"local_coordinates"} = $self->can(qq[__local_coord_$self->{"local_coordinates"}])
l!l&&r!l&&!r
74450
MC/DC0%0/2
ref $self->{"local_coordinates"} or $self->{"local_coordinates"} = $self->can(qq[__local_coord_$self->{"local_coordinates"}])
ref $self->{"local_coordinates"} $self->{"local_coordinates"} = $self->can(qq[__local_coord_$self->{"local_coordinates"}])
Truth table66%2/3
A or B
A= ref $self->{"local_coordinates"}B= $self->{"local_coordinates"} = $self->can(qq[__local_coord_$self->{"local_coordinates"}])
ABresult
1X1
011
000
69 CODE_REF eq ref $self->{local_coordinates}
70 or $self->{warner}->wail(
71 749 ▶ 'Argument local_coordinates must be a code reference ',
Branch: 1 branch
BranchTrueFalseTotal
"CODE" eq ref $self->{"local_coordinates"} or $self->{"warner"}->wail("Argument local_coordinates must be a code reference ", "or the name of a known coordinate system") 749 0 749
72 'or the name of a known coordinate system'
73 );
74  
75 defined( $self->{list_formatter} = $args{list_formatter} )
76 749 ▶ or $self->{list_formatter} = $self->can( '__list_formatter' );
Branch: 1 branch
BranchTrueFalseTotal
defined($self->{"list_formatter"} = $args{"list_formatter"}) or $self->{"list_formatter"} = $self->can("__list_formatter") 731 18 749
77 CODE_REF eq ref $self->{list_formatter}
78 or $self->{warner}->wail(
79 749 ▶ 'Argument list_formatter must be a code reference ',
Branch: 1 branch
BranchTrueFalseTotal
"CODE" eq ref $self->{"list_formatter"} or $self->{"warner"}->wail("Argument list_formatter must be a code reference ", "or the name of a known coordinate system") 749 0 749
80 'or the name of a known coordinate system'
81 );
82  
83 749 $self->{title} = $args{title};
84  
85 $self->title_gravity( _dor( $args{title_gravity},
86 749 TITLE_GRAVITY_TOP ) );
87  
88 $self->{time_formatter} = $args{time_formatter} ||
89 749 ▶ 'Astro::App::Satpass2::FormatTime';
Condition100%2/2
$args{'time_formatter'} || 'Astro::App::Satpass2::FormatTime'
l!l
73613
MC/DC100%1/1
$args{'time_formatter'} || 'Astro::App::Satpass2::FormatTime'
$args{'time_formatter'}
Truth table100%2/2
A
A= $args{'time_formatter'}
Aresult
11
00
90 ref $self->{time_formatter}
91 749 ▶ or $self->{time_formatter} = $self->{time_formatter}->new();
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{"time_formatter"} or $self->{"time_formatter"} = $self->{"time_formatter"}->new 736 13 749
92 instance( $self->{time_formatter},
93 'Astro::App::Satpass2::FormatTime' )
94 or $self->{warner}->wail(
95 749 ▶ 'Argument time_formatter must be an Astro::App::Satpass2::FormatTime'
Branch: 1 branch
BranchTrueFalseTotal
instance($self->{"time_formatter"}, "Astro::App::Satpass2::FormatTime") or $self->{"warner"}->wail("Argument time_formatter must be an Astro::App::Satpass2::FormatTime") 749 0 749
96 );
97 749 $self->{date_format} = $args{date_format};
98 defined $self->{date_format}
99 749 ▶ or $self->{date_format} = $self->{time_formatter}->DATE_FORMAT();
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"date_format"} or $self->{"date_format"} = $self->{"time_formatter"}->DATE_FORMAT 731 18 749
100 749 $self->{time_format} = $args{time_format};
101 defined $self->{time_format}
102 749 ▶ or $self->{time_format} = $self->{time_formatter}->TIME_FORMAT();
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"time_format"} or $self->{"time_format"} = $self->{"time_formatter"}->TIME_FORMAT 731 18 749
103 749 ▶ if ( exists $args{round_time} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{'round_time'}) { } 731 18 749
104 731 $self->{round_time} = $args{round_time};
105 } else {
106 18 $self->{round_time} = $self->{time_formatter}->ROUND_TIME();
107 }
108  
109 749 $self->{report} = $args{report};
110  
111 749 return $self;
112 }
113  
114 }
115  
116 # Overrides
117  
118 11 ▶sub clone {
Subroutine clone: called CC=5 SCAR=17.0
Pod documented
119 282 my ( $self, @args ) = @_;
120 282 my %arg;
121 282 ▶ if ( @args == 1 && HASH_REF eq ref $args[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args == 1 and 'HASH' eq ref $args[0]) { } 0 282 282
Condition33%1/3
@args == 1 and "HASH" eq ref $args[0]
!ll&&!rl&&r
28200
MC/DC0%0/2
@args == 1 and "HASH" eq ref $args[0]
@args == 1 "HASH" eq ref $args[0]
Truth table33%1/3
A and B
A= @args == 1B= "HASH" eq ref $args[0]
ABresult
0X0
100
111
122 0 %arg = %{ $args[0] };
123 } else {
124 282 %arg = @args;
125 }
126 282 foreach my $name ( keys %{ $self } ) {
127 defined $arg{$name}
128 4383 ▶ or $arg{$name} = $self->{ $name };
Branch: 1 branch
BranchTrueFalseTotal
defined $arg{$name} or $arg{$name} = $self->{$name} 282 4101 4383
129 }
130 282 delete $arg{internal};
131 282 return $self->new( %arg );
132 }
133  
134 # Accessors.
135  
136 53 ▶sub body { # Required for template 'list', which needs to figure
Subroutine body: called CC=1 SCAR=0.0
Pod documented
137 # out whether the body is inertial or not.
138 53 my ( $self ) = @_;
139 53 return $self->_get_eci( 'body' );
140 }
141  
142 0 ▶sub data {
Subroutine data: not called CC=1 SCAR=6.9
Pod documented
143 0 my ( $self ) = @_;
144 0 return $self->_get( 'data' );
145 }
146  
147 # Mutators. These should be kept to a minimum.
148  
149 14 ▶sub fixed_width {
Subroutine fixed_width: called CC=2 SCAR=7.4
Pod documented
150 14 my ( $self, @args ) = @_;
151 14 ▶ if ( @args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) { } 14 0 14
152 14 $self->{fixed_width} = $args[0];
153 14 return $self;
154 } else {
155 0 return $self->{fixed_width};
156 }
157 }
158  
159 846 ▶sub title_gravity {
Subroutine title_gravity: called CC=3 SCAR=11.0
Pod documented
160 846 my ( $self, @args ) = @_;
161 846 ▶ if ( @args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) { } 786 60 846
162 is_valid_title_gravity( $args[0] )
163 or $self->{warner}->wail(
164 786 ▶ "Attribute title_gravity value '$args[0]' invalid"
Branch: 1 branch
BranchTrueFalseTotal
is_valid_title_gravity($args[0]) or $self->{"warner"}->wail("Attribute title_gravity value '$args[0]' invalid") 786 0 786
165 );
166 786 $self->{title_gravity} = $args[0];
167 786 return $self;
168 } else {
169 60 return $self->{title_gravity};
170 }
171 }
172  
173 # Transformations
174  
175 49 ▶sub appulse {
Subroutine appulse: called CC=1 SCAR=0.0
Pod documented
176 49 my ( $self ) = @_;
177 49 return $self->_variant( 'appulse' );
178 }
179  
180 9 ▶sub bodies {
Subroutine bodies: called CC=5 SCAR=16.1
Pod documented
181 9 my ( $self ) = @_;
182 9 ▶ my $bodies = $self->_get( data => 'bodies' )
Branch: 1 branch
BranchTrueFalseTotal
my $bodies = $self->_get("data", "bodies") or return 9 0 9
183 or return;
184  
185 9 my $questionable = $self->_get( data => 'questionable' );
186 9 my $sta = $self->_get( data => 'station' );
187 9 my $time = $self->_get( data => 'time' );
188 9 my $twilight = $self->_get( data => 'twilight' );
189 9 ▶ defined $twilight
Branch: 1 branch
BranchTrueFalseTotal
defined $twilight or $twilight = deg2rad(-6) 4 5 9
190 or $twilight = deg2rad( -6 ); # Civil
191  
192 9 my @rslt;
193 9 foreach my $body ( @{ $bodies } ) {
194 20 ▶ embodies( $body, 'Astro::Coord::ECI' )
Branch: 1 branch
BranchTrueFalseTotal
embodies($body, "Astro::Coord::ECI") or next 20 0 20
195 or next;
196  
197 20 my $data = {
198 body => $body,
199 illumination => _illumination(
200 body => $body,
201 station => $sta,
202 time => $time,
203 twilight => $twilight,
204 ),
205 questionable => $questionable,
206 };
207  
208 20 push @rslt, $self->_variant( $data );
209 }
210  
211 9 return \@rslt;
212 }
213  
214 6 ▶sub _elevation {
Subroutine _elevation: called CC=2 SCAR=7.1
215 6 my ( $station, $body, $time ) = @_;
216 6 ▶ defined $time and $body->universal( $time );
Branch: 1 branch
BranchTrueFalseTotal
defined $time and $body->universal($time) 6 0 6
217 6 return ( $station->azel( $body ) )[1];
218 }
219  
220 20 ▶sub _illumination {
Subroutine _illumination: called CC=11 SCAR=27.7
221 20 my %arg = @_;
222  
223 20 ▶ embodies( $arg{body}, 'Astro::Coord::ECI::TLE' )
Branch: 1 branch
BranchTrueFalseTotal
embodies($arg{"body"}, "Astro::Coord::ECI::TLE") or return "" 6 14 20
224 or return PASS_EVENT_NONE;
225  
226 defined $arg{time}
227 6 ▶ or $arg{time} = $arg{body}->universal();
Branch: 1 branch
BranchTrueFalseTotal
defined $arg{"time"} or $arg{"time"} = $arg{"body"}->universal 6 0 6
228  
229 embodies( $arg{sun}, 'Astro::Coord::ECI' )
230 6 ▶ or $arg{sun} = $arg{body}->get( 'sun' );
Branch: 1 branch
BranchTrueFalseTotal
embodies($arg{"sun"}, "Astro::Coord::ECI") or $arg{"sun"} = $arg{"body"}->get("sun") 0 6 6
231 embodies( $arg{sun}, 'Astro::Coord::ECI' )
232 6 ▶ or $arg{sun} = Astro::Coord::ECI::Sun->new();
Branch: 1 branch
BranchTrueFalseTotal
embodies($arg{"sun"}, "Astro::Coord::ECI") or $arg{"sun"} = "Astro::Coord::ECI::Sun"->new 6 0 6
233  
234 defined $arg{twilight}
235 or $arg{twilight} = _dor(
236 6 ▶ $arg{body}->get( 'twilight' ),
Branch: 1 branch
BranchTrueFalseTotal
defined $arg{"twilight"} or $arg{"twilight"} = _dor($arg{"body"}->get("twilight"), deg2rad(-6)) 6 0 6
237 deg2rad( -6 ), # Civil
238 );
239  
240 defined $arg{time}
241 6 ▶ and embodies( $arg{station}, 'Astro::Coord::ECI' )
Branch: 1 branch
BranchTrueFalseTotal
defined $arg{"time"} and embodies($arg{"station"}, "Astro::Coord::ECI") or return "" 6 0 6
Condition33%1/3
defined $arg{"time"} and embodies($arg{"station"}, "Astro::Coord::ECI")
!ll&&!rl&&r
006
MC/DC0%0/2
defined $arg{"time"} and embodies($arg{"station"}, "Astro::Coord::ECI")
defined $arg{"time"} embodies($arg{"station"}, "Astro::Coord::ECI")
Truth table33%1/3
A and B
A= defined $arg{"time"}B= embodies($arg{"station"}, "Astro::Coord::ECI")
ABresult
0X0
100
111
242 # and _elevation( $arg{station}, $arg{body}, $arg{time} ) >= 0
243 or return PASS_EVENT_NONE;
244  
245 $arg{body}->illuminated( $arg{time} )
246 6 ▶ or return PASS_EVENT_SHADOWED;
Branch: 1 branch
BranchTrueFalseTotal
$arg{"body"}->illuminated($arg{"time"}) or return "shdw" 6 0 6
247  
248 _elevation( $arg{station}, $arg{sun}, $arg{time} ) > $arg{twilight}
249 6 ▶ and _elevation( $arg{station}, $arg{body}, $arg{time} ) >= 0
Branch: 1 branch
BranchTrueFalseTotal
_elevation($arg{"station"}, $arg{"sun"}, $arg{"time"}) > $arg{"twilight"} and _elevation($arg{"station"}, $arg{"body"}, $arg{"time"}) >= 0 and return "day" 0 6 6
Condition33%1/3
_elevation($arg{"station"}, $arg{"sun"}, $arg{"time"}) > $arg{"twilight"} and _elevation($arg{"station"}, $arg{"body"}, $arg{"time"}) >= 0
!ll&&!rl&&r
600
MC/DC0%0/2
_elevation($arg{"station"}, $arg{"sun"}, $arg{"time"}) > $arg{"twilight"} and _elevation($arg{"station"}, $arg{"body"}, $arg{"time"}) >= 0
_elevation($arg{"station"}, $arg{"sun"}, $arg{"time"}) > $arg{"twilight"} _elevation($arg{"station"}, $arg{"body"}, $arg{"time"}) >= 0
Truth table33%1/3
A and B
A= _elevation($arg{"station"}, $arg{"sun"}, $arg{"time"}) > $arg{"twilight"}B= _elevation($arg{"station"}, $arg{"body"}, $arg{"time"}) >= 0
ABresult
0X0
100
111
250 and return PASS_EVENT_DAY;
251  
252 6 return PASS_EVENT_LIT;
253 }
254  
255 36 ▶sub center {
Subroutine center: called CC=1 SCAR=0.0
Pod documented
256 36 my ( $self ) = @_;
257 36 return $self->_variant( 'center' );
258 }
259  
260 5 ▶sub earth {
Subroutine earth: called CC=1 SCAR=0.0
Pod documented
261 5 my ( $self ) = @_;
262 5 my $earth = $self->_variant();
263 5 $earth->{data}{station} = Astro::Coord::ECI->new()->ecef( 0, 0, 0 );
264 5 return $earth;
265 }
266  
267 31 ▶sub events {
Subroutine events: called CC=1 SCAR=0.0
Pod documented
268 31 my ( $self ) = @_;
269 31 return [ map { $self->clone( data => $_ ) } $self->__raw_events() ];
270 }
271  
272 2 ▶sub tle_events {
Subroutine tle_events: called CC=3 SCAR=11.0
Pod documented
273 2 my ( $self ) = @_;
274 2 my @rslt;
275  
276 2 foreach my $evt ( $self->__raw_events() ) {
277 10 ▶ embodies( $evt->{body}, 'Astro::Coord::ECI::TLE' )
Branch: 1 branch
BranchTrueFalseTotal
embodies($evt->{"body"}, "Astro::Coord::ECI::TLE") or next 8 2 10
278 or next;
279 8 push @rslt, $self->clone( data => $evt );
280 }
281 2 return \@rslt;
282 }
283  
284 36 ▶sub __raw_events {
Subroutine __raw_events: called CC=3 SCAR=11.3
285 36 my ( $self ) = @_;
286  
287 36 ▶ my $events = $self->_get( data => 'events' )
Branch: 1 branch
BranchTrueFalseTotal
my $events = $self->_get("data", "events") or return 36 0 36
288 or return;
289  
290 36 ▶ ARRAY_REF eq ref $events
Branch: 1 branch
BranchTrueFalseTotal
"ARRAY" eq ref $events or return 36 0 36
291 or return;
292  
293 36 return @{ $events };
294 }
295  
296 20 ▶sub reflections {
Subroutine reflections: called CC=11 SCAR=31.2
Pod documented
297 20 my ( $self ) = @_;
298  
299 20 ▶ my $body = $self->_get_tle( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_tle("body") or return 6 14 20
300 or return;
301  
302 6 ▶ my $sta = $self->_get_eci( 'station' )
Branch: 1 branch
BranchTrueFalseTotal
my $sta = $self->_get_eci("station") or return 6 0 6
303 or return;
304  
305 6 my $time = $self->_get( data => 'time' );
306 6 ▶ defined $time
Branch: 1 branch
BranchTrueFalseTotal
defined $time or $time = $body->universal 6 0 6
307 or $time = $body->universal();
308 6 ▶ defined $time or return;
Branch: 1 branch
BranchTrueFalseTotal
defined $time or return 6 0 6
309  
310 6 my $illum = $self->_get( data => 'illumination' );
311 6 ▶ defined $illum
Branch: 1 branch
BranchTrueFalseTotal
defined $illum or $illum = _illumination("body", $body, "station", $sta, "time", $time) 6 0 6
312 or $illum = _illumination(
313 body => $body,
314 station => $sta,
315 time => $time,
316 );
317  
318 6 ▶ $illum
Branch: 1 branch
BranchTrueFalseTotal
$illum and "lit" == $illum || "day" == $illum and $body->can_flare($self->_get("data", "questionable")) or return 0 6 6
Condition33%3/9
$illum and "lit" == $illum || "day" == $illum and $body->can_flare($self->_get("data", "questionable"))
!ll&&!rl&&r
060
$illum and "lit" == $illum || "day" == $illum
!ll&&!rl&&r
006
"lit" == $illum or "day" == $illum
l!l&&r!l&&!r
600
MC/DC0%0/4
$illum and "lit" == $illum || "day" == $illum and $body->can_flare($self->_get("data", "questionable"))
$illum "lit" == $illum "day" == $illum $body->can_flare($self->_get("data", "questionable"))
Truth table16%1/6
A and B or C and D
A= $illumB= "lit" == $illumC= "day" == $illumD= $body->can_flare($self->_get("data", "questionable"))
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
319 and ( PASS_EVENT_LIT == $illum
320 or PASS_EVENT_DAY == $illum )
321 and $body->can_flare( $self->_get( data => 'questionable' ) )
322 or return;
323  
324 0 $body->set( horizon => 0 );
325 0 my @rslt;
326 0 foreach my $info ( $body->reflection( $sta, $time ) ) {
327 0 push @rslt, $self->_variant( $info );
328 }
329  
330 0 return \@rslt;
331 }
332  
333 39 ▶sub station {
Subroutine station: called CC=1 SCAR=0.0
Pod documented
334 39 my ( $self ) = @_;
335 39 my $station = $self->_variant();
336 ( $station->{data}{body}, $station->{data}{station} ) = (
337 39 map { $station->_get( data => $_ ) } qw{ station body } );
338 39 return $station;
339 }
340  
341 # Formatters
342  
343 23 ▶sub list {
Subroutine list: called CC=1 SCAR=0.0
Pod documented
344 23 my ( $self, %arg ) = _arguments( @_ );
345 23 return $self->{list_formatter}->( $self, %arg );
346 }
347  
348 3 ▶sub __list_formatter {
Subroutine __list_formatter: called CC=4 SCAR=14.1
349 3 my ( $self, @arg ) = _arguments( @_ );
350 3 my $body;
351 3 ▶ my $type = ( $body = $self->body() ) ?
Branch: 1 branch
BranchTrueFalseTotal
($body = $self->body) ? : 2 1 3
352 $body->__list_type() :
353 'inertial';
354 3 my $code;
355 3 ▶ $code = $self->can( "__list_formatter_$type" )
Branch: 1 branch
BranchTrueFalseTotal
$code = $self->can("__list_formatter_$type") and return &$code($self, @arg) 0 3 3
356 and return $code->( $self, @arg );
357 3 ▶ $code = $self->can( "__list_formatter_args_$type" ) ||
Condition33%1/3
$self->can("__list_formatter_args_$type") || $self->can('__list_formatter_args_inertial')
l!l&&r!l&&!r
300
MC/DC0%0/2
$self->can("__list_formatter_args_$type") || $self->can('__list_formatter_args_inertial')
$self->can("__list_formatter_args_$type") $self->can('__list_formatter_args_inertial')
Truth table33%1/3
A || B
A= $self->can("__list_formatter_args_$type")B= $self->can('__list_formatter_args_inertial')
ABresult
1X1
011
000
358 $self->can( '__list_formatter_args_inertial' );
359 3 my $rslt = join ' ', map { $self->$_( @arg ) } $code->( $self );
360 3 $rslt =~ s/ \s+ \z //smx;
361 3 return $rslt;
362 }
363  
364 1 ▶sub __list_formatter_args_fixed {
Subroutine __list_formatter_args_fixed: called CC=1 SCAR=0.0
365 1 return ( qw{ oid name latitude longitude altitude } );
366 }
367  
368 2 ▶sub __list_formatter_args_inertial {
Subroutine __list_formatter_args_inertial: called CC=1 SCAR=0.0
369 2 return ( qw{ oid name epoch period } );
370 }
371  
372 205 ▶sub local_coord {
Subroutine local_coord: called CC=1 SCAR=0.0
Pod documented
373 205 my ( $self, %arg ) = _arguments( @_ );
374 205 return $self->{local_coordinates}->( $self, %arg );
375 }
376  
377 1 ▶sub __local_coord_az_rng {
Subroutine __local_coord_az_rng: called CC=1 SCAR=0.0
378 1 my ( $self, @arg ) = _arguments( @_ );
379 1 return join ' ', $self->azimuth( @arg, { bearing => 2 } ),
380 $self->range( @arg );
381 }
382  
383 1 ▶sub __local_coord_azel {
Subroutine __local_coord_azel: called CC=1 SCAR=0.0
384 1 my ( $self, @arg ) = _arguments( @_ );
385 1 return join ' ', $self->elevation( @arg ),
386 $self->azimuth( @arg, { bearing => 2 } );
387 }
388  
389 3 ▶sub __local_coord_azel_rng {
Subroutine __local_coord_azel_rng: called CC=1 SCAR=0.0
390 3 my ( $self, @arg ) = _arguments( @_ );
391 3 return join ' ', $self->elevation( @arg ),
392 $self->azimuth( @arg, { bearing => 2 } ),
393 $self->range( @arg );
394 }
395  
396 1 ▶sub __local_coord_equatorial {
Subroutine __local_coord_equatorial: called CC=1 SCAR=0.0
397 1 my ( $self, @arg ) = _arguments( @_ );
398 1 return join ' ', $self->right_ascension( @arg ),
399 $self->declination( @arg );
400 }
401  
402 1 ▶sub __local_coord_equatorial_rng {
Subroutine __local_coord_equatorial_rng: called CC=1 SCAR=0.0
403 1 my ( $self, @arg ) = _arguments( @_ );
404 1 return join ' ', $self->right_ascension( @arg ),
405 $self->declination( @arg ),
406 $self->range( @arg );
407 }
408  
409 # The %dimensions hash defines physical dimensions and the
410 # allowable units for each. The keys of this hash are the names of
411 # physical dimensions (e.g. 'length', 'mass', 'volume', and so
412 # on), and the values are hashes defining the dimension.
413 #
414 # Each dimension definition hash must have the following keys:
415 #
416 # align_left => boolean
417 # This optional key, if true, specifies that the value is to
418 # be aligned to the left in its field. This value can be
419 # overridden in the {define} key, or when the formatter is
420 # called.
421 #
422 # default => the name of the default units for the dimension. This
423 # value must appear as a key in the define hash (see below).
424 # This default can be overridden by a given format effector.
425 #
426 # define => a hash defining the legal units for the dimension. The
427 # keys are the names of the units (e.g. for length
428 # 'kilometers', 'meters', 'miles', 'feet'). The value is a
429 # hash containing zero or more of the following keys:
430 #
431 # alias => name
432 # This optional key specifies that the name is just an
433 # alias for another key, which must exist in the define
434 # hash. No other keys need be specified.
435 #
436 # align_left => boolean
437 # This optional key, if true, specifies that the value is
438 # to be aligned to the left of its field. It can be
439 # overridden by a value specified when the formatter is
440 # called.
441 #
442 # factor => number
443 # A number to multiply the value by to do the conversion.
444 #
445 # formatter => name
446 # This optional key specifies the name of the formatter
447 # routine to use instead of the normal one.
448 #
449 # method => _name
450 # This optional key specifies a method to call. The method
451 # is passed the value being formatted, and the method's
452 # return becomes the new value to format. If both {factor}
453 # and {method} are specified, {method} is done first.
454 #
455 # formatter => name
456 # This key specifies the formatter to use for the units. It
457 # can be overridden in the {define} key.
458  
459 11 my %dimensions = (
460  
461 almanac_pseudo_units => {
462 default => 'description',
463 define => {
464 event => {},
465 detail => {
466 formatter => '_format_integer',
467 },
468 description => {},
469 },
470 formatter => '_format_string',
471 },
472  
473 angle_units => {
474 align_left => 0,
475 default => 'degrees',
476 define => {
477 bearing => {
478 align_left => 1,
479 formatter => '_format_bearing',
480 },
481 decimal => {
482 alias => 'degrees',
483 },
484 degrees => {
485 factor => 90/atan2( 1, 0 ),
486 },
487 radians => {},
488 phase => {
489 align_left => 1,
490 formatter => '_format_phase',
491 },
492 right_ascension => {
493 formatter => '_format_right_ascension',
494 },
495 },
496 formatter => '_format_number',
497 },
498  
499 dimensionless => {
500 default => 'unity',
501 define => {
502 percent => {
503 factor => 100,
504 },
505 unity => {},
506 },
507 formatter => '_format_number',
508 },
509  
510 duration => {
511 default => 'composite',
512 define => {
513 composite => {
514 formatter => '_format_duration',
515 },
516 seconds => {},
517 minutes => {
518 factor => 1/60,
519 },
520 hours => {
521 factor => 1/3600,
522 },
523 days => {
524 factor => 1/86400,
525 },
526 },
527 formatter => '_format_number',
528 },
529  
530 event_pseudo_units => {
531 default => 'localized',
532 define => {
533 localized => {},
534 integer => {
535 formatter => '_format_integer',
536 },
537 string => {},
538 },
539 formatter => '_format_event',
540 },
541  
542 integer_pseudo_units => {
543 align_left => 0,
544 default => 'integer',
545 define => {
546 integer => {},
547 },
548 formatter => '_format_integer',
549 },
550  
551 length => {
552 align_left => 0,
553 default => 'kilometers',
554 define => {
555 kilometers => {},
556 km => {},
557 meters => {
558 factor => 1000,
559 },
560 m => {
561 alias => 'meters',
562 },
563 miles => {
564 factor => 0.62137119,
565 },
566 mi => {
567 alias => 'miles',
568 },
569 feet => {
570 factor => 3280.8399,
571 },
572 ft => {
573 alias => 'feet',
574 },
575 },
576 formatter => '_format_number',
577 },
578  
579 number => { # Just for consistency's sake
580 align_left => 0,
581 default => 'number',
582 define => {
583 number => {},
584 },
585 formatter => '_format_number',
586 },
587  
588 scientific => { # Just for consistency's sake
589 align_left => 0,
590 default => 'scientific',
591 define => {
592 scientific => {},
593 },
594 formatter => '_format_number_scientific',
595 },
596  
597 string => { # for tle, to prevent munging data. ONLY
598 # 'string' is to be defined.
599 default => 'string',
600 define => {
601 string => {},
602 },
603 formatter => '_format_string',
604 },
605  
606 string_pseudo_units => {
607 default => 'string',
608 define => {
609 lower_case => {
610 formatter => '_format_lower_case',
611 },
612 string => {},
613 title_case => {
614 formatter => '_format_title_case',
615 },
616 upper_case => {
617 formatter => '_format_upper_case',
618 },
619 },
620 formatter => '_format_string',
621 },
622  
623 time_units => {
624 default => 'local',
625 define => {
626 days_since_epoch => {
627 factor => 1/86400,
628 formatter => '_format_number',
629 method => '_subtract_epoch',
630 },
631 gmt => {
632 gmt => 1,
633 },
634 julian => {
635 formatter => '_format_number',
636 method => '_julian_day',
637 },
638 local => {},
639 universal => {
640 alias => 'gmt',
641 },
642 z => {
643 alias => 'gmt',
644 },
645 zulu => {
646 alias => 'gmt',
647 },
648 },
649 formatter => '_format_time',
650 },
651  
652 );
653  
654 # The following was for a utility script to generate documentation for
655 # the dimensions.
656 #
657 # sub __get_dimension_data {
658 # my ( $class, $name ) = @_;
659 # return $dimensions{$name};
660 # }
661  
662 # The following hash is used for generating formatter methods, as
663 # a way of avoiding the replication of common code. The keys are
664 # the method names, and the values are hashes which specify the
665 # method to generate. If the named method already exists, it is
666 # not replaced.
667 #
668 # The hash specifying each method contains the following keys,
669 # which are all requited unless the documentation for the key says
670 # otherwise.
671 #
672 # {chain} - An optional code reference which may (but need not)
673 # expand the formatter to produce multiple representations of
674 # the same value. It takes the arguments ( $self, $name,
675 # $value, $arg ) where $self is the invocant, $name is the
676 # name of the formatter method, $value is the value being
677 # formatted, and $arg is the formatter arguments, which have
678 # already had the defaults applied. It returns at least one
679 # argument hash. If it returns more than one, the same value
680 # is formatted using each set of arguments, with the results
681 # made into a single string using join( ' ', ... ). The
682 # returned argument sets MUST keep the same field width for
683 # the same arguments.
684 #
685 # This is used only for azimuth(), to process the 'bearing'
686 # argument.
687 #
688 # {default} - A hash specifying all legal arguments, and their
689 # default values. You can specify undef to make the argument
690 # legal but give it no value (i.e. to pick up the value from
691 # somewhere else).
692 #
693 # {dimension} - A hash specifying the dimension of the value to be
694 # formatted. This must contain a {dimension} key specifying
695 # the name of the dimension, and may contain a {units} value
696 # overriding the default units.
697 #
698 # {fetch} - A code reference which returns the value to be
699 # formatted. It will be passed arguments ( $self, $name, $arg
700 # ), where $self is the invocant, $name is the name of the
701 # formatter method, and $arg is a refernce to the arguments
702 # hash, which has already had _apply_defaults() called on it.
703 # This code is _not_ called if the invocant was initialized
704 # with title => 1.
705 #
706 # {locale} - A hash specifying last-ditch localization
707 # information. The keys are locale, the formatter name
708 # (yes, this is a duplicate) and the item name.
709  
710 my %formatter_data = ( # For generating formatters
711  
712 almanac => {
713 default => {
714 width => 40,
715 },
716 dimension => {
717 dimension => 'almanac_pseudo_units',
718 },
719 48 ▶ fetch => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
720 48 my ( $self, undef, $arg ) = @_; # $name unused
721 48 ▶ my $field = $arg->{units} ||= 'description';
Condition100%2/2
$arg->{"units"} ||= "description"
l!l
3216
MC/DC100%1/1
$arg->{"units"} ||= "description"
$arg->{"units"}
Truth table100%2/2
A
A= $arg->{"units"}
Aresult
11
00
722 48 return $self->_get( data => almanac => $field );
723 },
724 },
725  
726 altitude => {
727 default => {
728 places => 1,
729 width => 7,
730 },
731 dimension => {
732 dimension => 'length',
733 },
734 119 ▶ fetch => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
735 119 my ( $self ) = @_; # $name, $arg unused
736 119 my $value;
737 119 ▶ if ( my $body = $self->_get_eci( 'body' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $body = $self->_get_eci("body")) 119 0 119
738 119 $value = ( $body->geodetic() )[2];
739 }
740 119 return $value;
741 },
742 },
743  
744 angle => {
745 default => {
746 places => 1,
747 width => 5,
748 },
749 dimension => {
750 dimension => 'angle_units',
751 },
752 15 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
753 15 my ( $self ) = @_; # $name, $arg unused
754 15 return $self->_get( data => 'angle' );
755 },
756 },
757  
758 apoapsis => {
759 default => {
760 as_altitude => 1,
761 places => 0,
762 width => 6,
763 },
764 dimension => {
765 dimension => 'length',
766 },
767 24 ▶ fetch => sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
768 24 my ( $self, $name, $arg ) = @_;
769  
770 24 my $body;
771 24 ▶ $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
$body = $self->_get_eci("body") and $body->can($name) or return undef 12 12 24
Condition100%3/3
$body = $self->_get_eci("body") and $body->can($name)
!ll&&!rl&&r
4812
MC/DC100%2/2
$body = $self->_get_eci("body") and $body->can($name)
$body = $self->_get_eci("body") $body->can($name)
Truth table100%3/3
A and B
A= $body = $self->_get_eci("body")B= $body->can($name)
ABresult
0X0
100
111
772 and $body->can( $name )
773 or return NONE;
774  
775 12 my $value = $body->$name();
776  
777 12 ▶ if ( $arg->{as_altitude} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->{"as_altitude"}) 8 4 12
778 8 ▶ $body->can( 'semimajor' )
Branch: 1 branch
BranchTrueFalseTotal
$body->can("semimajor") or return undef 8 0 8
779 or return NONE;
780 8 $value -= $body->get( 'semimajor' );
781 }
782  
783 12 return $value;
784 },
785 },
786  
787 # apogee => duplicated from apoapsis, below
788  
789 argument_of_perigee => {
790 default => {
791 places => 4,
792 width => 9,
793 },
794 dimension => {
795 dimension => 'angle_units',
796 },
797 6 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
798 6 my ( $self ) = @_; # $name, $arg unused
799 6 return $self->_get_tle_attr( body => 'argumentofperigee' );
800 },
801 },
802  
803 ascending_node => {
804 default => {
805 places => 2,
806 width => 11,
807 },
808 dimension => {
809 dimension => 'angle_units',
810 units => 'right_ascension',
811 },
812 7 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
813 7 my ( $self ) = @_; # $name, $arg unused
814 7 return $self->_get_tle_attr( body => 'ascendingnode' );
815 },
816 },
817  
818 azimuth => {
819 chain => \&__chain_bearing,
820 default => {
821 bearing => 0,
822 places => 1,
823 width => 5,
824 },
825 dimension => {
826 dimension => 'angle_units',
827 },
828 139 ▶ fetch => sub {
Subroutine __ANON__: called CC=3 SCAR=11.4
829 139 my ( $self ) = @_; # $name, $arg unused
830 139 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 139 0 139
831 or return NONE;
832 139 ▶ my $station = $self->_get_eci( 'station' )
Branch: 1 branch
BranchTrueFalseTotal
my $station = $self->_get_eci("station") or return undef 139 0 139
833 or return NONE;
834 139 return ( $station->azel( $body ) )[0];
835 },
836 },
837  
838 b_star_drag => {
839 default => {
840 places => 4,
841 width => 11,
842 },
843 dimension => {
844 dimension => 'scientific',
845 },
846 4 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
847 4 my ( $self ) = @_; # $name, $arg unused
848 4 return $self->_get_tle_attr( body => 'bstardrag' );
849 },
850 },
851  
852 classification => {
853 default => {
854 width => 1,
855 },
856 dimension => {
857 dimension => 'string_pseudo_units',
858 },
859 3 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
860 3 my ( $self ) = @_; # $name, $arg unused
861 3 return $self->_get_tle_attr( body => 'classification' );
862 },
863 },
864  
865 date => {
866 default => {
867 delta => 0,
868 format => undef, # Just to get it looked at
869 gmt => undef,
870 places => 5,
871 round_time => undef, # Just to get it looked at
872 width => '',
873 },
874 dimension => {
875 dimension => 'time_units',
876 format => [ 'date_format' ],
877 },
878 92 ▶ fetch => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
879 92 my ( $self, undef, $arg ) = @_; # $name not used
880 92 ▶ defined( my $value = $self->_get( data => 'time' ) )
Branch: 1 branch
BranchTrueFalseTotal
defined(my $value = $self->_get("data", "time")) or return undef 92 0 92
881 or return NONE;
882 92 return $value + $arg->{delta};
883 },
884 },
885  
886 declination => {
887 default => {
888 places => 1,
889 width => 5,
890 },
891 dimension => {
892 dimension => 'angle_units',
893 },
894 22 ▶ fetch => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
895 22 my ( $self ) = @_; # $name, $arg unused
896 22 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 21 1 22
897 or return NONE;
898 21 ▶ my $station = $self->_get_eci( 'station' )
Branch: 1 branch
BranchTrueFalseTotal
my $station = $self->_get_eci("station") or return undef 21 0 21
899 or return NONE;
900 21 return ( $self->_get_precessed_coordinates(
901 equatorial => $body, $station ) )[ 1 ];
902 },
903 },
904  
905 eccentricity => {
906 default => {
907 places => 5,
908 width => 8,
909 },
910 dimension => {
911 dimension => 'dimensionless',
912 },
913 3 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
914 3 my ( $self ) = @_; # $name, $arg unused
915 3 return $self->_get_tle_attr( body => 'eccentricity' );
916 },
917 },
918  
919 effective_date => {
920 default => {
921 format => undef, # Just to get it looked at
922 gmt => undef,
923 places => '',
924 round_time => undef, # Just to get it looked at
925 width => '',
926 },
927 dimension => {
928 dimension => 'time_units',
929 format => [ 'date_format', 'time_format' ],
930 },
931 6 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
932 6 my ( $self ) = @_; # $name, $arg unused
933 6 return $self->_get_tle_attr( body => 'effective' );
934 },
935 },
936  
937 element_number => {
938 default => {
939 align_left => 0,
940 width => 4,
941 },
942 dimension => {
943 dimension => 'string',
944 },
945 3 ▶ fetch => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
946 3 my ( $self ) = @_; # $name, $arg unused
947 3 my $value = $self->_get_tle_attr( body => 'elementnumber' );
948 3 ▶ defined $value and $value =~ s/ \A \s+ //sxm;
Branch: 1 branch
BranchTrueFalseTotal
defined $value and $value =~ s/ \A \s+ //msx 3 0 3
949 3 return $value;
950 },
951 },
952  
953 elevation => {
954 default => {
955 places => 1,
956 width => 5,
957 },
958 dimension => {
959 dimension => 'angle_units',
960 },
961 128 ▶ fetch => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
962 128 my ( $self ) = @_; # $name, $arg unused
963 128 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 127 1 128
964 or return NONE;
965 127 ▶ my $station = $self->_get_eci( 'station' )
Branch: 1 branch
BranchTrueFalseTotal
my $station = $self->_get_eci("station") or return undef 127 0 127
966 or return NONE;
967 127 return ( $station->azel( $body ) )[1];
968 },
969 },
970  
971 ephemeris_type => {
972 default => {
973 width => 1,
974 },
975 dimension => {
976 dimension => 'string_pseudo_units',
977 },
978 6 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
979 6 my ( $self ) = @_; # $name, $arg unused
980 6 return $self->_get_tle_attr( body => 'ephemeristype' );
981 },
982 },
983  
984 epoch => {
985 default => {
986 format => undef, # Just to get it looked at
987 gmt => undef,
988 places => '',
989 round_time => undef, # Just to get it looked at
990 width => '',
991 },
992 dimension => {
993 dimension => 'time_units',
994 format => [ 'date_format', 'time_format' ],
995 },
996 36 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
997 36 my ( $self ) = @_; # $name, $arg unused
998 36 return $self->_get_tle_attr( body => 'epoch' );
999 },
1000 },
1001  
1002 event => {
1003 default => {
1004 width => 5,
1005 },
1006 dimension => {
1007 dimension => 'event_pseudo_units',
1008 },
1009 262 ▶ fetch => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
1010 262 my ( $self, $name ) = @_; # $arg unused
1011 262 ▶ defined( my $value = $self->_get( data => $name ) )
Branch: 1 branch
BranchTrueFalseTotal
defined(my $value = $self->_get("data", $name)) or return undef 262 0 262
1012 or return NONE;
1013 262 return $value;
1014 },
1015 },
1016  
1017 first_derivative => {
1018 default => {
1019 places => 10,
1020 width => 17,
1021 },
1022 dimension => {
1023 dimension => 'angle_units',
1024 formatter => '_format_number_scientific',
1025 },
1026 6 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1027 6 my ( $self ) = @_; # $name, $arg unused
1028 6 return $self->_get_tle_attr( body => 'firstderivative' );
1029 },
1030 },
1031  
1032 fraction_lit => {
1033 default => {
1034 places => 2,
1035 width => 4,
1036 },
1037 dimension => {
1038 dimension => 'dimensionless',
1039 },
1040 7 ▶ fetch => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1041 7 my ( $self ) = @_; # $name, $arg unused
1042 7 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 6 1 7
1043 or return NONE;
1044 6 ▶ $body->can( 'phase' )
Branch: 1 branch
BranchTrueFalseTotal
$body->can("phase") or return undef 4 2 6
1045 or return NONE;
1046 4 return ( $body->phase() )[1];
1047 },
1048 },
1049  
1050 illumination => {
1051 default => {
1052 width => 5,
1053 },
1054 dimension => {
1055 dimension => 'event_pseudo_units',
1056 },
1057 135 ▶ fetch => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1058 135 my ( $self, $name ) = @_; # $arg unused
1059 135 my $value;
1060 135 ▶ defined( $value = $self->_get( data => $name ) )
Branch: 1 branch
BranchTrueFalseTotal
defined($value = $self->_get("data", $name)) and $value ne "" and return $value 119 16 135
Condition100%3/3
defined($value = $self->_get("data", $name)) and $value ne ""
!ll&&!rl&&r
214119
MC/DC100%2/2
defined($value = $self->_get("data", $name)) and $value ne ""
defined($value = $self->_get("data", $name)) $value ne ""
Truth table100%3/3
A and B
A= defined($value = $self->_get("data", $name))B= $value ne ""
ABresult
0X0
100
111
1061 and $value ne ''
1062 and return $value;
1063 16 return NONE;
1064 },
1065 },
1066  
1067 inclination => {
1068 default => {
1069 places => 4,
1070 width => 8,
1071 },
1072 dimension => {
1073 dimension => 'angle_units',
1074 },
1075 6 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1076 6 my ( $self ) = @_; # $name, $arg unused
1077 6 return $self->_get_tle_attr( body => 'inclination' );
1078 },
1079 },
1080  
1081 inertial => {
1082 default => {
1083 width => 1,
1084 },
1085 dimension => {
1086 dimension => 'integer_pseudo_units',
1087 },
1088 4 ▶ fetch => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1089 4 my ( $self ) = @_; # $name, $arg unused
1090 4 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 3 1 4
1091 or return NONE;
1092 3 ▶ return $body->get( 'inertial' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$body->get('inertial') ? : 1 2 3
1093 },
1094 },
1095  
1096 international => {
1097 default => {
1098 align_left => 1,
1099 width => 8,
1100 },
1101 dimension => {
1102 dimension => 'string_pseudo_units',
1103 },
1104 6 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1105 6 my ( $self ) = @_; # $name, $arg unused
1106 6 return $self->_get_tle_attr( body => 'international' );
1107 },
1108 },
1109  
1110 latitude => {
1111 default => {
1112 places => 4,
1113 width => 8,
1114 },
1115 dimension => {
1116 dimension => 'angle_units',
1117 },
1118 110 ▶ fetch => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1119 110 my ( $self ) = @_; # $name, $arg unused
1120 110 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 109 1 110
1121 or return NONE;
1122 109 return ( $body->geodetic() )[0];
1123 },
1124 },
1125  
1126 longitude => {
1127 default => {
1128 places => 4,
1129 width => 9,
1130 },
1131 dimension => {
1132 dimension => 'angle_units',
1133 },
1134 110 ▶ fetch => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1135 110 my ( $self ) = @_; # $name, $arg unused
1136 110 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 109 1 110
1137 or return NONE;
1138 109 return ( $body->geodetic() )[1];
1139 },
1140 },
1141  
1142 magnitude => {
1143 default => {
1144 align_left => 0,
1145 places => 1,
1146 width => 4,
1147 },
1148 dimension => {
1149 dimension => 'number',
1150 },
1151 4 ▶ fetch => sub {
Subroutine __ANON__: called CC=7 SCAR=20.6
1152 4 my ( $self ) = @_; # $name, $arg unused
1153 4 my $mag;
1154 4 ▶ defined( $mag = $self->_get( data => 'magnitude' ) )
Branch: 1 branch
BranchTrueFalseTotal
defined($mag = $self->_get("data", "magnitude")) and return $mag 0 4 4
1155 and return $mag;
1156  
1157 4 my ( $body, $sta );
1158 4 ▶ $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
$body = $self->_get_eci("body") and $body->can("magnitude") and $sta = $self->_get_eci("station") or return undef 1 3 4
Condition83%5/6
$body = $self->_get_eci("body") and $body->can("magnitude") and $sta = $self->_get_eci("station")
!ll&&!rl&&r
301
$body = $self->_get_eci("body") and $body->can("magnitude")
!ll&&!rl&&r
121
MC/DC66%2/3
$body = $self->_get_eci("body") and $body->can("magnitude") and $sta = $self->_get_eci("station")
$body = $self->_get_eci("body") $body->can("magnitude") $sta = $self->_get_eci("station")
Truth table75%3/4
A and B and C
A= $body = $self->_get_eci("body")B= $body->can("magnitude")C= $sta = $self->_get_eci("station")
ABCresult
0XX0
10X0
1100
1111
1159 and $body->can( 'magnitude' )
1160 and $sta = $self->_get_eci( 'station' )
1161 or return NONE;
1162 1 ▶ if ( defined( my $time = $self->_get( data => 'time' ) ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined(my $time = $self->_get('data', 'time'))) { } 1 0 1
elsif (not defined $body->universal) { } 0 0 0
1163 1 $body->universal( $time );
1164 } elsif ( ! defined( $body->universal() ) ) {
1165 0 return NONE;
1166 }
1167 1 return $body->magnitude( $sta );
1168 },
1169 },
1170  
1171 maidenhead => {
1172 default => {
1173 width => 6,
1174 places => undef,
1175 },
1176 dimension => {
1177 dimension => 'string_pseudo_units',
1178 },
1179 6 ▶ fetch => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
1180 6 my ( $self, undef, $arg ) = @_; # $name unused
1181 6 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 5 1 6
1182 or return NONE;
1183 my $places = defined $arg->{places} ?
1184 $arg->{places} :
1185 $arg->{width} ?
1186 5 ▶ floor( $arg->{width} / 2 ) :
Branch: 2 branches
BranchTrueFalseTotal
defined $arg->{'places'} ? : 1 4 5
$arg->{'width'} ? : 3 1 4
1187 3;
1188 5 return ( $body->maidenhead( $places ) )[0];
1189 },
1190 },
1191  
1192 mean_anomaly => {
1193 default => {
1194 places => 4,
1195 width => 9,
1196 },
1197 dimension => {
1198 dimension => 'angle_units',
1199 },
1200 6 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1201 6 my ( $self ) = @_; # $name, $arg unused
1202 6 return $self->_get_tle_attr( body => 'meananomaly' );
1203 },
1204 },
1205  
1206 mean_motion => {
1207 default => {
1208 places => 10,
1209 width => 12,
1210 },
1211 dimension => {
1212 dimension => 'angle_units',
1213 },
1214 6 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1215 6 my ( $self ) = @_; # $name, $arg unused
1216 6 return $self->_get_tle_attr( body => 'meanmotion' );
1217 },
1218 },
1219  
1220 mma => {
1221 default => {
1222 width => 3,
1223 },
1224 dimension => {
1225 dimension => 'string_pseudo_units',
1226 },
1227 4 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1228 4 my ( $self ) = @_; # $name, $arg unused
1229 4 return $self->_get( data => 'mma' );
1230 },
1231 },
1232  
1233 name => {
1234 default => {
1235 width => 24, # Per http://celestrak.com/NORAD/documentation/tle-fmt.asp
1236 },
1237 dimension => {
1238 dimension => 'string_pseudo_units',
1239 },
1240 77 ▶ fetch => sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
1241 77 my ( $self, undef, $arg ) = @_; # $name unused
1242 77 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 76 1 77
1243 or return NONE;
1244 76 my $value;
1245 76 ▶ defined( $value = $body->get( 'name' ) )
Branch: 1 branch
BranchTrueFalseTotal
defined($value = $body->get("name")) and return $value 38 38 76
1246 and return $value;
1247 defined $arg->{missing}
1248 and 'oid' eq $arg->{missing}
1249 38 ▶ and return $body->get( 'id' );
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"missing"} and "oid" eq $arg->{"missing"} and return $body->get("id") 1 37 38
Condition66%2/3
defined $arg->{"missing"} and "oid" eq $arg->{"missing"}
!ll&&!rl&&r
3701
MC/DC50%1/2
defined $arg->{"missing"} and "oid" eq $arg->{"missing"}
defined $arg->{"missing"} "oid" eq $arg->{"missing"}
Truth table66%2/3
A and B
A= defined $arg->{"missing"}B= "oid" eq $arg->{"missing"}
ABresult
0X0
100
111
1250 37 return NONE;
1251 },
1252 },
1253  
1254 oid => {
1255 default => {
1256 width => 6,
1257 },
1258 dimension => {
1259 dimension => 'string_pseudo_units',
1260 },
1261 59 ▶ fetch => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
1262 59 my ( $self, undef, $arg ) = @_; # $name unused
1263 59 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 58 1 59
1264 or return NONE;
1265 58 ▶ defined( my $value = $body->get( 'id' ) )
Branch: 1 branch
BranchTrueFalseTotal
defined(my $value = $body->get("id")) or return undef 57 1 58
1266 or return NONE;
1267 not defined $arg->{align_left}
1268 57 ▶ and $arg->{align_left} = $value !~ RE_ALL_DIGITS;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"align_left"} or $arg->{"align_left"} = !($value =~ / \A [0-9]+ \z /msx) 8 49 57
1269 57 return $value;
1270 },
1271 },
1272  
1273 operational => {
1274 default => {
1275 width => 1,
1276 },
1277 dimension => {
1278 dimension => 'string_pseudo_units',
1279 },
1280 4 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1281 4 my ( $self ) = @_; # $nane, $arg unused
1282 4 return $self->_get_tle_attr( body => 'status' );
1283 },
1284 },
1285  
1286 # periapsis => duplicated from apoapsis, below
1287  
1288 # perigee => duplicated from apoapsis, below
1289  
1290 period => {
1291 default => {
1292 places => 0,
1293 width => 12,
1294 },
1295 dimension => {
1296 dimension => 'duration',
1297 },
1298 18 ▶ fetch => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1299 18 my ( $self ) = @_; # $name, $arg unused
1300 18 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 17 1 18
1301 or return NONE;
1302 17 ▶ $body->can( 'period' )
Branch: 1 branch
BranchTrueFalseTotal
$body->can("period") or return undef 16 1 17
1303 or return NONE;
1304 16 return $body->period();
1305 },
1306 },
1307  
1308 phase => {
1309 default => {
1310 places => 0,
1311 width => 4,
1312 },
1313 dimension => {
1314 dimension => 'angle_units',
1315 },
1316 10 ▶ fetch => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1317 10 my ( $self ) = @_; # $name, $arg unused
1318 10 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 9 1 10
1319 or return NONE;
1320 9 ▶ $body->can( 'phase' )
Branch: 1 branch
BranchTrueFalseTotal
$body->can("phase") or return undef 6 3 9
1321 or return NONE;
1322 6 return ( $body->phase() )[0];
1323 },
1324 },
1325  
1326 range => {
1327 default => {
1328 places => 1,
1329 width => 10,
1330 },
1331 dimension => {
1332 dimension => 'length',
1333 },
1334 131 ▶ fetch => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1335 131 my ( $self ) = @_; # $name, $arg unused
1336 131 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 130 1 131
1337 or return NONE;
1338 130 ▶ my $station = $self->_get_eci( 'station' )
Branch: 1 branch
BranchTrueFalseTotal
my $station = $self->_get_eci("station") or return undef 130 0 130
1339 or return NONE;
1340 130 return ( $station->azel( $body ) )[2];
1341 },
1342 },
1343  
1344 revolutions_at_epoch => {
1345 default => {
1346 align_left => 0,
1347 width => 6,
1348 },
1349 dimension => {
1350 dimension => 'string',
1351 },
1352 6 ▶ fetch => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1353 6 my ( $self ) = @_; # $name, $arg unused
1354 6 my $value = $self->_get_tle_attr( body => 'revolutionsatepoch' );
1355 6 ▶ defined $value and $value =~ s/ \A \s+ //sxm;
Branch: 1 branch
BranchTrueFalseTotal
defined $value and $value =~ s/ \A \s+ //msx 3 3 6
1356 6 return $value;
1357 },
1358 },
1359  
1360 right_ascension => {
1361 default => {
1362 places => 0,
1363 width => 8,
1364 },
1365 dimension => {
1366 dimension => 'angle_units',
1367 units => 'right_ascension',
1368 },
1369 21 ▶ fetch => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1370 21 my ( $self ) = @_; # $name, $arg unused
1371 21 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 20 1 21
1372 or return NONE;
1373 20 ▶ my $station = $self->_get_eci( 'station' )
Branch: 1 branch
BranchTrueFalseTotal
my $station = $self->_get_eci("station") or return undef 20 0 20
1374 or return NONE;
1375 20 return ( $self->_get_precessed_coordinates(
1376 equatorial => $body, $station ) )[ 0 ];
1377 },
1378 },
1379  
1380 second_derivative => {
1381 default => {
1382 places => 10,
1383 width => 17,
1384 },
1385 dimension => {
1386 dimension => 'angle_units',
1387 formatter => '_format_number_scientific',
1388 },
1389 6 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1390 6 my ( $self ) = @_; # $name, $arg unused
1391 6 return $self->_get_tle_attr( body => 'secondderivative' );
1392 },
1393 },
1394  
1395 semimajor => {
1396 default => {
1397 places => 0,
1398 width => 6,
1399 },
1400 dimension => {
1401 dimension => 'length',
1402 },
1403 10 ▶ fetch => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1404 10 my ( $self, $name ) = @_; # $arg unused
1405 10 ▶ my $body = $self->_get_eci( 'body' )
Branch: 1 branch
BranchTrueFalseTotal
my $body = $self->_get_eci("body") or return undef 8 2 10
1406 or return NONE;
1407 8 ▶ $body->can( $name )
Branch: 1 branch
BranchTrueFalseTotal
$body->can($name) or return undef 4 4 8
1408 or return NONE;
1409 4 return $body->$name();
1410 },
1411 },
1412  
1413 # semiminor => duplicated from semimajor, below
1414  
1415 status => {
1416 default => {
1417 width => 60,
1418 },
1419 dimension => {
1420 dimension => 'string_pseudo_units',
1421 },
1422 5 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1423 5 my ( $self ) = @_; # $name, $arg unused
1424 5 return $self->_get( data => 'status' );
1425 },
1426 },
1427  
1428 time => {
1429 default => {
1430 delta => 0,
1431 format => undef, # Just to get it looked at
1432 gmt => undef,
1433 places => 5,
1434 round_time => undef, # Just to get it looked at
1435 width => '',
1436 },
1437 dimension => {
1438 dimension => 'time_units',
1439 format => [ 'time_format' ],
1440 },
1441 179 ▶ fetch => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
1442 179 my ( $self, undef, $arg ) = @_; # $name unused
1443 179 ▶ defined( my $value = $self->_get( data => 'time' ) )
Branch: 1 branch
BranchTrueFalseTotal
defined(my $value = $self->_get("data", "time")) or return undef 179 0 179
1444 or return NONE;
1445 179 return $value + $arg->{delta};
1446 },
1447 },
1448  
1449 tle => {
1450 default => {},
1451 dimension => {
1452 dimension => 'string',
1453 },
1454 8 ▶ fetch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1455 8 my ( $self ) = @_; # $name, $arg unused
1456 8 return $self->_get_tle_attr( body => 'tle' );
1457 },
1458 },
1459  
1460 type => {
1461 default => {
1462 align_left => 1,
1463 width => 3,
1464 },
1465 dimension => {
1466 dimension => 'string_pseudo_units',
1467 },
1468 0 ▶ fetch => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1469 0 my ( $self ) = @_; # $name, $arg unused
1470 0 return $self->_get( data => 'type' );
1471 },
1472 },
1473  
1474 11 );
1475  
1476 11 foreach my $fmtr_name ( keys %formatter_data ) {
1477 495 $formatter_data{$fmtr_name}{name} = $fmtr_name;
1478 }
1479  
1480 44 ▶sub _clone_formatter {
Subroutine _clone_formatter: called CC=1 SCAR=0.0
1481 44 my ( $from, $to ) = @_;
1482 44 %{ $formatter_data{$to} } = %{ $formatter_data{$from} };
1483 44 $formatter_data{$to}{name} = $to;
1484 44 return;
1485 }
1486  
1487 11 _clone_formatter( apoapsis => 'apogee' );
1488 11 _clone_formatter( apoapsis => 'periapsis' );
1489 11 _clone_formatter( apoapsis => 'perigee' );
1490 11 _clone_formatter( semimajor => 'semiminor' );
1491  
1492 1868 ▶sub _fetch {
Subroutine _fetch: called CC=5 SCAR=16.1
1493 1868 my ( $self, $info, $name, $arg ) = @_;
1494  
1495 1868 ▶ if ( ! $self->{internal}{time_set} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"internal"}{"time_set"}) 356 1512 1868
1496 356 ▶ if ( defined( my $time = $self->_get( data => 'time' ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $time = $self->_get("data", "time"))) 329 27 356
1497 329 foreach my $key ( qw{ body station } ) {
1498 658 ▶ my $obj = $self->_get_eci( $key )
Branch: 1 branch
BranchTrueFalseTotal
my $obj = $self->_get_eci($key) or next 606 52 658
1499 or next;
1500 606 $obj->universal( $time );
1501 }
1502 }
1503 356 $self->{internal}{time_set} = 1;
1504 }
1505 1868 return $info->{fetch}->( $self, $name, $arg );
1506 }
1507  
1508 0 ▶sub __list_formatter_names {
Subroutine __list_formatter_names: not called CC=1 SCAR=6.9
1509 0 return ( keys %formatter_data );
1510 }
1511  
1512 11 ▶sub __get_formatter_data {
Subroutine __get_formatter_data: called CC=2 SCAR=8.1
1513 11 my ( undef, $name ) = @_; # Invocant unused
1514 11 ▶ defined $name
Branch: 1 branch
BranchTrueFalseTotal
defined $name or return values %formatter_data 0 11 11
1515 or return ( values %formatter_data );
1516 0 return $formatter_data{$name};
1517 }
1518  
1519 # Used when the normal reporting mechanism is unavailable.
1520 0 ▶sub _confess {
Subroutine _confess: not called CC=1 SCAR=6.9
1521 0 my ( @arg ) = @_;
1522 0 require Carp;
1523 0 Carp::confess( @arg );
1524 }
1525  
1526 # Note that this implementation of add_formatter_method() modifies our
1527 # name space by adding a stub method that dispatches to the
1528 # object-specific code, or throws an error if there is none. The
1529 # previous implementation used AUTOLOAD, but this had problems on most
1530 # smokers involving calls to DESTROY(). I was never able to duplicate
1531 # these, and rather than try to figure out how to handle any and all
1532 # Perl-reserved subs, I decided to switch to an implementation which,
1533 # while still fairly grody, did not use AUTOLOAD.
1534 {
1535 11 my $fmtr_class = 'Astro::App::Satpass2::FormatValue::Formatter';
1536 11 my %defined_here;
1537 449 ▶ sub add_formatter_method {
Subroutine add_formatter_method: called CC=7 SCAR=19.7
Pod documented
1538 449 my ( $self, @formatters ) = @_;
1539 449 foreach my $fmtr_obj ( @formatters ) {
1540 instance( $fmtr_obj, $fmtr_class )
1541 or $self->{warner}->wail(
1542 3 ▶ "Formatters must be instances of $fmtr_class" );
Branch: 1 branch
BranchTrueFalseTotal
instance($fmtr_obj, $fmtr_class) or $self->{"warner"}->wail("Formatters must be instances of $fmtr_class") 3 0 3
1543 3 my $name = $fmtr_obj->name();
1544 $self->can( $name )
1545 and not $defined_here{$name}
1546 and $self->{warner}->wail(
1547 3 ▶ "Formatter $name can not override built-in format" );
Branch: 1 branch
BranchTrueFalseTotal
$self->can($name) and not $defined_here{$name} and $self->{"warner"}->wail("Formatter $name can not override built-in format") 0 3 3
Condition66%2/3
$self->can($name) and not $defined_here{$name}
!ll&&!rl&&r
120
MC/DC0%0/2
$self->can($name) and not $defined_here{$name}
$self->can($name) not $defined_here{$name}
Truth table66%2/3
A and not(B)
A= $self->can($name)B= not $defined_here{$name}
ABresult
0X0
100
111
1548 $self->{formatter_method}{$name}
1549 and $self->{warner}->wail(
1550 3 ▶ "Formatter $name can not replace previously-set formatter of same name" );
Branch: 1 branch
BranchTrueFalseTotal
$self->{"formatter_method"}{$name} and $self->{"warner"}->wail("Formatter $name can not replace previously-set formatter of same name") 0 3 3
1551 3 $self->{formatter_method}{$name} = $fmtr_obj;
1552 3 ▶ unless ( $defined_here{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($defined_here{$name}) 1 2 3
1553 1 $defined_here{$name} = 1;
1554 11 ▶ no strict qw{ refs };
Subroutine BEGIN: called CC=1 SCAR=0.0
1555 1 ▶ *$name = sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
1556 1 my ( $self ) = @_;
1557 my $obj = $self->{formatter_method}{$name}
1558 1 ▶ or $self->{warner}->wail( "No such formatter as '$name'" );
Branch: 1 branch
BranchTrueFalseTotal
my $obj = $self->{"formatter_method"}{$name} or $self->{"warner"}->wail("No such formatter as '${name}'") 1 0 1
1559 1 goto &{ $obj->code() };
1560 1 };
1561 }
1562 }
1563 449 return $self;
1564 }
1565 }
1566  
1567 11 ▶sub __make_formatter_code {
Subroutine __make_formatter_code: called CC=13 SCAR=27.2
1568 540 my ( $class, $fmtr ) = @_;
1569  
1570 540 ▶ HASH_REF eq ref $fmtr
Branch: 1 branch
BranchTrueFalseTotal
"HASH" eq ref $fmtr or _confess("The argument must be a HASH reference") 540 0 540
1571 or _confess( 'The argument must be a HASH reference' );
1572 defined( my $fmtr_name = $fmtr->{name} )
1573 540 ▶ or _confess( 'The {name} must be defined' );
Branch: 1 branch
BranchTrueFalseTotal
defined(my $fmtr_name = $fmtr->{"name"}) or _confess("The {name} must be defined") 540 0 540
1574  
1575 # Validate the dimension information
1576 $fmtr->{dimension}
1577 540 ▶ or _confess(
Branch: 1 branch
BranchTrueFalseTotal
$fmtr->{"dimension"} or _confess("'${fmtr_name}' does not specify a {dimension} hash") 540 0 540
1578 "'$fmtr_name' does not specify a {dimension} hash" );
1579 defined( my $dim_name = $fmtr->{dimension}{dimension} )
1580 540 ▶ or _confess(
Branch: 1 branch
BranchTrueFalseTotal
defined(my $dim_name = $fmtr->{"dimension"}{"dimension"}) or _confess("'${fmtr_name}' does not specify the dimension") 540 0 540
1581 "'$fmtr_name' does not specify the dimension" );
1582 540 ▶ $dimensions{$dim_name}
Branch: 1 branch
BranchTrueFalseTotal
$dimensions{$dim_name} or _confess("'${fmtr_name}' specifies invalid dimension '${dim_name}'") 540 0 540
1583 or _confess( "'$fmtr_name' specifies invalid dimension '$dim_name'" );
1584 540 ▶ if ( defined( my $dflt = $fmtr->{dimension}{default} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $dflt = $fmtr->{"dimension"}{"default"})) 0 540 540
1585 0 ▶ defined $dimensions{$dim_name}{define}{$dflt}
Branch: 1 branch
BranchTrueFalseTotal
defined $dimensions{$dim_name}{"define"}{$dflt} or _confess("'${fmtr_name}' specifies invalid default units '${dflt}'") 0 0 0
1586 or _confess( "'$fmtr_name' specifies invalid default units '$dflt'" );
1587 }
1588  
1589 # If the dimension is 'time_units' we need to validate that the
1590 # format key is defined and valid
1591 540 ▶ if ( 'time_units' eq $dim_name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("time_units" eq $dim_name) 44 496 540
1592 44 ▶ if ( ARRAY_REF eq ref $fmtr->{dimension}{format} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ('ARRAY' eq ref $fmtr->{'dimension'}{'format'}) { } 44 0 44
1593 44 foreach my $entry ( @{ $fmtr->{dimension}{format} } ) {
1594 66 ▶ $class->_valid_time_format_name( $entry )
Branch: 1 branch
BranchTrueFalseTotal
$class->_valid_time_format_name($entry) or _confess("In '${fmtr_name}', '${entry}' is not a valid format") 66 0 66
1595 or _confess(
1596 "In '$fmtr_name', '$entry' is not a valid format" );
1597 }
1598 403 ▶ $fmtr->{default}{format} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1599 403 my ( $self ) = @_;
1600 403 return $self->_get_date_format_data( $fmtr_name, format => $fmtr );
1601 44 };
1602 377 ▶ $fmtr->{default}{width} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1603 377 my ( $self ) = @_;
1604 377 return $self->_get_date_format_data( $fmtr_name, width => $fmtr );
1605 44 };
1606 } else {
1607 0 _confess(
1608 "'$fmtr_name' must specify a {format} key in {dimension}" );
1609 }
1610 408 ▶ $fmtr->{default}{round_time} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1611 408 my ( $self ) = @_;
1612 408 return $self->{round_time};
1613 44 };
1614 }
1615  
1616 # Validate the fetch information
1617 CODE_REF eq ref $fmtr->{fetch}
1618 540 ▶ or _confess(
Branch: 1 branch
BranchTrueFalseTotal
"CODE" eq ref $fmtr->{"fetch"} or _confess("In '${fmtr_name}', {fetch} is not a code reference") 540 0 540
1619 "In '$fmtr_name', {fetch} is not a code reference" );
1620  
1621 2526 ▶ return sub {
Subroutine __ANON__: called CC=6 SCAR=18.0
1622 2526 my ( $self, %arg ) = _arguments( @_ );
1623  
1624 2526 $self->_apply_defaults( \%arg, $fmtr );
1625  
1626 2526 ▶ my $value = ( $self->{title} || defined $arg{literal} ) ?
Branch: 1 branch
BranchTrueFalseTotal
$self->{'title'} || defined $arg{'literal'} ? : 658 1868 2526
Condition66%2/3
$self->{"title"} or defined $arg{"literal"}
l!l&&r!l&&!r
65801868
MC/DC50%1/2
$self->{"title"} or defined $arg{"literal"}
$self->{"title"} defined $arg{"literal"}
Truth table66%2/3
A or B
A= $self->{"title"}B= defined $arg{"literal"}
ABresult
1X1
011
000
1627 NONE :
1628 $self->_fetch( $fmtr, $fmtr_name, \%arg );
1629  
1630 2526 my @rslt;
1631 2526 ▶ foreach my $parm ( $fmtr->{chain} ?
Branch: 1 branch
BranchTrueFalseTotal
$fmtr->{'chain'} ? : 188 2338 2526
1632 $fmtr->{chain}->( $self, $fmtr_name, $value, \%arg ) :
1633 \%arg ) {
1634  
1635 push @rslt, defined $arg{literal} ?
1636 2662 ▶ $self->_format_string( $arg{literal}, \%arg, $fmtr ) :
Branch: 1 branch
BranchTrueFalseTotal
defined $arg{'literal'} ? : 0 2662 2662
1637 $self->_apply_dimension( $value, $parm, $fmtr );
1638  
1639 }
1640  
1641 2526 return join ' ', @rslt;
1642 540 };
1643 }
1644  
1645 11 ▶sub __make_formatter_methods {
Subroutine __make_formatter_methods: called CC=3 SCAR=11.0
1646 11 my ( $class ) = @_;
1647  
1648 11 foreach my $fmtr ( $class->__get_formatter_data() ) {
1649 539 my $fmtr_name = $fmtr->{name};
1650  
1651 539 ▶ $class->can( $fmtr_name )
Branch: 1 branch
BranchTrueFalseTotal
$class->can($fmtr_name) and next 0 539 539
1652 and next;
1653  
1654 539 my $fq = "${class}::$fmtr_name";
1655  
1656 11 ▶ no strict qw{ refs };
Subroutine BEGIN: called CC=1 SCAR=0.0
1657  
1658 539 *$fq = __PACKAGE__->__make_formatter_code( $fmtr );
1659  
1660 }
1661 11 return;
1662 }
1663  
1664 11 __PACKAGE__->__make_formatter_methods();
1665  
1666 # Title control
1667  
1668 # sub is_valid_title_gravity would normally be here, but in order to
1669 # reduce technical debt it shares a hash with _do_title(), and is placed
1670 # with it, below.
1671  
1672 116 ▶sub more_title_lines {
Subroutine more_title_lines: called CC=3 SCAR=11.0
Pod documented
1673 116 my ( $self ) = @_;
1674 exists $self->{internal}{_title_info}
1675 116 ▶ or return 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{"internal"}{"_title_info"} or return 1 79 37 116
1676 79 my $more;
1677 79 ▶ if ( $more = delete $self->{internal}{_title_info}{more} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($more = delete $self->{'internal'}{'_title_info'}{'more'}) { } 42 37 79
1678 42 $self->{internal}{_title_info}{inx}++
1679 } else {
1680 37 $self->reset_title_lines();
1681 }
1682 79 return $more;
1683 }
1684  
1685 37 ▶sub reset_title_lines {
Subroutine reset_title_lines: called CC=1 SCAR=0.0
Pod documented
1686 37 my ( $self ) = @_;
1687 37 delete $self->{internal}{_title_info};
1688 37 return;
1689 }
1690  
1691 # Private methods and subroutines of all sorts.
1692  
1693 {
1694  
1695 11 my @always = qw{ align_left missing title };
1696  
1697 2526 ▶ sub _apply_defaults {
Subroutine _apply_defaults: called CC=17 SCAR=28.4
1698 2526 my ( $self, $arg, $fmtr ) = @_;
1699  
1700 2526 my $fmtr_name = $fmtr->{name};
1701 2526 ▶ my $dflt = $fmtr->{default} || {};
Condition50%1/2
$fmtr->{'default'} || {}
l!l
25260
MC/DC0%0/1
$fmtr->{'default'} || {}
$fmtr->{'default'}
Truth table50%1/2
A
A= $fmtr->{'default'}
Aresult
11
00
1702  
1703 defined $arg->{width}
1704 or $self->{fixed_width}
1705 2526 ▶ or $arg->{width} = '';
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"width"} or $self->{"fixed_width"} or $arg->{"width"} = "" 2406 120 2526
Condition100%3/3
defined $arg->{"width"} or $self->{"fixed_width"}
l!l&&r!l&&!r
3082098120
MC/DC100%2/2
defined $arg->{"width"} or $self->{"fixed_width"}
defined $arg->{"width"} $self->{"fixed_width"}
Truth table100%3/3
A or B
A= defined $arg->{"width"}B= $self->{"fixed_width"}
ABresult
1X1
011
000
1706  
1707 2526 ▶ if ( defined $arg->{format} && ! defined $arg->{width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $arg->{"format"} and not defined $arg->{"width"}) 5 2521 2526
Condition66%2/3
defined $arg->{"format"} and not defined $arg->{"width"}
!ll&&!rl&&r
252105
MC/DC50%1/2
defined $arg->{"format"} and not defined $arg->{"width"}
defined $arg->{"format"} not defined $arg->{"width"}
Truth table66%2/3
A and not(B)
A= defined $arg->{"format"}B= not defined $arg->{"width"}
ABresult
0X0
100
111
1708 $arg->{width} = $self->{time_formatter}->
1709 5 format_datetime_width( $arg->{format} );
1710 }
1711  
1712 # TODO maybe apply locale here? But see also _do_title.
1713 APPLY_DEFAULT_LOOP:
1714 2526 foreach my $key ( keys %{ $dflt }, @always ) {
1715  
1716 13560 ▶ defined $arg->{$key} and next;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{$key} and next 937 12623 13560
1717  
1718 12623 foreach my $source ( qw{ default internal } ) {
1719 25227 ▶ defined( $arg->{$key} = $self->_get( $source, $fmtr_name,
Branch: 1 branch
BranchTrueFalseTotal
defined($arg->{$key} = $self->_get($source, $fmtr_name, $key)) and next APPLY_DEFAULT_LOOP 19 25208 25227
1720 $key ) )
1721 and next APPLY_DEFAULT_LOOP;
1722 }
1723  
1724 defined( $arg->{$key} = __localize(
1725 text => [ $fmtr_name, $key ],
1726 locale => $fmtr->{locale},
1727 12604 ▶ ) )
Branch: 1 branch
BranchTrueFalseTotal
defined($arg->{$key} = __localize("text", [$fmtr_name, $key], "locale", $fmtr->{"locale"})) and next 2483 10121 12604
1728 and next;
1729  
1730 10121 my $default = $dflt->{$key};
1731 10121 ▶ $arg->{$key} = CODE_REF eq ref $default ?
Branch: 1 branch
BranchTrueFalseTotal
'CODE' eq ref $default ? : 1188 8933 10121
1732 $default->( $self, $fmtr_name, $arg ) : $default
1733  
1734 }
1735  
1736 defined $arg->{width}
1737 2526 ▶ or $arg->{width} = '';
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"width"} or $arg->{"width"} = "" 2518 8 2526
1738 $arg->{width} =~ m/ \D /sxm
1739 2526 ▶ and $arg->{width} = '';
Branch: 1 branch
BranchTrueFalseTotal
$arg->{"width"} =~ / \D /msx and $arg->{"width"} = "" 0 2526 2526
1740  
1741 2526 ▶ if ( $self->{report} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"report"}) 2145 381 2526
1742 2145 my $report = "-$self->{report}";
1743 2145 foreach my $key ( qw{ literal missing title } ) {
1744 6435 ▶ defined $arg->{$key}
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{$key} or next 2166 4269 6435
1745 or next;
1746 $arg->{$key} = __localize(
1747 text => [ $report, 'string', $arg->{$key} ],
1748 default => $arg->{$key},
1749 locale => $fmtr->{locale},
1750 2166 );
1751 }
1752  
1753 }
1754  
1755 2526 return;
1756 }
1757  
1758 }
1759  
1760 11 ▶sub _apply_dimension {
Subroutine _apply_dimension: called CC=16 SCAR=28.2
1761 2662 my ( $self, $value, $arg, $fmtr ) = @_;
1762  
1763 2662 my $fmtr_name = $fmtr->{name};
1764 defined( my $dim_name = $fmtr->{dimension}{dimension} )
1765 2662 ▶ or $self->weep( 'No dimension specified' );
Branch: 1 branch
BranchTrueFalseTotal
defined(my $dim_name = $fmtr->{"dimension"}{"dimension"}) or $self->weep("No dimension specified") 2662 0 2662
1766  
1767 2662 my $dim;
1768 $dim = $dimensions{$dim_name}
1769 and defined( my $unit_name = _dor( $arg->{units}, $fmtr->{dimension}{units},
1770 $self->_get( default => $fmtr_name, 'units' ),
1771 2662 ▶ $dim->{default} ) )
Branch: 1 branch
BranchTrueFalseTotal
$dim = $dimensions{$dim_name} and defined(my $unit_name = _dor($arg->{"units"}, $fmtr->{"dimension"}{"units"}, $self->_get("default", $fmtr_name, "units"), $dim->{"default"})) or $self->weep("Dimension $dim_name undefined") 2662 0 2662
Condition33%1/3
$dim = $dimensions{$dim_name} and defined(my $unit_name = _dor($arg->{"units"}, $fmtr->{"dimension"}{"units"}, $self->_get("default", $fmtr_name, "units"), $dim->{"default"}))
!ll&&!rl&&r
002662
MC/DC0%0/2
$dim = $dimensions{$dim_name} and defined(my $unit_name = _dor($arg->{"units"}, $fmtr->{"dimension"}{"units"}, $self->_get("default", $fmtr_name, "units"), $dim->{"default"}))
$dim = $dimensions{$dim_name} defined(my $unit_name = _dor($arg->{"units"}, $fmtr->{"dimension"}{"units"}, $self->_get("default", $fmtr_name, "units"), $dim->{"default"}))
Truth table33%1/3
A and B
A= $dim = $dimensions{$dim_name}B= defined(my $unit_name = _dor($arg->{"units"}, $fmtr->{"dimension"}{"units"}, $self->_get("default", $fmtr_name, "units"), $dim->{"default"}))
ABresult
0X0
100
111
1772 or $self->weep( "Dimension $dim_name undefined" );
1773  
1774 my $unit = $dim->{define}{$unit_name}
1775 or $self->{warner}->wail(
1776 2662 ▶ "Units $unit_name not valid for $dim_name" );
Branch: 1 branch
BranchTrueFalseTotal
my $unit = $dim->{"define"}{$unit_name} or $self->{"warner"}->wail("Units $unit_name not valid for $dim_name") 2662 0 2662
1777  
1778 2662 ▶ if ( defined $unit->{alias} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $unit->{"alias"}) 13 2649 2662
1779 my $alias = $dim->{define}{$unit->{alias}}
1780 13 ▶ or $self->weep( "Undefined alias '$unit->{alias}'" );
Branch: 1 branch
BranchTrueFalseTotal
my $alias = $dim->{"define"}{$unit->{"alias"}} or $self->weep(qq[Undefined alias '$unit->{"alias"}']) 13 0 13
1781 13 $unit_name = $unit->{alias};
1782 13 $unit = $alias;
1783 }
1784  
1785 defined $arg->{align_left}
1786 or $arg->{align_left} = _dor( $unit->{align_left},
1787 2662 ▶ $dim->{align_left} );
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"align_left"} or $arg->{"align_left"} = _dor($unit->{"align_left"}, $dim->{"align_left"}) 224 2438 2662
1788  
1789 $self->{title}
1790 2662 ▶ and return $self->_do_title( $arg, $fmtr );
Branch: 1 branch
BranchTrueFalseTotal
$self->{"title"} and return $self->_do_title($arg, $fmtr) 658 2004 2662
1791  
1792 2004 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or return $self->_format_undef(undef, $arg, $fmtr) 1846 158 2004
1793 or return $self->_format_undef( undef, $arg, $fmtr );
1794  
1795 defined $unit->{method}
1796 1846 ▶ and do {
Branch: 1 branch
BranchTrueFalseTotal
defined $unit->{"method"} and do { my $method = $unit->{"method"}; defined($value = $self->$method($value)) or return $self->_format_undef(undef, $arg, $fmtr) } 8 1838 1846
1797 8 my $method = $unit->{method};
1798 8 ▶ defined( $value = $self->$method( $value ) )
Branch: 1 branch
BranchTrueFalseTotal
defined($value = $self->$method($value)) or return $self->_format_undef(undef, $arg, $fmtr) 7 1 8
1799 or return $self->_format_undef( undef, $arg, $fmtr );
1800 };
1801  
1802 defined $unit->{factor}
1803 1845 ▶ and $value *= $unit->{factor};
Branch: 1 branch
BranchTrueFalseTotal
defined $unit->{"factor"} and $value *= $unit->{"factor"} 554 1291 1845
1804  
1805 defined $unit->{gmt}
1806 and not defined $arg->{gmt}
1807 1845 ▶ and $arg->{gmt} = $unit->{gmt};
Branch: 1 branch
BranchTrueFalseTotal
defined $unit->{"gmt"} and not defined $arg->{"gmt"} and $arg->{"gmt"} = $unit->{"gmt"} 6 1839 1845
Condition66%2/3
defined $unit->{"gmt"} and not defined $arg->{"gmt"}
!ll&&!rl&&r
183906
MC/DC50%1/2
defined $unit->{"gmt"} and not defined $arg->{"gmt"}
defined $unit->{"gmt"} not defined $arg->{"gmt"}
Truth table66%2/3
A and not(B)
A= defined $unit->{"gmt"}B= not defined $arg->{"gmt"}
ABresult
0X0
100
111
1808  
1809 1845 $arg->{units} = $unit_name;
1810  
1811 $value = __localize(
1812 text => [ $fmtr_name, 'localize_value', $value ],
1813 default => $value,
1814 locale => $fmtr->{locale},
1815 1845 );
1816  
1817 defined( my $formatter = _dor( $unit->{formatter},
1818 $fmtr->{dimension}{formatter},
1819 $dim->{formatter},
1820 1845 ▶ ) )
Branch: 1 branch
BranchTrueFalseTotal
defined(my $formatter = _dor($unit->{"formatter"}, $fmtr->{"dimension"}{"formatter"}, $dim->{"formatter"})) or $self->weep("No formatter for $dim_name $unit_name") 1845 0 1845
1821 or $self->weep( "No formatter for $dim_name $unit_name" );
1822  
1823 1845 return $self->$formatter( $value, $arg, $fmtr );
1824 }
1825  
1826 2764 ▶sub _arguments {
Subroutine _arguments: called CC=5 SCAR=16.1
1827 2764 my @arg = @_;
1828  
1829 2764 my $obj = shift @arg;
1830 2764 ▶ my $hash = HASH_REF eq ref $arg[-1] ? pop @arg : {};
Branch: 1 branch
BranchTrueFalseTotal
'HASH' eq ref $arg[-1] ? : 454 2310 2764
1831  
1832 2764 my ( @clean, @append );
1833 2764 foreach my $item ( @arg ) {
1834 1178 ▶ if ( has_method( $item, 'dereference' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (has_method($item, 'dereference')) { } 637 541 1178
1835 637 push @append, $item->dereference();
1836 } else {
1837 541 push @clean, $item;
1838 }
1839 }
1840  
1841 2764 ▶ @clean % 2 and splice @clean, 0, 0, 'title';
Branch: 1 branch
BranchTrueFalseTotal
@clean % 2 and splice @clean, 0, 0, "title" 9 2755 2764
1842  
1843 2764 return ( $obj, %{ $hash }, @clean, @append );
1844 }
1845  
1846 =begin comment
1847  
1848 # TODO remove this after October 1 2016
1849 # It's only still here because, although I can't find a call for it, and
1850 # testcover shows it is not called, I'm paranoid that I did something
1851 # tricky that I can not now remember and is not covered by the tests.
1852  
1853 sub _attrib_hash {
1854 my ( $self, $name, @arg ) = @_;
1855 if ( @arg ) {
1856 my $value = shift @arg;
1857 ref $value
1858 and HASH_REF eq reftype( $value )
1859 or $self->{warner}->wail(
1860 "Attribute $name must be a hash reference" );
1861 $self->{$name} = $value;
1862 return $self;
1863 } else {
1864 return $self->{$name};
1865 }
1866 }
1867  
1868 =end comment
1869  
1870 =cut
1871  
1872 {
1873  
1874 my %do_title = (
1875 59 ▶ TITLE_GRAVITY_TOP() => sub {
Subroutine __ANON__: called CC=4 SCAR=14.5
1876 59 my ( $self, $wrapped, $arg, $fmtr ) = @_;
1877 defined $self->{internal}{_title_info}{inx}
1878 59 ▶ or $self->{internal}{_title_info}{inx} = 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"internal"}{"_title_info"}{"inx"} or $self->{"internal"}{"_title_info"}{"inx"} = 0 53 6 59
1879 59 my $inx = $self->{internal}{_title_info}{inx};
1880 $self->{internal}{_title_info}{more} ||=
1881 59 ▶ defined $wrapped->[$inx + 1];
Condition33%1/3
$self->{"internal"}{"_title_info"}{"more"} ||= defined $$wrapped[$inx + 1]
l!l&&r!l&&!r
0059
MC/DC0%0/2
$self->{"internal"}{"_title_info"}{"more"} ||= defined $$wrapped[$inx + 1]
$self->{"internal"}{"_title_info"}{"more"} defined $$wrapped[$inx + 1]
Truth table33%1/3
A ||= B
A= $self->{"internal"}{"_title_info"}{"more"}B= defined $$wrapped[$inx + 1]
ABresult
1X1
011
000
1882  
1883 59 ▶ return defined $wrapped->[$inx] ?
Branch: 1 branch
BranchTrueFalseTotal
defined $wrapped->[$inx] ? : 59 0 59
1884 $wrapped->[$inx] :
1885 $self->_format_string( '', $arg, $fmtr );
1886 },
1887 599 ▶ TITLE_GRAVITY_BOTTOM() => sub {
Subroutine __ANON__: called CC=6 SCAR=17.9
1888 599 my ( $self, $wrapped, $arg, $fmtr ) = @_;
1889 defined $self->{internal}{_title_info}{inx}
1890 599 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"internal"}{"_title_info"}{"inx"} or do { $self->{"internal"}{"_title_info"}{"inx"} = -1; $self->{"internal"}{"_title_info"}{"max"} = 0 } 561 38 599
1891 38 $self->{internal}{_title_info}{inx} = -1;
1892 38 $self->{internal}{_title_info}{max} = 0;
1893 };
1894 599 my $size = @{ $wrapped };
1895 599 my $inx = $self->{internal}{_title_info}{inx};
1896 599 ▶ if ( $inx < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inx < 0) 282 317 599
1897 $self->{internal}{_title_info}{max} = max(
1898 $size,
1899 $self->{internal}{_title_info}{max},
1900 282 );
1901 }
1902 599 my $max = $self->{internal}{_title_info}{max};
1903 599 ▶ $self->{internal}{_title_info}{more} ||= $inx + 1 < $max;
Condition100%3/3
$self->{"internal"}{"_title_info"}{"more"} ||= $inx + 1 < $max
l!l&&r!l&&!r
27542282
MC/DC100%2/2
$self->{"internal"}{"_title_info"}{"more"} ||= $inx + 1 < $max
$self->{"internal"}{"_title_info"}{"more"} $inx + 1 < $max
Truth table100%3/3
A ||= B
A= $self->{"internal"}{"_title_info"}{"more"}B= $inx + 1 < $max
ABresult
1X1
011
000
1904 599 $inx = $inx - $max + $size;
1905 599 ▶ return ( $inx >= 0 && defined $wrapped->[$inx] ) ?
Branch: 1 branch
BranchTrueFalseTotal
$inx >= 0 && defined $wrapped->[$inx] ? : 286 313 599
Condition66%2/3
$inx >= 0 and defined $wrapped->[$inx]
!ll&&!rl&&r
3130286
MC/DC50%1/2
$inx >= 0 and defined $wrapped->[$inx]
$inx >= 0 defined $wrapped->[$inx]
Truth table66%2/3
A and B
A= $inx >= 0B= defined $wrapped->[$inx]
ABresult
0X0
100
111
1906 $wrapped->[$inx] :
1907 $self->_format_string( '', $arg, $fmtr );
1908 },
1909 11 );
1910  
1911 658 ▶ sub _do_title {
Subroutine _do_title: called CC=3 SCAR=11.2
1912 658 my ( $self, $arg, $fmtr ) = @_;
1913 658 my $fmtr_name = $fmtr->{name};
1914 # TODO this looks like a good place to insert localized title
1915 # code. But see also _apply_defaults().
1916 defined $arg->{title}
1917 658 ▶ or $arg->{title} = '';
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"title"} or $arg->{"title"} = "" 658 0 658
1918 658 my $title = $arg->{title};
1919 my $wrapped = $self->{internal}{$fmtr_name}{_title}{$title}{$arg->{width}}
1920 658 ▶ ||= $self->_do_title_wrap( $arg, $fmtr );
Condition66%2/3
$self->{"internal"}{$fmtr_name}{"_title"}{$title}{$arg->{"width"}} ||= $self->_do_title_wrap($arg, $fmtr)
l!l&&r!l&&!r
3173410
MC/DC0%0/2
$self->{"internal"}{$fmtr_name}{"_title"}{$title}{$arg->{"width"}} ||= $self->_do_title_wrap($arg, $fmtr)
$self->{"internal"}{$fmtr_name}{"_title"}{$title}{$arg->{"width"}} $self->_do_title_wrap($arg, $fmtr)
Truth table66%2/3
A ||= B
A= $self->{"internal"}{$fmtr_name}{"_title"}{$title}{$arg->{"width"}}B= $self->_do_title_wrap($arg, $fmtr)
ABresult
1X1
011
000
1921  
1922 658 return $do_title{$self->{title_gravity}}->( $self, $wrapped,
1923 $arg, $fmtr );
1924 }
1925  
1926 786 ▶ sub is_valid_title_gravity {
Subroutine is_valid_title_gravity: called CC=3 SCAR=11.7
Pod documented
1927 786 my ( @args ) = @_;
1928 786 ▶ defined( my $value = pop @args )
Branch: 1 branch
BranchTrueFalseTotal
defined(my $value = pop @args) or return 0 786 0 786
1929 or return 0;
1930 786 ▶ return $do_title{$value} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$do_title{$value} ? : 786 0 786
1931 }
1932  
1933 }
1934  
1935 11 ▶sub _do_title_wrap {
Subroutine _do_title_wrap: called CC=3 SCAR=11.0
1936 341 my ( $self, $arg, $fmtr ) = @_;
1937 341 my $title = $arg->{title};
1938 341 ▶ $arg->{width} eq ''
Branch: 1 branch
BranchTrueFalseTotal
$arg->{"width"} eq "" and return [$title] 64 277 341
1939 and return [ $title ];
1940 $arg->{width}
1941 277 ▶ or return [ '' ];
Branch: 1 branch
BranchTrueFalseTotal
$arg->{"width"} or return [""] 277 0 277
1942 277 local $Text::Wrap::columns = $arg->{width} + 1;
1943 277 local $Text::Wrap::huge = 'overflow';
1944 277 my $wrap = Text::Wrap::wrap( '', '', $title );
1945 277 my @lines = split qr{ \n }sxm, $wrap;
1946 277 return [ map { $self->_format_string( $_, $arg, $fmtr ) } @lines ];
1947 }
1948  
1949 188 ▶sub __chain_bearing {
Subroutine __chain_bearing: called CC=7 SCAR=19.5
1950 188 my ( undef, undef, $value, $arg ) = @_; # Invocant, $name unused
1951 $arg->{bearing}
1952 and $arg->{bearing} =~ RE_ALL_DIGITS
1953 188 ▶ or $arg->{bearing} = 0;
Branch: 1 branch
BranchTrueFalseTotal
$arg->{"bearing"} and $arg->{"bearing"} =~ / \A [0-9]+ \z /msx or $arg->{"bearing"} = 0 185 3 188
Condition66%2/3
$arg->{"bearing"} and $arg->{"bearing"} =~ / \A [0-9]+ \z /msx
!ll&&!rl&&r
30185
MC/DC50%1/2
$arg->{"bearing"} and $arg->{"bearing"} =~ / \A [0-9]+ \z /msx
$arg->{"bearing"} $arg->{"bearing"} =~ / \A [0-9]+ \z /msx
Truth table66%2/3
A and B
A= $arg->{"bearing"}B= $arg->{"bearing"} =~ / \A [0-9]+ \z /msx
ABresult
0X0
100
111
1954  
1955 188 ▶ $arg->{bearing} or return $arg;
Branch: 1 branch
BranchTrueFalseTotal
$arg->{"bearing"} or return $arg 185 3 188
1956  
1957 185 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 136 49 185
1958 136 my $ab = { %{ $arg } }; # Shallow clone
1959 136 ▶ $ab->{width} and $ab->{width} = $ab->{bearing};
Branch: 1 branch
BranchTrueFalseTotal
$ab->{"width"} and $ab->{"width"} = $ab->{"bearing"} 128 8 136
1960 136 $ab->{units} = 'bearing';
1961 136 return ( $arg, $ab );
1962 } else {
1963 $arg->{width}
1964 49 ▶ and $arg->{width} += $arg->{bearing} + 1;
Branch: 1 branch
BranchTrueFalseTotal
$arg->{"width"} and $arg->{"width"} += $arg->{"bearing"} + 1 49 0 49
1965 49 return $arg;
1966 }
1967 }
1968  
1969 7694 ▶sub _dor {
Subroutine _dor: called CC=3 SCAR=11.0
1970 7694 foreach ( @_ ) {
1971 20923 ▶ defined $_ and return $_;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and return $_ 6594 14329 20923
1972 }
1973 1100 return $_[-1];
1974 }
1975  
1976 32323 ▶sub _get {
Subroutine _get: called CC=7 SCAR=23.4
1977 32323 my ( $self, @arg ) = @_;
1978 32323 my $hash = $self;
1979 32323 foreach my $key ( @arg ) {
1980 91773 ▶ ref $hash or return NONE;
Branch: 1 branch
BranchTrueFalseTotal
ref $hash or return undef 65134 26639 91773
1981 65134 ▶ defined $key
Branch: 1 branch
BranchTrueFalseTotal
defined $key or $self->weep("Undefined key") 65134 0 65134
1982 or $self->weep( 'Undefined key' );
1983 65134 my $ref = reftype( $hash );
1984 65134 ▶ if ( HASH_REF eq $ref ) {
Branch: 3 branches
BranchTrueFalseTotal
if ('HASH' eq $ref) { } 65134 0 65134
elsif ('ARRAY' eq $ref) { } 0 0 0
elsif ('CODE' eq $ref) { } 0 0 0
1985 65134 $hash = $hash->{$key};
1986 } elsif ( ARRAY_REF eq $ref ) {
1987 0 $hash = $hash->[$key];
1988 } elsif ( CODE_REF eq $ref ) {
1989 0 $hash = $hash->( $self, $key );
1990 } else {
1991 0 return NONE;
1992 }
1993 }
1994 5684 return $hash;
1995 }
1996  
1997 2154 ▶sub _get_eci {
Subroutine _get_eci: called CC=2 SCAR=6.9
1998 2154 my ( $self, @arg ) = @_;
1999 2154 my $eci = $self->_get( data => @arg );
2000 2154 ▶ embodies( $eci, 'Astro::Coord::ECI' )
Branch: 1 branch
BranchTrueFalseTotal
embodies($eci, "Astro::Coord::ECI") and return $eci 2069 85 2154
2001 and return $eci;
2002 85 return NONE;
2003 }
2004  
2005 # @coords = $self->_get_precessed_coordinates( $method, $body,
2006 # $station );
2007 #
2008 # This method fetches the coordinates of the given body which are
2009 # specified by the given method. These must be inertial, and are
2010 # precessed if desired. If the body is not defined, nothing is
2011 # returned. If the station is passed, the coordinates are relative
2012 # to it; if it is undefined, nothing is returned.
2013  
2014 41 ▶sub _get_precessed_coordinates {
Subroutine _get_precessed_coordinates: called CC=5 SCAR=18.2
2015 41 my ( $self, $method, $body, $station ) = @_;
2016  
2017 41 foreach my $thing ( $body, $station ) {
2018 82 ▶ embodies( $thing, 'Astro::Coord::ECI' )
Branch: 1 branch
BranchTrueFalseTotal
embodies($thing, "Astro::Coord::ECI") or return 82 0 82
2019 or return;
2020 }
2021  
2022 # TODO need to set station time from body? I think not now, but
2023 # Astro::App::Satpass2::FormatValue needed this.
2024  
2025 41 ▶ if ( my $equinox = $self->{desired_equinox_dynamical} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $equinox = $self->{"desired_equinox_dynamical"}) 0 41 41
2026 0 foreach my $thing ( $body, $station ) {
2027 0 $thing = $thing->clone()->precess_dynamical( $equinox );
2028 }
2029 }
2030  
2031 41 return $station->$method( $body );
2032 }
2033  
2034 20 ▶sub _get_tle {
Subroutine _get_tle: called CC=2 SCAR=6.9
2035 20 my ( $self, @arg ) = @_;
2036 20 my $tle = $self->_get( data => @arg );
2037 20 ▶ embodies( $tle, 'Astro::Coord::ECI::TLE' )
Branch: 1 branch
BranchTrueFalseTotal
embodies($tle, "Astro::Coord::ECI::TLE") and return $tle 6 14 20
2038 and return $tle;
2039 14 return NONE;
2040 }
2041  
2042 132 ▶sub _get_tle_attr {
Subroutine _get_tle_attr: called CC=3 SCAR=11.0
2043 132 my ( $self, @arg ) = @_;
2044 132 my $attr = pop @arg;
2045 132 my $tle = $self->_get( data => @arg );
2046 132 ▶ embodies( $tle, 'Astro::Coord::ECI::TLE' )
Branch: 1 branch
BranchTrueFalseTotal
embodies($tle, "Astro::Coord::ECI::TLE") and $tle->attribute($attr) or return undef 78 54 132
Condition100%3/3
embodies($tle, "Astro::Coord::ECI::TLE") and $tle->attribute($attr)
!ll&&!rl&&r
53178
MC/DC100%2/2
embodies($tle, "Astro::Coord::ECI::TLE") and $tle->attribute($attr)
embodies($tle, "Astro::Coord::ECI::TLE") $tle->attribute($attr)
Truth table100%3/3
A and B
A= embodies($tle, "Astro::Coord::ECI::TLE")B= $tle->attribute($attr)
ABresult
0X0
100
111
2047 and $tle->attribute( $attr )
2048 or return NONE;
2049 78 return $tle->get( $attr );
2050 }
2051  
2052 # $string = $self->_format_*( $value, \%arg, \%fmtr );
2053 #
2054 # These methods take the value and turn it into a string.
2055 # Recognized arguments are:
2056 # {places} => decimal places, ignored if not a non-negative
2057 # number;
2058 # {width} => field width, ignored if not a non-negative
2059 # number;
2060  
2061 # Called as $self->$method()
2062 139 ▶sub _format_bearing { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _format_bearing: called CC=10 SCAR=23.6
2063 139 my ( $self, $value, $arg, $fmtr ) = @_;
2064 139 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or goto \&Astro::App::Satpass2::FormatValue::_format_undef 139 0 139
2065 or goto &_format_undef;
2066  
2067 139 my $table;
2068  
2069 139 foreach my $source ( qw{ default } ) {
2070 139 ▶ $table = $self->_get( $source => bearing => 'table' )
Branch: 1 branch
BranchTrueFalseTotal
$table = $self->_get($source, "bearing", "table") and last 1 138 139
2071 and last;
2072 }
2073  
2074 $table ||= __localize(
2075 text => [ bearing => 'table' ],
2076 default => [],
2077 locale => $fmtr->{locale},
2078 139 ▶ );
Condition66%2/3
$table ||= __localize("text", ["bearing", "table"], "default", scalar [], "locale", $fmtr->{"locale"})
l!l&&r!l&&!r
11380
MC/DC0%0/2
$table ||= __localize("text", ["bearing", "table"], "default", scalar [], "locale", $fmtr->{"locale"})
$table __localize("text", ["bearing", "table"], "default", scalar [], "locale", $fmtr->{"locale"})
Truth table66%2/3
A ||= B
A= $tableB= __localize("text", ["bearing", "table"], "default", scalar [], "locale", $fmtr->{"locale"})
ABresult
1X1
011
000
2079  
2080 $arg->{bearing}
2081 139 ▶ or $arg->{bearing} = ( $arg->{width} || 2 );
Branch: 1 branch
BranchTrueFalseTotal
$arg->{"bearing"} or $arg->{"bearing"} = $arg->{"width"} || 2 137 2 139
Condition50%1/2
$arg->{'width'} || 2
l!l
20
MC/DC0%0/1
$arg->{'width'} || 2
$arg->{'width'}
Truth table50%1/2
A
A= $arg->{'width'}
Aresult
11
00
2082 $arg->{width}
2083 and $arg->{bearing} > $arg->{width}
2084 139 ▶ and $arg->{bearing} = $arg->{width};
Branch: 1 branch
BranchTrueFalseTotal
$arg->{"width"} and $arg->{"bearing"} > $arg->{"width"} and $arg->{"bearing"} = $arg->{"width"} 0 139 139
Condition66%2/3
$arg->{"width"} and $arg->{"bearing"} > $arg->{"width"}
!ll&&!rl&&r
91300
MC/DC0%0/2
$arg->{"width"} and $arg->{"bearing"} > $arg->{"width"}
$arg->{"width"} $arg->{"bearing"} > $arg->{"width"}
Truth table66%2/3
A and B
A= $arg->{"width"}B= $arg->{"bearing"} > $arg->{"width"}
ABresult
0X0
100
111
2085  
2086 139 ▶ my $inx = min( $arg->{bearing} || 2, scalar @{ $table } ) - 1;
Condition50%1/2
$arg->{'bearing'} || 2
l!l
1390
MC/DC0%0/1
$arg->{'bearing'} || 2
$arg->{'bearing'}
Truth table50%1/2
A
A= $arg->{'bearing'}
Aresult
11
00
2087 139 my $tags = $table->[$inx];
2088 139 my $bins = @{ $tags };
2089 139 $inx = floor ($value / TWOPI * $bins + .5) % $bins;
2090 139 return $self->_format_string( $tags->[$inx], $arg, $fmtr );
2091 }
2092  
2093 # Called as $self->$method()
2094 12 ▶sub _format_duration { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _format_duration: called CC=8 SCAR=21.1
2095 12 my ( $self, $value, $arg, $fmtr ) = @_;
2096  
2097 defined $arg->{align_left}
2098 12 ▶ or $arg->{align_left} = 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"align_left"} or $arg->{"align_left"} = 0 7 5 12
2099  
2100 12 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or goto \&Astro::App::Satpass2::FormatValue::_format_undef 12 0 12
2101 or goto &_format_undef;
2102  
2103 12 my $secs = floor ($value + .5);
2104 12 my $mins = floor ($secs / 60);
2105 12 $secs %= 60;
2106 12 my $hrs = floor ($mins / 60);
2107 12 $mins %= 60;
2108 12 my $days = floor ($hrs / 24);
2109 12 $hrs %= 24;
2110  
2111 12 my $buffer;
2112 12 ▶ if ($days > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($days > 0) { } 1 11 12
2113 1 $buffer = sprintf '%d %02d:%02d:%02d', $days, $hrs, $mins, $secs;
2114 } else {
2115 11 $buffer = sprintf '%02d:%02d:%02d', $hrs, $mins, $secs;
2116 }
2117  
2118 '' eq $arg->{width}
2119 12 ▶ and return $buffer;
Branch: 1 branch
BranchTrueFalseTotal
"" eq $arg->{"width"} and return $buffer 2 10 12
2120  
2121 length $buffer <= $arg->{width}
2122 or $self->{overflow}
2123 10 ▶ or return '*' x $arg->{width};
Branch: 1 branch
BranchTrueFalseTotal
length $buffer <= $arg->{"width"} or $self->{"overflow"} or return "*" x $arg->{"width"} 10 0 10
Condition33%1/3
length $buffer <= $arg->{"width"} or $self->{"overflow"}
l!l&&r!l&&!r
1000
MC/DC0%0/2
length $buffer <= $arg->{"width"} or $self->{"overflow"}
length $buffer <= $arg->{"width"} $self->{"overflow"}
Truth table33%1/3
A or B
A= length $buffer <= $arg->{"width"}B= $self->{"overflow"}
ABresult
1X1
011
000
2124  
2125 10 ▶ $arg->{width} - length $buffer
Branch: 1 branch
BranchTrueFalseTotal
$arg->{"width"} - length($buffer) or return $buffer 10 0 10
2126 or return $buffer;
2127  
2128 10 return $self->_format_string( $buffer, $arg, $fmtr );
2129 }
2130  
2131 # Called as $self->$method()
2132 380 ▶sub _format_event { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _format_event: called CC=9 SCAR=22.0
2133 380 my ( $self, $value, $arg, $fmtr ) = @_;
2134  
2135 380 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or goto \&Astro::App::Satpass2::FormatValue::_format_undef 380 0 380
2136 or goto &_format_undef;
2137  
2138 380 ▶ isdual( $value )
Branch: 1 branch
BranchTrueFalseTotal
&isdual($value) or not $value =~ / \D /msx or goto \&Astro::App::Satpass2::FormatValue::_format_string 368 12 380
Condition100%3/3
&isdual($value) or not $value =~ / \D /msx
l!l&&r!l&&!r
3571112
MC/DC100%2/2
&isdual($value) or not $value =~ / \D /msx
&isdual($value) not $value =~ / \D /msx
Truth table100%3/3
A or not(B)
A= &isdual($value)B= not $value =~ / \D /msx
ABresult
1X1
011
000
2139 or $value !~ m/ \D /sxm
2140 or goto &_format_string;
2141  
2142 368 my $table;
2143 368 ▶ if ( 'string' ne $arg->{units} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("string" ne $arg->{"units"}) 367 1 368
2144 367 foreach my $source ( qw{ default } ) {
2145 367 ▶ $table = $self->_get( $source => event => 'table' )
Branch: 1 branch
BranchTrueFalseTotal
$table = $self->_get($source, "event", "table") and last 1 366 367
2146 and last;
2147 }
2148 }
2149 368 ▶ $table ||= __localize(
Condition66%2/3
$table ||= __localize("text", ["event", "table"], "default", scalar [])
l!l&&r!l&&!r
13670
MC/DC0%0/2
$table ||= __localize("text", ["event", "table"], "default", scalar [])
$table __localize("text", ["event", "table"], "default", scalar [])
Truth table66%2/3
A ||= B
A= $tableB= __localize("text", ["event", "table"], "default", scalar [])
ABresult
1X1
011
000
2150 text => [ event => 'table' ],
2151 default => [],
2152 );
2153  
2154 368 ▶ return $self->_format_string( $table->[$value] || '', $arg, $fmtr );
Condition100%2/2
$table->[$value] || ''
l!l
3671
MC/DC100%1/1
$table->[$value] || ''
$table->[$value]
Truth table100%2/2
A
A= $table->[$value]
Aresult
11
00
2155 }
2156  
2157 # Called as $self->$method()
2158 5 ▶sub _format_integer { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _format_integer: called CC=6 SCAR=19.1
2159 5 my ( $self, $value, $arg ) = @_; # $fmtr unused
2160 5 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or goto \&Astro::App::Satpass2::FormatValue::_format_undef 5 0 5
2161 or goto &_format_undef;
2162  
2163 $arg->{width}
2164 5 ▶ and $arg->{width} =~ RE_ALL_DIGITS
Branch: 1 branch
BranchTrueFalseTotal
$arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx or return sprintf("%d", $value) 4 1 5
Condition66%2/3
$arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx
!ll&&!rl&&r
104
MC/DC50%1/2
$arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx
$arg->{"width"} $arg->{"width"} =~ / \A [0-9]+ \z /msx
Truth table66%2/3
A and B
A= $arg->{"width"}B= $arg->{"width"} =~ / \A [0-9]+ \z /msx
ABresult
0X0
100
111
2165 or return sprintf '%d', $value;
2166  
2167 4 my $buffer = sprintf '%*d', $arg->{width}, $value;
2168  
2169 length $buffer <= $arg->{width}
2170 or $self->{overflow}
2171 4 ▶ or return '*' x $arg->{width};
Branch: 1 branch
BranchTrueFalseTotal
length $buffer <= $arg->{"width"} or $self->{"overflow"} or return "*" x $arg->{"width"} 4 0 4
Condition33%1/3
length $buffer <= $arg->{"width"} or $self->{"overflow"}
l!l&&r!l&&!r
400
MC/DC0%0/2
length $buffer <= $arg->{"width"} or $self->{"overflow"}
length $buffer <= $arg->{"width"} $self->{"overflow"}
Truth table33%1/3
A or B
A= length $buffer <= $arg->{"width"}B= $self->{"overflow"}
ABresult
1X1
011
000
2172  
2173 4 return $buffer;
2174 }
2175  
2176 # Called as $self->$method()
2177 0 ▶sub _format_lower_case { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _format_lower_case: not called CC=2 SCAR=17.9
2178 0 my ( $self, $value, $arg, $fmtr ) = @_;
2179 0 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or goto \&Astro::App::Satpass2::FormatValue::_format_undef 0 0 0
2180 or goto &_format_undef;
2181  
2182 0 return $self->_format_string( lc $value, $arg, $fmtr );
2183 }
2184  
2185 # Called as $self->$method()
2186 813 ▶sub _format_number { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _format_number: called CC=14 SCAR=29.1
2187 813 my ( $self, $value, $arg, $fmtr ) = @_;
2188 813 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value and $value ne "" or goto \&Astro::App::Satpass2::FormatValue::_format_undef 813 0 813
Condition33%1/3
defined $value and $value ne ""
!ll&&!rl&&r
00813
MC/DC0%0/2
defined $value and $value ne ""
defined $value $value ne ""
Truth table33%1/3
A and B
A= defined $valueB= $value ne ""
ABresult
0X0
100
111
2189 and $value ne ''
2190 or goto &_format_undef;
2191  
2192 my $width = ( $arg->{width} && $arg->{width} =~ RE_ALL_DIGITS )
2193 813 ▶ ? $arg->{width} : '';
Branch: 1 branch
BranchTrueFalseTotal
$arg->{'width'} && $arg->{'width'} =~ / \A [0-9]+ \z /msx ? : 767 46 813
Condition66%2/3
$arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx
!ll&&!rl&&r
460767
MC/DC50%1/2
$arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx
$arg->{"width"} $arg->{"width"} =~ / \A [0-9]+ \z /msx
Truth table66%2/3
A and B
A= $arg->{"width"}B= $arg->{"width"} =~ / \A [0-9]+ \z /msx
ABresult
0X0
100
111
2194 813 my $tplt = "%$width";
2195 defined $arg->{places}
2196 813 ▶ and $arg->{places} =~ RE_ALL_DIGITS
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"places"} and $arg->{"places"} =~ / \A [0-9]+ \z /msx and $tplt .= qq[.$arg->{"places"}] 813 0 813
Condition33%1/3
defined $arg->{"places"} and $arg->{"places"} =~ / \A [0-9]+ \z /msx
!ll&&!rl&&r
00813
MC/DC0%0/2
defined $arg->{"places"} and $arg->{"places"} =~ / \A [0-9]+ \z /msx
defined $arg->{"places"} $arg->{"places"} =~ / \A [0-9]+ \z /msx
Truth table33%1/3
A and B
A= defined $arg->{"places"}B= $arg->{"places"} =~ / \A [0-9]+ \z /msx
ABresult
0X0
100
111
2197 and $tplt .= ".$arg->{places}";
2198  
2199 813 ▶ '%' eq $tplt
Branch: 1 branch
BranchTrueFalseTotal
"%" eq $tplt and return "$value" 0 813 813
2200 and return "$value";
2201  
2202 813 my $buffer = sprintf $tplt . 'f', $value;
2203  
2204 # The following line is because sprintf '%.1f', 0.04 produces
2205 # '-0.0'. This may not be a bug, given what 'perldoc -f sprintf'
2206 # says, but it sure looks like a wart to me.
2207 813 $buffer =~ s/ \A ( \s* ) - ( 0* [.]? 0* \s* ) \z /$1 $2/smx;
2208  
2209 813 ▶ $width or return $buffer;
Branch: 1 branch
BranchTrueFalseTotal
$width or return $buffer 767 46 813
2210  
2211 767 ▶ if ($width && length $buffer > $width && $width >= 7) {
Branch: 1 branch
BranchTrueFalseTotal
if ($width and length $buffer > $width and $width >= 7) 6 761 767
Condition66%4/6
$width and length $buffer > $width and $width >= 7
!ll&&!rl&&r
76106
$width and length $buffer > $width
!ll&&!rl&&r
07616
MC/DC33%1/3
$width and length $buffer > $width and $width >= 7
$width length $buffer > $width $width >= 7
Truth table50%2/4
A and B and C
A= $widthB= length $buffer > $widthC= $width >= 7
ABCresult
0XX0
10X0
1100
1111
2212 6 $arg->{places} = $width - 7;
2213 6 return $self->_format_number_scientific( $value, $arg, $fmtr );
2214 }
2215  
2216 length $buffer <= $width
2217 or $self->{overflow}
2218 761 ▶ or return '*' x $width;
Branch: 1 branch
BranchTrueFalseTotal
length $buffer <= $width or $self->{"overflow"} or return "*" x $width 761 0 761
Condition33%1/3
length $buffer <= $width or $self->{"overflow"}
l!l&&r!l&&!r
76100
MC/DC0%0/2
length $buffer <= $width or $self->{"overflow"}
length $buffer <= $width $self->{"overflow"}
Truth table33%1/3
A or B
A= length $buffer <= $widthB= $self->{"overflow"}
ABresult
1X1
011
000
2219  
2220 761 return $buffer;
2221 }
2222  
2223 15 ▶sub _format_number_scientific {
Subroutine _format_number_scientific: called CC=13 SCAR=30.6
2224 15 my ( $self, $value, $arg ) = @_; # $fmtr unused
2225 15 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value and $value ne "" or goto \&Astro::App::Satpass2::FormatValue::_format_undef 15 0 15
Condition33%1/3
defined $value and $value ne ""
!ll&&!rl&&r
0015
MC/DC0%0/2
defined $value and $value ne ""
defined $value $value ne ""
Truth table33%1/3
A and B
A= defined $valueB= $value ne ""
ABresult
0X0
100
111
2226 and $value ne ''
2227 or goto &_format_undef;
2228  
2229 my $width = ( $arg->{width} && $arg->{width} =~ RE_ALL_DIGITS )
2230 15 ▶ ? $arg->{width} : '';
Branch: 1 branch
BranchTrueFalseTotal
$arg->{'width'} && $arg->{'width'} =~ / \A [0-9]+ \z /msx ? : 9 6 15
Condition66%2/3
$arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx
!ll&&!rl&&r
609
MC/DC50%1/2
$arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx
$arg->{"width"} $arg->{"width"} =~ / \A [0-9]+ \z /msx
Truth table66%2/3
A and B
A= $arg->{"width"}B= $arg->{"width"} =~ / \A [0-9]+ \z /msx
ABresult
0X0
100
111
2231 15 my $tplt = "%$width";
2232 defined $arg->{places}
2233 15 ▶ and $arg->{places} =~ RE_ALL_DIGITS
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"places"} and $arg->{"places"} =~ / \A [0-9]+ \z /msx and $tplt .= qq[.$arg->{"places"}] 15 0 15
Condition33%1/3
defined $arg->{"places"} and $arg->{"places"} =~ / \A [0-9]+ \z /msx
!ll&&!rl&&r
0015
MC/DC0%0/2
defined $arg->{"places"} and $arg->{"places"} =~ / \A [0-9]+ \z /msx
defined $arg->{"places"} $arg->{"places"} =~ / \A [0-9]+ \z /msx
Truth table33%1/3
A and B
A= defined $arg->{"places"}B= $arg->{"places"} =~ / \A [0-9]+ \z /msx
ABresult
0X0
100
111
2234 and $tplt .= ".$arg->{places}";
2235 15 $tplt .= 'e';
2236  
2237 15 my $buffer = sprintf $tplt, $value;
2238 15 ▶ $buffer =~ s/ e ( [-+]? ) 0 ( [0-9]{2} ) \z /e$1$2/smx # Normalize
Branch: 1 branch
BranchTrueFalseTotal
$buffer =~ s/ e ( [-+]? ) 0 ( [0-9]{2} ) \z /e$1$2/msx and $width and $width > length $buffer and $buffer = ' ' . $buffer 0 15 15
Condition33%2/6
$buffer =~ s/ e ( [-+]? ) 0 ( [0-9]{2} ) \z /e$1$2/msx and $width and $width > length $buffer
!ll&&!rl&&r
1500
$buffer =~ s/ e ( [-+]? ) 0 ( [0-9]{2} ) \z /e$1$2/msx and $width
!ll&&!rl&&r
1500
MC/DC0%0/3
$buffer =~ s/ e ( [-+]? ) 0 ( [0-9]{2} ) \z /e$1$2/msx and $width and $width > length $buffer
$buffer =~ s/ e ( [-+]? ) 0 ( [0-9]{2} ) \z /e$1$2/msx $width $width > length $buffer
Truth table25%1/4
A and B and C
A= $buffer =~ s/ e ( [-+]? ) 0 ( [0-9]{2} ) \z /e$1$2/msxB= $widthC= $width > length $buffer
ABCresult
0XX0
10X0
1100
1111
2239 and $width
2240 and $width > length $buffer
2241 and $buffer = ' ' . $buffer; # Preserve width after normalize
2242  
2243 15 ▶ $width
Branch: 1 branch
BranchTrueFalseTotal
$width or return $buffer 9 6 15
2244 or return $buffer;
2245  
2246 length $buffer <= $width
2247 or $self->{overflow}
2248 9 ▶ or return '*' x $width;
Branch: 1 branch
BranchTrueFalseTotal
length $buffer <= $width or $self->{"overflow"} or return "*" x $width 9 0 9
Condition33%1/3
length $buffer <= $width or $self->{"overflow"}
l!l&&r!l&&!r
900
MC/DC0%0/2
length $buffer <= $width or $self->{"overflow"}
length $buffer <= $width $self->{"overflow"}
Truth table33%1/3
A or B
A= length $buffer <= $widthB= $self->{"overflow"}
ABresult
1X1
011
000
2249  
2250 9 return $buffer;
2251 }
2252  
2253 # Called as $self->$method()
2254 5 ▶sub _format_phase { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _format_phase: called CC=7 SCAR=19.7
2255 5 my ( $self, $value, $arg, $fmtr ) = @_;
2256 5 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or goto \&Astro::App::Satpass2::FormatValue::_format_undef 5 0 5
2257 or goto &_format_undef;
2258 5 my $angle = rad2deg( $value );
2259  
2260 5 my $table;
2261 5 foreach my $source ( qw{ default } ) {
2262 5 ▶ $table = $self->_get( $source => phase => 'table' )
Branch: 1 branch
BranchTrueFalseTotal
$table = $self->_get($source, "phase", "table") and last 1 4 5
2263 and last;
2264 }
2265 $table ||= __localize(
2266 text => [ phase => 'table' ],
2267 default => [],
2268 locale => $fmtr->{locale},
2269 5 ▶ );
Condition66%2/3
$table ||= __localize("text", ["phase", "table"], "default", scalar [], "locale", $fmtr->{"locale"})
l!l&&r!l&&!r
140
MC/DC0%0/2
$table ||= __localize("text", ["phase", "table"], "default", scalar [], "locale", $fmtr->{"locale"})
$table __localize("text", ["phase", "table"], "default", scalar [], "locale", $fmtr->{"locale"})
Truth table66%2/3
A ||= B
A= $tableB= __localize("text", ["phase", "table"], "default", scalar [], "locale", $fmtr->{"locale"})
ABresult
1X1
011
000
2270 5 foreach my $entry ( @{ $table } ) {
2271 20 ▶ $entry->[0] > $angle or next;
Branch: 1 branch
BranchTrueFalseTotal
$entry->[0] > $angle or next 5 15 20
2272 5 return $self->_format_string( $entry->[1], $arg, $fmtr );
2273 }
2274 0 return $self->_format_string( $table->[0][1], $arg, $fmtr );
2275 }
2276  
2277 # Called as $self->$method()
2278 25 ▶sub _format_right_ascension { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _format_right_ascension: called CC=6 SCAR=19.0
2279 25 my ( $self, $value, $arg, $fmtr ) = @_;
2280 25 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or goto \&Astro::App::Satpass2::FormatValue::_format_undef 25 0 25
2281 or goto &_format_undef;
2282 25 my $sec = $value / PI * 12;
2283 25 my $hr = floor($sec);
2284 25 $sec = ($sec - $hr) * 60;
2285 25 my $min = floor($sec);
2286 25 $sec = ($sec - $min) * 60;
2287 25 my ( $ps, $wid );
2288 25 ▶ if ( defined $arg->{places} && $arg->{places} =~ RE_ALL_DIGITS )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $arg->{'places'} and $arg->{'places'} =~ / \A [0-9]+ \z /msx) { } 25 0 25
Condition33%1/3
defined $arg->{"places"} and $arg->{"places"} =~ / \A [0-9]+ \z /msx
!ll&&!rl&&r
0025
MC/DC0%0/2
defined $arg->{"places"} and $arg->{"places"} =~ / \A [0-9]+ \z /msx
defined $arg->{"places"} $arg->{"places"} =~ / \A [0-9]+ \z /msx
Truth table33%1/3
A and B
A= defined $arg->{"places"}B= $arg->{"places"} =~ / \A [0-9]+ \z /msx
ABresult
0X0
100
111
2289 {
2290 25 $ps = ".$arg->{places}";
2291 25 ▶ $wid = $arg->{places} ? 3 + $arg->{places} : 2;
Branch: 1 branch
BranchTrueFalseTotal
$arg->{'places'} ? : 2 23 25
2292 } else {
2293 0 $ps = '';
2294 0 $wid = 2;
2295 }
2296 defined $arg->{align_left}
2297 25 ▶ or $arg->{align_left} = 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"align_left"} or $arg->{"align_left"} = 0 25 0 25
2298 25 return $self->_format_string(
2299 sprintf( "%02d:%02d:%0$wid${ps}f", $hr, $min, $sec ), $arg,
2300 $fmtr );
2301 }
2302  
2303 1613 ▶sub _format_string {
Subroutine _format_string: called CC=8 SCAR=20.9
2304 1613 my ( $self, $value, $arg ) = @_; # $fmtr unused
2305  
2306 1613 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or goto \&Astro::App::Satpass2::FormatValue::_format_undef 1613 0 1613
2307 or goto &_format_undef;
2308  
2309 defined $arg->{width}
2310 1613 ▶ and $arg->{width} =~ RE_ALL_DIGITS
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx or return "$value" 1389 224 1613
Condition66%2/3
defined $arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx
!ll&&!rl&&r
02241389
MC/DC50%1/2
defined $arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx
defined $arg->{"width"} $arg->{"width"} =~ / \A [0-9]+ \z /msx
Truth table66%2/3
A and B
A= defined $arg->{"width"}B= $arg->{"width"} =~ / \A [0-9]+ \z /msx
ABresult
0X0
100
111
2311 or return "$value";
2312  
2313 1389 ▶ my $left = defined $arg->{align_left} ? $arg->{align_left} : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{'align_left'} ? : 633 756 1389
2314 1389 ▶ $left = $left ? '-' : '';
Branch: 1 branch
BranchTrueFalseTotal
$left ? : 913 476 1389
2315  
2316 1389 my $buffer = sprintf "%$left*s", $arg->{width}, $value;
2317  
2318 length $buffer <= $arg->{width}
2319 or $self->{overflow}
2320 1389 ▶ or return substr $buffer, 0, $arg->{width};
Branch: 1 branch
BranchTrueFalseTotal
length $buffer <= $arg->{"width"} or $self->{"overflow"} or return substr($buffer, 0, $arg->{"width"}) 1306 83 1389
Condition66%2/3
length $buffer <= $arg->{"width"} or $self->{"overflow"}
l!l&&r!l&&!r
1306083
MC/DC50%1/2
length $buffer <= $arg->{"width"} or $self->{"overflow"}
length $buffer <= $arg->{"width"} $self->{"overflow"}
Truth table66%2/3
A or B
A= length $buffer <= $arg->{"width"}B= $self->{"overflow"}
ABresult
1X1
011
000
2321  
2322 1306 return $buffer;
2323 }
2324  
2325 # Called as $self->$method()
2326 285 ▶sub _format_time { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _format_time: called CC=3 SCAR=11.1
2327 285 my ( $self, $value, $arg, $fmtr ) = @_;
2328 285 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or goto \&Astro::App::Satpass2::FormatValue::_format_undef 285 0 285
2329 or goto &_format_undef;
2330  
2331 285 my $time_fmtr = $self->{time_formatter};
2332 285 $time_fmtr->round_time( $arg->{round_time} );
2333 285 my $fmt = $arg->{format};
2334 285 ▶ defined $fmt
Branch: 1 branch
BranchTrueFalseTotal
defined $fmt or $self->weep("No time format") 285 0 285
2335 or $self->weep( 'No time format' );
2336  
2337 my $buffer = $time_fmtr->format_datetime(
2338 285 $fmt, $value, $arg->{gmt} );
2339 285 return $self->_format_string( $buffer, $arg, $fmtr );
2340 }
2341  
2342 # Called as $self->$method()
2343 0 ▶sub _format_title_case { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _format_title_case: not called CC=2 SCAR=17.9
2344 0 my ( $self, $value, $arg, $fmtr ) = @_;
2345 0 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or goto \&Astro::App::Satpass2::FormatValue::_format_undef 0 0 0
2346 or goto &_format_undef;
2347  
2348 ## $value = join '', map { ucfirst lc $_ }
2349 ## split qr{ (?<= [^[:alpha:]] ) (?= [[:alpha:]] ) }sxm, $value;
2350 0 $value =~ s{ (?: \A | (?<= \s ) ) ( [[:alpha:]] \S* ) }
2351 0 { ucfirst lc $1 }sxmge;
2352 0 return $self->_format_string( $value, $arg, $fmtr );
2353 }
2354  
2355 159 ▶sub _format_undef {
Subroutine _format_undef: called CC=7 SCAR=20.5
2356 159 my ( $self, undef, $arg, $fmtr ) = @_; # $value unused
2357  
2358 $self->{title}
2359 and defined $arg->{title}
2360 159 ▶ and return $self->_format_string( $arg->{title}, $arg, $fmtr );
Branch: 1 branch
BranchTrueFalseTotal
$self->{"title"} and defined $arg->{"title"} and return $self->_format_string($arg->{"title"}, $arg, $fmtr) 0 159 159
Condition33%1/3
$self->{"title"} and defined $arg->{"title"}
!ll&&!rl&&r
15900
MC/DC0%0/2
$self->{"title"} and defined $arg->{"title"}
$self->{"title"} defined $arg->{"title"}
Truth table33%1/3
A and B
A= $self->{"title"}B= defined $arg->{"title"}
ABresult
0X0
100
111
2361  
2362 defined $arg->{missing}
2363 159 ▶ and return $self->_format_string( $arg->{missing}, $arg, $fmtr );
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"missing"} and return $self->_format_string($arg->{"missing"}, $arg, $fmtr) 3 156 159
2364  
2365 defined $arg->{width}
2366 and $arg->{width} =~ RE_ALL_DIGITS
2367 and $arg->{width}
2368 156 ▶ or return '';
Branch: 1 branch
BranchTrueFalseTotal
defined $arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx and $arg->{"width"} or return "" 123 33 156
Condition66%4/6
defined $arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx and $arg->{"width"}
!ll&&!rl&&r
330123
defined $arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx
!ll&&!rl&&r
033123
MC/DC33%1/3
defined $arg->{"width"} and $arg->{"width"} =~ / \A [0-9]+ \z /msx and $arg->{"width"}
defined $arg->{"width"} $arg->{"width"} =~ / \A [0-9]+ \z /msx $arg->{"width"}
Truth table50%2/4
A and B and C
A= defined $arg->{"width"}B= $arg->{"width"} =~ / \A [0-9]+ \z /msxC= $arg->{"width"}
ABCresult
0XX0
10X0
1100
1111
2369  
2370 123 return ' ' x $arg->{width};
2371 }
2372  
2373 # Called as $self->$method()
2374 0 ▶sub _format_upper_case { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _format_upper_case: not called CC=2 SCAR=17.9
2375 0 my ( $self, $value, $arg, $fmtr ) = @_;
2376 0 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or goto \&Astro::App::Satpass2::FormatValue::_format_undef 0 0 0
2377 or goto &_format_undef;
2378  
2379 0 return $self->_format_string( uc $value, $arg, $fmtr );
2380 }
2381  
2382 # Called as $self->$method()
2383 4 ▶sub _julian_day { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _julian_day: called CC=1 SCAR=0.0
2384 4 my ( undef, $value ) = @_; # Invocant unused
2385 4 return julianday( $value );
2386 }
2387  
2388 780 ▶sub _get_date_format_data {
Subroutine _get_date_format_data: called CC=2 SCAR=7.0
2389 780 my ( $self, $name, $datum, $info ) = @_;
2390 780 ▶ $self->{internal}{_date_format}{$name} ||=
Condition66%2/3
$self->{"internal"}{"_date_format"}{$name} ||= $self->_manufacture_date_format($name, $info)
l!l&&r!l&&!r
4333470
MC/DC0%0/2
$self->{"internal"}{"_date_format"}{$name} ||= $self->_manufacture_date_format($name, $info)
$self->{"internal"}{"_date_format"}{$name} $self->_manufacture_date_format($name, $info)
Truth table66%2/3
A ||= B
A= $self->{"internal"}{"_date_format"}{$name}B= $self->_manufacture_date_format($name, $info)
ABresult
1X1
011
000
2391 $self->_manufacture_date_format( $name, $info );
2392 780 return $self->{internal}{_date_format}{$name}{$datum};
2393 }
2394  
2395 347 ▶sub _manufacture_date_format {
Subroutine _manufacture_date_format: called CC=2 SCAR=7.1
2396 347 my ( $self, undef, $info ) = @_; # $name unused
2397 405 ▶ my $fmt = join ' ', grep { defined $_ && '' ne $_ }
Condition33%1/3
defined $_ && '' ne $_
!ll&&!rl&&r
00405
MC/DC0%0/2
defined $_ && '' ne $_
defined $_ '' ne $_
Truth table33%1/3
A && B
A= defined $_B= '' ne $_
ABresult
0X0
100
111
2398 347 map { $self->{$_} } @{ $info->{dimension}{format} };
2399 my $wid =
2400 347 $self->{time_formatter}->format_datetime_width( $fmt );
2401 347 return { format => $fmt, width => $wid };
2402 }
2403  
2404 {
2405  
2406 11 my %fmt;
2407  
2408 11 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
2409 11 %fmt = map { $_ => 1 } qw{ date_format time_format };
2410 }
2411  
2412 66 ▶ sub _valid_time_format_name {
Subroutine _valid_time_format_name: called CC=1 SCAR=0.0
2413 66 my ( undef, $name ) = @_;
2414 66 return $fmt{$name};
2415 }
2416 }
2417  
2418 =begin comment
2419  
2420 # TODO remove this after October 1 2016
2421 # It's only still here because, although I can't find a call for it, and
2422 # testcover shows it is not called, I'm paranoid that I did something
2423 # tricky that I can not now remember and is not covered by the tests.
2424  
2425 sub _set_time_format {
2426 my ($self, $name, $data) = @_;
2427 $self->_valid_time_format( $name )
2428 or $self->weep(
2429 "'$name' invalid for _set_time_format()" );
2430 $self->{$name} = $data;
2431 delete $self->{internal}{_date_format};
2432  
2433 return $self;
2434 }
2435  
2436 =end comment
2437  
2438 =cut
2439  
2440 # Called as $self->$method()
2441 11 ▶sub _subtract_epoch { ## no critic (ProhibitUnusedPrivateSubroutines)
Subroutine _subtract_epoch: called CC=2 SCAR=6.9
2442 4 my ( $self, $value ) = @_;
2443 4 my $epoch = $self->_get_tle_attr( body => 'epoch' );
2444 4 ▶ defined $epoch
Branch: 1 branch
BranchTrueFalseTotal
defined $epoch or return $epoch 3 1 4
2445 or return $epoch;
2446 3 return $value - $epoch;
2447 }
2448  
2449 149 ▶sub _variant {
Subroutine _variant: called CC=5 SCAR=16.1
2450 149 my ( $self, $variant ) = @_;
2451  
2452 149 my $data;
2453 149 ▶ if ( defined $variant ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $variant) { } 105 44 149
2454 $data = HASH_REF eq ref $variant ? $variant : { # Shallow clone
2455 105 ▶ %{ $self->_get( data => $variant ) || {} }
Branch: 1 branch
BranchTrueFalseTotal
'HASH' eq ref $variant ? : 20 85 105
Condition100%2/2
$self->_get('data', $variant) || {}
l!l
4936
MC/DC100%1/1
$self->_get('data', $variant) || {}
$self->_get('data', $variant)
Truth table100%2/2
A
A= $self->_get('data', $variant)
Aresult
11
00
2456 };
2457 105 foreach my $key ( qw{ station time } ) {
2458 210 $data->{$key} = $self->_get( data => $key );
2459 }
2460 } else {
2461 44 $data = { %{ $self->_get( 'data' ) } }; # Shallow clone
2462 }
2463  
2464 149 return $self->clone( data => $data );
2465 }
2466  
2467 11 1;
2468  
2469 __END__
« blib/lib/Astro/App/Satpass2/Locale.pm ↑ Summary blib/lib/Astro/App/Satpass2/Geocode/OSM.pm »