| 1 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | Astro::SpaceTrack - Retrieve orbital data from www.space-track.org. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | my $st = Astro::SpaceTrack->new (username => $me, | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | password => $secret, with_name => 1) or die; | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | my $rslt = $st->spacetrack ('special'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | print $rslt->is_success ? $rslt->content : | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | $rslt->status_line; | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | or | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | $ SpaceTrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | (some banner text gets printed here) | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | SpaceTrack> set username me password secret | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | OK | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | SpaceTrack> set with_name 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | OK | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | SpaceTrack> spacetrack special >special.txt | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | SpaceTrack> celestrak visual >visual.txt | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | SpaceTrack> exit | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | In either of the above, username and password entry can be omitted if | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | you have installed L<Config::Identity|Config::Identity>, created an | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | L<IDENTITY FILE|/IDENTITY FILE> (see below) containing these values, and | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | set the C<identity> attribute to a true value. You probably | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | want to encrypt the identity file, if you have C<gpg2> and C<gpg-agent>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | In practice, it is probably not useful to retrieve data from any source | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | more often than once every four hours, and in fact daily usually | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | suffices. | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | =head1 CAVEAT | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | Version 0.180 was an emergency release of this module. It was caused by Space | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | Track deprecating and ultimately revoking the C<'tle_latest'> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | C<'tle'> data classes in favor of C<'gp'> and C<'gp_history'> | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | respectively, and me being oblivious until the revocation occurred. | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | Unlike the previous release (v0.172) release 0.180 will actually return | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | Space Track data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | Known changes: | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | =item The --last5 option is ignored. | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | It is also deprecated, will warn on every use, and will be removed in a | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | future release. This functionality relied on a datum (C<ORDINAL>) that | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | Space Track no longer provides. | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | =item The C<OBJECT_NUMBER> datum is missing from JSON data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | This datum is no longer provided by Space Track, and I am not minded to | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | fudge it in. C<NORAD_CAT_ID> has the same value. | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | =item Favorites do not work | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | In the previous release C<spacetrack()> would fetch canned favorites | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | curated by Space Track. As of January 21 2026 these are 404. | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | =head1 LEGAL NOTICE | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | The following two paragraphs are quoted from the Space Track web site. | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | Due to existing National Security Restrictions pertaining to access of | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | and use of U.S. Government-provided information and data, all users | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | accessing this web site must be an approved registered user to access | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | data on this site. | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | By logging in to the site, you accept and agree to the terms of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | User Agreement specified in | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | L<https://www.space-track.org/documentation#/user_agree>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | You should consult the above link for the full text of the user | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | agreement before using this software to retrieve content from the Space | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | Track web site. | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | =head1 FUNCTIONAL NOTICES | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | =head2 CELESTRAK API | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | The Celestrak web site, L<https://celestrak.org/>, is in transition from | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | being simply a file based repository of TLEs to an API-based service | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | providing orbital elements in a number of formats. The C<celestrak()> | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | and C<celestrak_supplemental()> methods will track this, growing new | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | arguments as needed. | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | =head2 DEPRECATION NOTICE: IRIDIUM STATUS | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | As of version 0.137, Iridium status format C<'mccants'> is fully | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | deprecated, and will result in an exception. | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | As of version 0.143, any access of attribute | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | C<url_iridium_status_mccants> is fatal. | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | As of version 0.169, any use of attribute C<url_iridium_status_kelso> is | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | fatal. | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | As of version 0.181, B<any> remaining functionality relating to Iridium | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | Classic satellites is fatal, except for attribute iridium_status_format, | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | which I missed, and which warns on every use as of version 0.183. Six | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | months after this release it will become fatal, and six months after | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | that all Iridium functionality will be dropped. | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | This package retrieves orbital data from the Space Track web site | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | L<https://www.space-track.org> and several others. You must register and | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | get a user name and password before you can get data from Space Track. | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | Other methods (C<celestrak()> ...) have | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | been added to access other repositories of orbital data, and in general | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | these do not require a Space Track username and password. | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | Nothing is exported by default, but the shell method/subroutine | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | and the BODY_STATUS constants (see C<iridium_status()>) | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | can be exported if you so desire. | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | Most methods return an HTTP::Response object. See the individual | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | method document for details. Methods which return orbital data on | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | success add a 'Pragma: spacetrack-type = orbit' header to the | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | HTTP::Response object if the request succeeds, and a 'Pragma: | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | spacetrack-source =' header to specify what source the data came from. | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | =head2 Methods | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | The following methods should be considered public: | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | package Astro::SpaceTrack; | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | ▶ | use 5.006002; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 7 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 7 | our @ISA = qw{ Exporter }; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 7 | our $VERSION = '0.184'; | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | 7 | our @EXPORT_OK = qw{ | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | shell | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | BODY_STATUS_IS_OPERATIONAL | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | BODY_STATUS_IS_SPARE | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | BODY_STATUS_IS_TUMBLING | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | BODY_STATUS_IS_DECAYED | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | ARRAY_REF | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | CODE_REF | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | HASH_REF | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | our %EXPORT_TAGS = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 56 | ref => [ grep { m/ _REF \z /smx } @EXPORT_OK ], | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | 7 | status => [ grep { m/ \A BODY_STATUS_IS_ /smx } @EXPORT_OK ], | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 7 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 7 | ▶ | use Getopt::Long 2.39; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 7 | ▶ | use HTTP::Date (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 7 | ▶ | use HTTP::Request; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 7 | ▶ | use HTTP::Response; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 7 | ▶ | use HTTP::Status qw{ | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | HTTP_PAYMENT_REQUIRED | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | HTTP_BAD_REQUEST | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | HTTP_NOT_FOUND | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | HTTP_I_AM_A_TEAPOT | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | HTTP_INTERNAL_SERVER_ERROR | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | HTTP_NOT_ACCEPTABLE | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | HTTP_NOT_MODIFIED | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | HTTP_OK | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | HTTP_PRECONDITION_FAILED | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | HTTP_UNAUTHORIZED | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | HTTP_INTERNAL_SERVER_ERROR | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | 7 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 7 | ▶ | use IO::Uncompress::Unzip (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 7 | ▶ | use JSON qw{}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 7 | ▶ | use List::Util (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 7 | ▶ | use LWP::UserAgent; # Not in the base. | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 7 | ▶ | use POSIX (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 7 | ▶ | use Scalar::Util 1.07 (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 7 | ▶ | use Text::ParseWords (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 7 | ▶ | use Time::Local (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 7 | ▶ | use URI qw{}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # use URI::Escape qw{}; | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # Number of OIDs to retrieve at once. This is a global variable so I can | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # play with it, but it is neither documented nor supported, and I | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # reserve the right to change it or delete it without notice. | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 7 | our $RETRIEVAL_SIZE = $ENV{SPACETRACK_RETRIEVAL_SIZE}; | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | 7 | ▶ | defined $RETRIEVAL_SIZE or $RETRIEVAL_SIZE = 200; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 7 | ▶ | use constant COPACETIC => 'OK'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 7 | ▶ | use constant BAD_SPACETRACK_RESPONSE => | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 7 | 'Unable to parse SpaceTrack response'; | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | 7 | ▶ | use constant INVALID_CATALOG => | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 7 | 'Catalog name %s invalid. Legal names are %s.'; | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | 7 | ▶ | use constant LAPSED_FUNDING => 'Funding lapsed.'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 7 | ▶ | use constant LOGIN_FAILED => 'Login failed'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 7 | ▶ | use constant NO_CREDENTIALS => 'Username or password not specified.'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 7 | ▶ | use constant NO_CAT_ID => 'No catalog IDs specified.'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 7 | ▶ | use constant NO_OBJ_NAME => 'No object name specified.'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 7 | ▶ | use constant NO_RECORDS => 'No records found.'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 7 | ▶ | use constant SESSION_PATH => '/'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 7 | ▶ | use constant DEFAULT_SPACE_TRACK_REST_SEARCH_CLASS => 'satcat'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 7 | ▶ | use constant DEFAULT_SPACE_TRACK_VERSION => 2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # dump_headers constants. | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 7 | ▶ | use constant DUMP_NONE => 0; # No dump | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 7 | ▶ | use constant DUMP_TRACE => 0x01; # Logic trace | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 7 | ▶ | use constant DUMP_REQUEST => 0x02; # Request content | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 7 | ▶ | use constant DUMP_DRY_RUN => 0x04; # Do not execute request | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 7 | ▶ | use constant DUMP_COOKIE => 0x08; # Dump cookies. | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 7 | ▶ | use constant DUMP_RESPONSE => 0x10; # Dump response. | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 7 | ▶ | use constant DUMP_TRUNCATED => 0x20; # Dump with truncated content | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 7 | my @dump_options; | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | 7 | foreach my $key ( sort keys %Astro::SpaceTrack:: ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1694 | ▶ | $key =~ s/ \A DUMP_ //smx | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 49 | push @dump_options, lc $key; | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # Manifest constants for reference types | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 7 | ▶ | use constant ARRAY_REF => ref []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 7 | ▶ | use constant CODE_REF => ref sub {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 7 | ▶ | use constant HASH_REF => ref {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # These are the Space Track version 1 retrieve Getopt::Long option | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # specifications, and the descriptions of each option. These need to | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # survive the retirement of Version 1 as a separate entity because I | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # emulated them in the celestrak() method. I'm _NOT_ | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # emulating the options added in version 2 because they require parsing | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # the TLE. | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 7 | ▶ | use constant CLASSIC_RETRIEVE_OPTIONS => [ | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | descending => '(direction of sort)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 'end_epoch=s' => 'date', | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | last5 => '(ignored and deprecated)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 'sort=s' => | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | "type ('catnum' or 'epoch', with 'catnum' the default)", | ||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 'start_epoch=s' => 'date', | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 7 | ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 7 | ▶ | use constant CELESTRAK_API_OPTIONS => [ | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 'query=s', 'query type', | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 'format=s', 'data format', | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 7 | ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 7 | ▶ | use constant CELESTRAK_OPTIONS => [ | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # @{ CLASSIC_RETRIEVE_OPTIONS() }, # TODO deprecate and remove | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 7 | @{ CELESTRAK_API_OPTIONS() }, | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | 7 | ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 7 | ▶ | use constant CELESTRAK_SUPPLEMENTAL_VALID_QUERY => { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 7 | map { $_ => 1 } qw{ CATNR INTDES SOURCE NAME SPECIAL FILE } }; | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 7 | ▶ | use constant CELESTRAK_VALID_QUERY => { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 7 | map { $_ => 1 } qw{ CATNR INTDES GROUP NAME SPECIAL } }; | |||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 7 | our $COMPLETION_APP; # A hack. | |||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 7 | my %catalogs = ( # Catalog names (and other info) for each source. | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | celestrak => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 'last-30-days' => {name => "Last 30 Days' Launches"}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | stations => {name => 'International Space Station'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | visual => {name => '100 (or so) brightest'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | active => { name => 'Active Satellites' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | analyst => { name => 'Analyst Satellites' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | weather => {name => 'Weather'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # Removed April 1 2026 | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # noaa => {name => 'NOAA'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # Removed April 1 2026 | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # goes => {name => 'GOES'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | resource => {name => 'Earth Resources'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | sarsat => {name => 'Search and Rescue (SARSAT)'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | dmc => {name => 'Disaster Monitoring'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | tdrss => {name => 'Tracking and Data Relay Satellite System (TDRSS)'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | geo => {name => 'Geostationary'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | intelsat => {name => 'Intelsat'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # Removed May 8 2025 | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # gorizont => {name => 'Gorizont'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # Removed May 8 2025 | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # raduga => {name => 'Raduga'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # Removed May 8 2025 | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # molniya => {name => 'Molniya'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # Removed May 8 2025 | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # iridium => {name => 'Iridium'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 'iridium-NEXT' => { name => 'Iridium NEXT' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | ses => { name => 'SES communication satellites' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | orbcomm => {name => 'Orbcomm'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 307 | globalstar => {name => 'Globalstar'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | amateur => {name => 'Amateur Radio'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 'x-comm' => {name => 'Experimental Communications'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 'other-comm' => {name => 'Other communications'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 'gps-ops' => {name => 'GPS Operational'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 'glo-ops' => {name => 'Glonass Operational'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | galileo => {name => 'Galileo'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | sar => { name => 'Synthetic Aperture Radar' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | sbas => {name => | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 'Satellite-Based Augmentation System (WAAS/EGNOS/MSAS)'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # Removed April 16 2026 | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # nnss => {name => 'Navy Navigation Satellite System (NNSS)'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # Removed April 16 2026 | ||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # musson => {name => 'Russian LEO Navigation'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | science => {name => 'Space and Earth Science'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 322 | geodetic => {name => 'Geodetic'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | engineering => {name => 'Engineering'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 324 | education => {name => 'Education'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 325 | military => {name => 'Miscellaneous Military'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | radar => {name => 'Radar Calibration'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | cubesat => {name => 'CubeSats'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # Removed April 16 2026 | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # other => {name => 'Other'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 330 | beidou => { name => 'Beidou navigational satellites' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | argos => { name => 'ARGOS Data Collection System' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | planet => { name => 'Planet Labs (Rapideye, Flock)' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 333 | spire => { name => 'Spire Global (Lemur weather and ship tracking)' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | satnogs => { name => 'SatNOGS' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | starlink => { name => 'Starlink' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 336 | oneweb => { name => 'OneWeb' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | # Removed May 8 2025 | ||||||||||||||||||||||||||||||||||||||||||||||
| 338 | # swarm => { name => 'Swarm' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | gnss => { name => 'GNSS navigational satellites' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # Removed April 1 2026 | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | # '1982-092' => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # name => 'Russian ASAT Test Debris (COSMOS 1408)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | # note => q/'cosmos-1408-debris' as of April 26 2024/, | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # ignore => 1, # Ignore in xt/author/celestrak_datasets.t | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | #}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # Removed April 1 2026 | ||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # 'cosmos-1408-debris' => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # name => 'Russian ASAT Test Debris (COSMOS 1408)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | '1999-025' => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | name => 'Fengyun 1C debris', | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | note => q/'fengyun-1c-debris' as of April 26 2024/, | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | ignore => 1, # Ignore in xt/author/celestrak_datasets.t | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 'fengyun-1c-debris' => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | name => 'Fengyun 1C debris', | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 'cosmos-2251-debris' => { name => 'Cosmos 2251 debris' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 'iridium-33-debris' => { name => 'Iridium 33 debris' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | '2012-044' => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 361 | name => 'BREEZE-M R/B Breakup (2012-044C)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | note => 'Fetchable as of November 16 2021, but not on web page', | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | ignore => 1, # Ignore in xt/author/celestrak_datasets.t | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # Removed 2022-05-12 | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # '2019-006' => { name => 'Indian ASAT Test Debris' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | eutelsat => { name => 'Eutelsat' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 368 | kuiper => { name => 'Kuiper' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | telesat => { name => 'Telesat' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 370 | hulianwang => { name => 'Hulianwang' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 371 | qianfan => { name => 'Qianfan' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 372 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 373 | celestrak_supplemental => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # Removed 2024-12-27 | ||||||||||||||||||||||||||||||||||||||||||||||
| 375 | # Added back 2024-12-29 | ||||||||||||||||||||||||||||||||||||||||||||||
| 376 | ast => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 377 | name => 'AST Space Mobile', | ||||||||||||||||||||||||||||||||||||||||||||||
| 378 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 380 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # Removed 2024-12-27 | ||||||||||||||||||||||||||||||||||||||||||||||
| 382 | # Added back 2024-12-29 | ||||||||||||||||||||||||||||||||||||||||||||||
| 383 | cpf => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | name => 'CPF (no match data)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # source => 'CPF', | ||||||||||||||||||||||||||||||||||||||||||||||
| 386 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 387 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # Removed 2024-12-27 | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | # Added back 2024-12-29 | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | css => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | name => 'CSS (no match data)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 392 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 393 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | eumetsat => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 395 | name => 'EUMETSAT', | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 397 | match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 398 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | gps => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | name => 'GPS Operational', | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | # source => 'GPS-A', | ||||||||||||||||||||||||||||||||||||||||||||||
| 402 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 403 | match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 404 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 405 | glonass => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | name => 'GLONASS Operational', | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | # source => 'GLONASS-RE', | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 409 | match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | iridium => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 412 | name => 'Iridium Next', | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # source => 'Iridium-E', | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 415 | match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 416 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # Removed 2024-12-27 | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # Added back 2024-12-29 | ||||||||||||||||||||||||||||||||||||||||||||||
| 419 | iss => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | name => 'ISS (from NASA, no match data)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # source => 'ISS-E', | ||||||||||||||||||||||||||||||||||||||||||||||
| 422 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # Removed 2024-01-12 | ||||||||||||||||||||||||||||||||||||||||||||||
| 425 | #meteosat => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # name => 'METEOSAT', | ||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # # source => 'METEOSAT-SV', | ||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 429 | # match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | #}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 431 | intelsat => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | name => 'Intelsat', | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # source => 'Intelsat-11P', | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 435 | match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 436 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # Removed 2024-12-27 | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # Added back 2024-12-29 | ||||||||||||||||||||||||||||||||||||||||||||||
| 439 | kuiper => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | name => 'Project Kuiper (Amazon; no match data)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 441 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 443 | oneweb => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | name => 'OneWeb', | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # source => 'OneWeb-E', | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 448 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 449 | # Removed 2024-12-25 | ||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # Added back 2025-07-28, with RMS and match data | ||||||||||||||||||||||||||||||||||||||||||||||
| 451 | orbcomm => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 452 | name => 'Orbcomm (no RMS or match data)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 453 | # source => 'Orbcomm-TLE', | ||||||||||||||||||||||||||||||||||||||||||||||
| 454 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 455 | match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 456 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 457 | planet => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 458 | name => 'Planet (no, not Mercury etc)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # source => 'Planet-E', | ||||||||||||||||||||||||||||||||||||||||||||||
| 460 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 461 | match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 462 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # Removed 2024-04-26 | ||||||||||||||||||||||||||||||||||||||||||||||
| 464 | # Added back 2024-05-23 | ||||||||||||||||||||||||||||||||||||||||||||||
| 465 | ses => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 466 | name => 'SES', | ||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # source => 'SES-11P', | ||||||||||||||||||||||||||||||||||||||||||||||
| 468 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 469 | match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 470 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 471 | starlink => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 472 | name => 'Starlink', | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | # source => 'SpaceX-E', | ||||||||||||||||||||||||||||||||||||||||||||||
| 474 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 475 | match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 476 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 477 | telesat => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 478 | name => 'Telesat', | ||||||||||||||||||||||||||||||||||||||||||||||
| 479 | # source => 'Telesat-E', | ||||||||||||||||||||||||||||||||||||||||||||||
| 480 | rms => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 481 | match => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 482 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 484 | iridium_status => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 485 | kelso => {name => 'Celestrak (Kelso)'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 486 | mccants => {name => 'McCants'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 487 | sladen => {name => 'Sladen'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 488 | spacetrack => { name => 'SpaceTrack' }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 489 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 490 | mccants => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 491 | classified => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 492 | name => 'Classified TLE file', | ||||||||||||||||||||||||||||||||||||||||||||||
| 493 | member => undef, # classfd.tle | ||||||||||||||||||||||||||||||||||||||||||||||
| 494 | spacetrack_type => 'orbit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 495 | url => 'https://www.mmccants.org/tles/classfd.zip', | ||||||||||||||||||||||||||||||||||||||||||||||
| 496 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 497 | integrated => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 498 | name => 'Integrated TLE file', | ||||||||||||||||||||||||||||||||||||||||||||||
| 499 | member => undef, # inttles.tle | ||||||||||||||||||||||||||||||||||||||||||||||
| 500 | spacetrack_type => 'orbit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 501 | url => 'https://www.mmccants.org/tles/inttles.zip', | ||||||||||||||||||||||||||||||||||||||||||||||
| 502 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 503 | # Removed 2025-12-15 or thereabouts | ||||||||||||||||||||||||||||||||||||||||||||||
| 504 | #mcnames => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 505 | # name => 'Molczan-format magnitude file', | ||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # member => undef, # mcnames | ||||||||||||||||||||||||||||||||||||||||||||||
| 507 | # spacetrack_type => 'molczan', | ||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # url => 'https://www.mmccants.org/tles/mcnames.zip', | ||||||||||||||||||||||||||||||||||||||||||||||
| 509 | #}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # Removed 2025-12-15 or thereabouts | ||||||||||||||||||||||||||||||||||||||||||||||
| 511 | #quicksat => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # name => 'Quicksat-format magnitude file', | ||||||||||||||||||||||||||||||||||||||||||||||
| 513 | # member => undef, # qs.mag | ||||||||||||||||||||||||||||||||||||||||||||||
| 514 | # spacetrack_type => 'quicksat', | ||||||||||||||||||||||||||||||||||||||||||||||
| 515 | # url => 'https://www.mmccants.org/programs/qsmag.zip', | ||||||||||||||||||||||||||||||||||||||||||||||
| 516 | #}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 517 | # Removed 2024-12-29. | ||||||||||||||||||||||||||||||||||||||||||||||
| 518 | #rcs => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # name => 'McCants-format RCS data (404 2024-04-27)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 520 | # member => undef, # rcs | ||||||||||||||||||||||||||||||||||||||||||||||
| 521 | # spacetrack_type => 'rcs.mccants', | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # url => 'https://www.mmccants.org/catalogs/rcs.zip', | ||||||||||||||||||||||||||||||||||||||||||||||
| 523 | #}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # Removed 2025-12-15 or thereabouts | ||||||||||||||||||||||||||||||||||||||||||||||
| 525 | #vsnames => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # name => 'Molczan-format magnitude file (visual only)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 527 | # member => undef, # vsnames | ||||||||||||||||||||||||||||||||||||||||||||||
| 528 | # spacetrack_type => 'molczan', | ||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # url => 'https://www.mmccants.org/tles/vsnames.zip', | ||||||||||||||||||||||||||||||||||||||||||||||
| 530 | #}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 531 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 532 | spacetrack => [ # Numbered by space_track_version | ||||||||||||||||||||||||||||||||||||||||||||||
| 533 | undef, # No interface version 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 534 | undef, # No interface version 1 any more | ||||||||||||||||||||||||||||||||||||||||||||||
| 535 | { # Interface version 2 (REST) | ||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||
| 537 | # On Space Track "Recent ELSETs" tab | ||||||||||||||||||||||||||||||||||||||||||||||
| 538 | full => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 539 | name => 'Full catalog', | ||||||||||||||||||||||||||||||||||||||||||||||
| 540 | # As of 2026-01-19 | ||||||||||||||||||||||||||||||||||||||||||||||
| 541 | # https://www.space-track.org/basicspacedata/query/class/gp/EPOCH/%3Enow-30/orderby/NORAD_CAT_ID,EPOCH/format/3le | ||||||||||||||||||||||||||||||||||||||||||||||
| 542 | # We have to go through satcat to eliminate bodies that | ||||||||||||||||||||||||||||||||||||||||||||||
| 543 | # are not on orbit, since tle_latest includes bodies | ||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # decayed in the last two years or so | ||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # satcat => {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 546 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 547 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 548 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # number => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 550 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 551 | geosynchronous => { # GEO | ||||||||||||||||||||||||||||||||||||||||||||||
| 552 | name => 'Geosynchronous satellites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 553 | # As of 2026-01-19 | ||||||||||||||||||||||||||||||||||||||||||||||
| 554 | # https://www.space-track.org/basicspacedata/query/class/gp/EPOCH/%3Enow-30/MEAN_MOTION/0.99--1.01/ECCENTRICITY/%3C0.01/OBJECT_TYPE/payload/orderby/NORAD_CAT_ID,EPOCH/format/3le | ||||||||||||||||||||||||||||||||||||||||||||||
| 555 | # number => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 556 | # We have to go through satcat to eliminate bodies that | ||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # are not on orbit, since tle_latest includes bodies | ||||||||||||||||||||||||||||||||||||||||||||||
| 558 | # decayed in the last two years or so | ||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # satcat => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # PERIOD => '1425.6--1454.4' | ||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 562 | # Note that the v2 interface specimen query is | ||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # PERIOD 1430--1450. | ||||||||||||||||||||||||||||||||||||||||||||||
| 564 | # The v1 definition is | ||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # MEAN_MOTION 0.99--1.01 | ||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # ECCENTRICITY <0.01 | ||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 568 | # ECCENTRICITY => '<0.01', | ||||||||||||||||||||||||||||||||||||||||||||||
| 569 | ## MEAN_MOTION => '0.99--1.01', | ||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 571 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 572 | ECCENTRICITY => '<0.01', | ||||||||||||||||||||||||||||||||||||||||||||||
| 573 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 574 | MEAN_MOTION => '0.99--1.01', | ||||||||||||||||||||||||||||||||||||||||||||||
| 575 | OBJECT_TYPE => 'payload', | ||||||||||||||||||||||||||||||||||||||||||||||
| 576 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 577 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 578 | medium_earth_orbit => { # MEO | ||||||||||||||||||||||||||||||||||||||||||||||
| 579 | name => 'Medium Earth Orbit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 580 | # As of 2026-01-19 | ||||||||||||||||||||||||||||||||||||||||||||||
| 581 | # https://www.space-track.org/basicspacedata/query/class/gp/EPOCH/%3Enow-30/MEAN_MOTION/1.8--2.39/ECCENTRICITY/%3C0.25/OBJECT_TYPE/payload/orderby/NORAD_CAT_ID,EPOCH/format/3le | ||||||||||||||||||||||||||||||||||||||||||||||
| 582 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 583 | ECCENTRICITY => '<0.25', | ||||||||||||||||||||||||||||||||||||||||||||||
| 584 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # The web page says '600 minutes <= Period <= 800 | ||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # minutes', but the query is in terms of mean | ||||||||||||||||||||||||||||||||||||||||||||||
| 587 | # motion. | ||||||||||||||||||||||||||||||||||||||||||||||
| 588 | MEAN_MOTION => '1.8--2.39', | ||||||||||||||||||||||||||||||||||||||||||||||
| 589 | OBJECT_TYPE => 'payload', | ||||||||||||||||||||||||||||||||||||||||||||||
| 590 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 591 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 592 | low_earth_orbit => { # LEO | ||||||||||||||||||||||||||||||||||||||||||||||
| 593 | name => 'Low Earth Orbit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 594 | # As of 2026-01-19https://www.space-track.org/basicspacedata/query/class/gp/EPOCH/%3Enow-30/ECCENTRICITY/%3E0.25/OBJECT_TYPE/payload/orderby/NORAD_CAT_ID,EPOCH/format/3le | ||||||||||||||||||||||||||||||||||||||||||||||
| 595 | # https://www.space-track.org/basicspacedata/query/class/gp/EPOCH/%3Enow-30/MEAN_MOTION/%3E11.25/ECCENTRICITY/%3C0.25/OBJECT_TYPE/payload/orderby/NORAD_CAT_ID,EPOCH/format/3le | ||||||||||||||||||||||||||||||||||||||||||||||
| 596 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 597 | ECCENTRICITY => '<0.25', | ||||||||||||||||||||||||||||||||||||||||||||||
| 598 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 599 | MEAN_MOTION => '>11.25', | ||||||||||||||||||||||||||||||||||||||||||||||
| 600 | OBJECT_TYPE => 'payload', | ||||||||||||||||||||||||||||||||||||||||||||||
| 601 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 602 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 603 | highly_elliptical_orbit => { # HEO | ||||||||||||||||||||||||||||||||||||||||||||||
| 604 | name => 'Highly Elliptical Orbit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 605 | # As of 2026-01-19 | ||||||||||||||||||||||||||||||||||||||||||||||
| 606 | # https://www.space-track.org/basicspacedata/query/class/gp/EPOCH/%3Enow-30/ECCENTRICITY/%3E0.25/OBJECT_TYPE/payload/orderby/NORAD_CAT_ID,EPOCH/format/3le | ||||||||||||||||||||||||||||||||||||||||||||||
| 607 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 608 | ECCENTRICITY => '>0.25', | ||||||||||||||||||||||||||||||||||||||||||||||
| 609 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 610 | OBJECT_TYPE => 'payload', | ||||||||||||||||||||||||||||||||||||||||||||||
| 611 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 612 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 613 | globalstar => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 614 | name => 'Globalstar satellites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 615 | # As of 2026-01-19 | ||||||||||||||||||||||||||||||||||||||||||||||
| 616 | # https://www.space-track.org/basicspacedata/query/class/gp/EPOCH/%3Enow-30/OBJECT_TYPE/payload/orderby/NORAD_CAT_ID,EPOCH/format/3le/OBJECT_NAME/globalstar~~/ | ||||||||||||||||||||||||||||||||||||||||||||||
| 617 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 618 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 619 | OBJECT_NAME => 'globalstar~~', | ||||||||||||||||||||||||||||||||||||||||||||||
| 620 | OBJECT_TYPE => 'payload', | ||||||||||||||||||||||||||||||||||||||||||||||
| 621 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # number => 13, | ||||||||||||||||||||||||||||||||||||||||||||||
| 623 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 624 | inmarsat => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 625 | name => 'Inmarsat satellites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 626 | # As of 2026-01-19 | ||||||||||||||||||||||||||||||||||||||||||||||
| 627 | # https://www.space-track.org/basicspacedata/query/class/gp/EPOCH/%3Enow-30/OBJECT_TYPE/payload/orderby/NORAD_CAT_ID,EPOCH/format/3le/OBJECT_NAME/inmarsat~~/ | ||||||||||||||||||||||||||||||||||||||||||||||
| 628 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 629 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 630 | OBJECT_NAME => 'inmarsat~~', | ||||||||||||||||||||||||||||||||||||||||||||||
| 631 | OBJECT_TYPE => 'payload', | ||||||||||||||||||||||||||||||||||||||||||||||
| 632 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 633 | # number => 17, | ||||||||||||||||||||||||||||||||||||||||||||||
| 634 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 635 | intelsat => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 636 | name => 'Intelsat satellites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 637 | # As of 2026-01-19 | ||||||||||||||||||||||||||||||||||||||||||||||
| 638 | # https://www.space-track.org/basicspacedata/query/class/gp/EPOCH/%3Enow-30/OBJECT_TYPE/payload/orderby/NORAD_CAT_ID,EPOCH/format/3le/OBJECT_NAME/intelsat~~/ | ||||||||||||||||||||||||||||||||||||||||||||||
| 639 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 640 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 641 | OBJECT_NAME => 'intelsat~~', | ||||||||||||||||||||||||||||||||||||||||||||||
| 642 | OBJECT_TYPE => 'payload', | ||||||||||||||||||||||||||||||||||||||||||||||
| 643 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 644 | # number => 15, | ||||||||||||||||||||||||||||||||||||||||||||||
| 645 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 646 | iridium => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 647 | name => 'Iridium satellites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # As of 2026-01-19 | ||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # https://www.space-track.org/basicspacedata/query/class/gp/EPOCH/%3Enow-30/OBJECT_TYPE/payload/orderby/NORAD_CAT_ID,EPOCH/format/3le/OBJECT_NAME/iridium~~/ | ||||||||||||||||||||||||||||||||||||||||||||||
| 650 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 651 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 652 | OBJECT_NAME => 'iridium~~', | ||||||||||||||||||||||||||||||||||||||||||||||
| 653 | OBJECT_TYPE => 'payload', | ||||||||||||||||||||||||||||||||||||||||||||||
| 654 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 655 | # number => 9, | ||||||||||||||||||||||||||||||||||||||||||||||
| 656 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 657 | orbcomm => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 658 | name => 'OrbComm satellites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 659 | # As of 2026-01-19 | ||||||||||||||||||||||||||||||||||||||||||||||
| 660 | # https://www.space-track.org/basicspacedata/query/class/gp/EPOCH/%3Enow-30/OBJECT_NAME/~~orbcomm,~~VESSELSAT/OBJECT_TYPE/payload/orderby/NORAD_CAT_ID,EPOCH/format/3le | ||||||||||||||||||||||||||||||||||||||||||||||
| 661 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 662 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 663 | OBJECT_NAME => 'ORBCOMM~~,VESSELSAT~~', | ||||||||||||||||||||||||||||||||||||||||||||||
| 664 | OBJECT_TYPE => 'payload', | ||||||||||||||||||||||||||||||||||||||||||||||
| 665 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 666 | # number => 11, | ||||||||||||||||||||||||||||||||||||||||||||||
| 667 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 668 | well_tracked_objects => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 669 | name => 'Well-Tracked Objects', | ||||||||||||||||||||||||||||||||||||||||||||||
| 670 | # As of 2026-01-19 | ||||||||||||||||||||||||||||||||||||||||||||||
| 671 | # https://www.space-track.org/basicspacedata/query/class/gp/EPOCH/%3Enow-30/NORAD_CAT_ID/80000--89999/orderby/NORAD_CAT_ID/format/tle/emptyresult/show | ||||||||||||||||||||||||||||||||||||||||||||||
| 672 | # satcat => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 673 | # COUNTRY => 'UNKN', | ||||||||||||||||||||||||||||||||||||||||||||||
| 674 | # SITE => 'UNKN', | ||||||||||||||||||||||||||||||||||||||||||||||
| 675 | # }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 676 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 677 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 678 | NORAD_CAT_ID => '80000--89999', | ||||||||||||||||||||||||||||||||||||||||||||||
| 679 | format => 'tle', | ||||||||||||||||||||||||||||||||||||||||||||||
| 680 | epmtyresult => 'show', | ||||||||||||||||||||||||||||||||||||||||||||||
| 681 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 682 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||
| 684 | # Favorites (whatever that means). As of 2026-01-19 these | ||||||||||||||||||||||||||||||||||||||||||||||
| 685 | # are specific to the individual user, and therefore | ||||||||||||||||||||||||||||||||||||||||||||||
| 686 | # useless. | ||||||||||||||||||||||||||||||||||||||||||||||
| 687 | navigation => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 688 | name => 'Navigation satellites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 689 | favorite => 'Navigation', | ||||||||||||||||||||||||||||||||||||||||||||||
| 690 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 691 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 692 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 693 | # number => 5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 694 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 695 | weather => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 696 | name => 'Weather satellites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 697 | favorite => 'Weather', | ||||||||||||||||||||||||||||||||||||||||||||||
| 698 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 699 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 700 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 701 | # number => 7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 702 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 703 | amateur => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 704 | favorite => 'Amateur', | ||||||||||||||||||||||||||||||||||||||||||||||
| 705 | name => 'Amateur Radio satellites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 706 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 707 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 708 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 709 | # number => 19, | ||||||||||||||||||||||||||||||||||||||||||||||
| 710 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 711 | visible => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 712 | favorite => 'Visible', | ||||||||||||||||||||||||||||||||||||||||||||||
| 713 | name => 'Visible satellites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 714 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 715 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 716 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 717 | # number => 21, | ||||||||||||||||||||||||||||||||||||||||||||||
| 718 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 719 | special => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 720 | favorite => 'Special_interest', | ||||||||||||||||||||||||||||||||||||||||||||||
| 721 | name => 'Special interest satellites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 722 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 723 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 724 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 725 | # number => 23, | ||||||||||||||||||||||||||||||||||||||||||||||
| 726 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 727 | bright_geosynchronous => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 728 | favorite => 'brightgeo', | ||||||||||||||||||||||||||||||||||||||||||||||
| 729 | name => 'Bright Geosynchronous satellites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 730 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 731 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 732 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 733 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 734 | human_spaceflight => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 735 | favorite => 'human_spaceflight', | ||||||||||||||||||||||||||||||||||||||||||||||
| 736 | name => 'Human Spaceflight', | ||||||||||||||||||||||||||||||||||||||||||||||
| 737 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 738 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 739 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 740 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||
| 742 | # Added by TRW | ||||||||||||||||||||||||||||||||||||||||||||||
| 743 | payloads => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 744 | name => 'All payloads', | ||||||||||||||||||||||||||||||||||||||||||||||
| 745 | # satcat => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 746 | # OBJECT_TYPE => 'PAYLOAD', | ||||||||||||||||||||||||||||||||||||||||||||||
| 747 | # }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 748 | tle => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 749 | EPOCH => '>now-30', | ||||||||||||||||||||||||||||||||||||||||||||||
| 750 | OBJECT_TYPE => 'payload', | ||||||||||||||||||||||||||||||||||||||||||||||
| 751 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 752 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 753 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 754 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 755 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 7 | my %mutator = ( # Mutators for the various attributes. | |||||||||||||||||||||||||||||||||||||||||||||
| 758 | addendum => \&_mutate_attrib, # Addendum to banner text. | ||||||||||||||||||||||||||||||||||||||||||||||
| 759 | banner => \&_mutate_attrib, | ||||||||||||||||||||||||||||||||||||||||||||||
| 760 | cookie_expires => \&_mutate_spacetrack_interface, | ||||||||||||||||||||||||||||||||||||||||||||||
| 761 | cookie_name => \&_mutate_spacetrack_interface, | ||||||||||||||||||||||||||||||||||||||||||||||
| 762 | domain_space_track => \&_mutate_spacetrack_interface, | ||||||||||||||||||||||||||||||||||||||||||||||
| 763 | dump_headers => \&_mutate_dump_headers, # Dump all HTTP headers. Undocumented and unsupported. | ||||||||||||||||||||||||||||||||||||||||||||||
| 764 | fallback => \&_mutate_attrib, | ||||||||||||||||||||||||||||||||||||||||||||||
| 765 | filter => \&_mutate_attrib, | ||||||||||||||||||||||||||||||||||||||||||||||
| 766 | identity => \&_mutate_identity, | ||||||||||||||||||||||||||||||||||||||||||||||
| 767 | iridium_status_format => \&_mutate_iridium_status_format, | ||||||||||||||||||||||||||||||||||||||||||||||
| 768 | max_range => \&_mutate_number, | ||||||||||||||||||||||||||||||||||||||||||||||
| 769 | password => \&_mutate_authen, | ||||||||||||||||||||||||||||||||||||||||||||||
| 770 | pretty => \&_mutate_attrib, | ||||||||||||||||||||||||||||||||||||||||||||||
| 771 | prompt => \&_mutate_attrib, | ||||||||||||||||||||||||||||||||||||||||||||||
| 772 | scheme_space_track => \&_mutate_attrib, | ||||||||||||||||||||||||||||||||||||||||||||||
| 773 | session_cookie => \&_mutate_spacetrack_interface, | ||||||||||||||||||||||||||||||||||||||||||||||
| 774 | space_track_version => \&_mutate_space_track_version, | ||||||||||||||||||||||||||||||||||||||||||||||
| 775 | url_iridium_status_kelso => \&_mutate_attrib, | ||||||||||||||||||||||||||||||||||||||||||||||
| 776 | url_iridium_status_mccants => \&_mutate_attrib, | ||||||||||||||||||||||||||||||||||||||||||||||
| 777 | url_iridium_status_sladen => \&_mutate_attrib, | ||||||||||||||||||||||||||||||||||||||||||||||
| 778 | username => \&_mutate_authen, | ||||||||||||||||||||||||||||||||||||||||||||||
| 779 | verbose => \&_mutate_attrib, | ||||||||||||||||||||||||||||||||||||||||||||||
| 780 | verify_hostname => \&_mutate_verify_hostname, | ||||||||||||||||||||||||||||||||||||||||||||||
| 781 | webcmd => \&_mutate_attrib, | ||||||||||||||||||||||||||||||||||||||||||||||
| 782 | with_name => \&_mutate_attrib, | ||||||||||||||||||||||||||||||||||||||||||||||
| 783 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 7 | my %accessor = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 786 | cookie_expires => \&_access_spacetrack_interface, | ||||||||||||||||||||||||||||||||||||||||||||||
| 787 | cookie_name => \&_access_spacetrack_interface, | ||||||||||||||||||||||||||||||||||||||||||||||
| 788 | domain_space_track => \&_access_spacetrack_interface, | ||||||||||||||||||||||||||||||||||||||||||||||
| 789 | session_cookie => \&_access_spacetrack_interface, | ||||||||||||||||||||||||||||||||||||||||||||||
| 790 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 7 | foreach my $key ( keys %mutator ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 792 | exists $accessor{$key} | ||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 56 | ▶ | or $accessor{$key} = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 56 | $_[0]->_deprecation_notice( attribute => $_[1] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 795 | 56 | return $_[0]->{$_[1]}; | |||||||||||||||||||||||||||||||||||||||||||||
| 796 | 175 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||
| 799 | # Maybe I really want a cookie_file attribute, which is used to do | ||||||||||||||||||||||||||||||||||||||||||||||
| 800 | # $self->{agent}->cookie_jar ({file => $self->{cookie_file}, autosave => 1}). | ||||||||||||||||||||||||||||||||||||||||||||||
| 801 | # We'll want to use a false attribute value to pass an empty hash. Going to | ||||||||||||||||||||||||||||||||||||||||||||||
| 802 | # this may imply modification of the new () method where the cookie_jar is | ||||||||||||||||||||||||||||||||||||||||||||||
| 803 | # defaulted and the session cookie's age is initialized. | ||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||
| 806 | =item $st = Astro::SpaceTrack->new ( ... ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||
| 808 | =for html <a name="new"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||
| 810 | This method instantiates a new Space-Track accessor object. If any | ||||||||||||||||||||||||||||||||||||||||||||||
| 811 | arguments are passed, the C<set()> method is called on the new object, | ||||||||||||||||||||||||||||||||||||||||||||||
| 812 | and passed the arguments given. | ||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||
| 814 | For both historical and operational reasons, this method can get the | ||||||||||||||||||||||||||||||||||||||||||||||
| 815 | C<username> and C<password> values from multiple locations. It uses the | ||||||||||||||||||||||||||||||||||||||||||||||
| 816 | first defined value it finds in the following list: | ||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||
| 818 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||
| 820 | =item a value explicitly specified as an argument to C<new()>; | ||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||
| 822 | =item a value from the L<IDENTITY FILE|/IDENTITY FILE>, if the | ||||||||||||||||||||||||||||||||||||||||||||||
| 823 | C<identity> attribute is explicitly specified as true and | ||||||||||||||||||||||||||||||||||||||||||||||
| 824 | L<Config::Identity|Config::Identity> is installed; | ||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||
| 826 | =item a value from environment variable C<SPACETRACK_USER> if that has a | ||||||||||||||||||||||||||||||||||||||||||||||
| 827 | non-empty value; | ||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||
| 829 | =item a value from the L<IDENTITY FILE|/IDENTITY FILE>, if the | ||||||||||||||||||||||||||||||||||||||||||||||
| 830 | C<identity> attribute defaulted to true and | ||||||||||||||||||||||||||||||||||||||||||||||
| 831 | L<Config::Identity|Config::Identity> s installed; | ||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||
| 833 | =item a value from environment variable C<SPACETRACK_OPT>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||
| 835 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||
| 837 | The reason for preferring C<SPACETRACK_USER> over an identity file value | ||||||||||||||||||||||||||||||||||||||||||||||
| 838 | taken by default is that I have found that under Mac OS X an SSH session | ||||||||||||||||||||||||||||||||||||||||||||||
| 839 | does not have access to the system keyring, and | ||||||||||||||||||||||||||||||||||||||||||||||
| 840 | L<Config::Identity|Config::Identity> provides no other way to specify | ||||||||||||||||||||||||||||||||||||||||||||||
| 841 | the passphrase used to decrypt the private key. I concluded that if the | ||||||||||||||||||||||||||||||||||||||||||||||
| 842 | user explicitly requested an identity that it should be preferred to | ||||||||||||||||||||||||||||||||||||||||||||||
| 843 | anything from the environment, but that, for SSH access to be usable, I | ||||||||||||||||||||||||||||||||||||||||||||||
| 844 | needed to provide a source of username and password that would be taken | ||||||||||||||||||||||||||||||||||||||||||||||
| 845 | before the L<IDENTITY FILE|/IDENTITY FILE> was tried by default. | ||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||
| 847 | Proxies are taken from the environment if defined. See the ENVIRONMENT | ||||||||||||||||||||||||||||||||||||||||||||||
| 848 | section of the Perl LWP documentation for more information on how to | ||||||||||||||||||||||||||||||||||||||||||||||
| 849 | set these up. | ||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||
| 851 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 7 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=28.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 7 | my ( $class, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 855 | 7 | ▶ | $class = ref $class if ref $class; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 7 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||
| 858 | banner => 1, # shell () displays banner if true. | ||||||||||||||||||||||||||||||||||||||||||||||
| 859 | dump_headers => DUMP_NONE, # No dumping. | ||||||||||||||||||||||||||||||||||||||||||||||
| 860 | fallback => 0, # Do not fall back if primary source offline | ||||||||||||||||||||||||||||||||||||||||||||||
| 861 | filter => 0, # Filter mode. | ||||||||||||||||||||||||||||||||||||||||||||||
| 862 | iridium_status_format => 'kelso', | ||||||||||||||||||||||||||||||||||||||||||||||
| 863 | max_range => 500, # Sanity limit on range size. | ||||||||||||||||||||||||||||||||||||||||||||||
| 864 | password => undef, # Login password. | ||||||||||||||||||||||||||||||||||||||||||||||
| 865 | pretty => 0, # Pretty-format content | ||||||||||||||||||||||||||||||||||||||||||||||
| 866 | prompt => 'SpaceTrack> ', | ||||||||||||||||||||||||||||||||||||||||||||||
| 867 | scheme_space_track => 'https', | ||||||||||||||||||||||||||||||||||||||||||||||
| 868 | _space_track_interface => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 869 | undef, # No such thing as version 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 870 | undef, # Interface version 1 retured. | ||||||||||||||||||||||||||||||||||||||||||||||
| 871 | { # Interface version 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 872 | # This interface does not seem to put an expiration time | ||||||||||||||||||||||||||||||||||||||||||||||
| 873 | # on the cookie. But the docs say it's only good for a | ||||||||||||||||||||||||||||||||||||||||||||||
| 874 | # couple hours, so we need this so we can fudge | ||||||||||||||||||||||||||||||||||||||||||||||
| 875 | # something in when the time comes. | ||||||||||||||||||||||||||||||||||||||||||||||
| 876 | cookie_expires => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 877 | cookie_name => 'chocolatechip', | ||||||||||||||||||||||||||||||||||||||||||||||
| 878 | domain_space_track => 'www.space-track.org', | ||||||||||||||||||||||||||||||||||||||||||||||
| 879 | session_cookie => undef, | ||||||||||||||||||||||||||||||||||||||||||||||
| 880 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 881 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 882 | space_track_version => DEFAULT_SPACE_TRACK_VERSION, | ||||||||||||||||||||||||||||||||||||||||||||||
| 883 | url_iridium_status_kelso => | ||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 'https://celestrak.org/SpaceTrack/query/iridium.txt', | ||||||||||||||||||||||||||||||||||||||||||||||
| 885 | url_iridium_status_sladen => | ||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 'http://www.rod.sladen.org.uk/iridium.htm', | ||||||||||||||||||||||||||||||||||||||||||||||
| 887 | username => undef, # Login username. | ||||||||||||||||||||||||||||||||||||||||||||||
| 888 | verbose => undef, # Verbose error messages for catalogs. | ||||||||||||||||||||||||||||||||||||||||||||||
| 889 | verify_hostname => 1, # Don't verify host names by default. | ||||||||||||||||||||||||||||||||||||||||||||||
| 890 | webcmd => undef, # Command to get web help. | ||||||||||||||||||||||||||||||||||||||||||||||
| 891 | with_name => undef, # True to retrieve three-line element sets. | ||||||||||||||||||||||||||||||||||||||||||||||
| 892 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 7 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 7 | $self->set( identity => delete $arg{identity} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||
| 897 | $ENV{SPACETRACK_OPT} and | ||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | $self->set (grep {defined $_} split '\s+', $ENV{SPACETRACK_OPT}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||
| 900 | # TODO this makes no sense - the first branch of the if() can never | ||||||||||||||||||||||||||||||||||||||||||||||
| 901 | # be executed because I already deleted $arg{identity}. But I do not | ||||||||||||||||||||||||||||||||||||||||||||||
| 902 | # want to execute the SPACETRACK_USER code willy-nilly -- maybe warn | ||||||||||||||||||||||||||||||||||||||||||||||
| 903 | # if identity is 1 and I don't have both a username and a password. | ||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 7 | ▶ | if ( defined( my $id = delete $arg{identity} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | $self->set( identity => $id ); | |||||||||||||||||||||||||||||||||||||||||||||
| 906 | } elsif ( $ENV{SPACETRACK_USER} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | my ($user, $pass) = split qr{ [:/] }smx, $ENV{SPACETRACK_USER}, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | '' ne $user | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
"" ne $user and "" ne $pass
MC/DC0%0/2
"" ne $user and "" ne $pass
"" ne $user
"" ne $pass
Truth table0%0/3
A and B
A= "" ne $userB= "" ne $pass
| |||||||||||||||||||||||||||||||||||||||||||||||
| 909 | and '' ne $pass | ||||||||||||||||||||||||||||||||||||||||||||||
| 910 | or $user = $pass = undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | $self->set (username => $user, password => $pass); | |||||||||||||||||||||||||||||||||||||||||||||
| 912 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 7 | $self->set( identity => undef ); | |||||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||
| 916 | defined $ENV{SPACETRACK_VERIFY_HOSTNAME} | ||||||||||||||||||||||||||||||||||||||||||||||
| 917 | and $self->set( verify_hostname => | ||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 7 | ▶ | $ENV{SPACETRACK_VERIFY_HOSTNAME} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 7 | ▶ | keys %arg | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 921 | and $self->set( %arg ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 7 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 924 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||
| 926 | =for html <a name="amsat"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||
| 928 | =item $resp = $st->amsat () | ||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||
| 930 | B<Note> that this method is non-functional as of September 8 2025 | ||||||||||||||||||||||||||||||||||||||||||||||
| 931 | (probably earlier), because Amsat has gone to a "humans-only" policy for | ||||||||||||||||||||||||||||||||||||||||||||||
| 932 | their web site. It will be put through the usual deprecation cycle and | ||||||||||||||||||||||||||||||||||||||||||||||
| 933 | removed. | ||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||
| 935 | This method downloads current orbital elements from the Radio Amateur | ||||||||||||||||||||||||||||||||||||||||||||||
| 936 | Satellite Corporation's web page, L<https://www.amsat.org/>. This lists | ||||||||||||||||||||||||||||||||||||||||||||||
| 937 | satellites of interest to radio amateurs, and appears to be updated | ||||||||||||||||||||||||||||||||||||||||||||||
| 938 | weekly. | ||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||
| 940 | No Space Track account is needed to access this data. As of version | ||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0.150 the setting of the 'with_name' attribute is honored. | ||||||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||||||
| 943 | You can specify options as either command-type options (e.g. | ||||||||||||||||||||||||||||||||||||||||||||||
| 944 | C<< amsat( '-file', 'foo.dat' ) >>) or as a leading hash reference (e.g. | ||||||||||||||||||||||||||||||||||||||||||||||
| 945 | C<< amsat( { file => 'foo.dat' } ) >>). If you specify the hash | ||||||||||||||||||||||||||||||||||||||||||||||
| 946 | reference, option names must be specified in full, without the leading | ||||||||||||||||||||||||||||||||||||||||||||||
| 947 | '-', and the argument list will not be parsed for command-type options. | ||||||||||||||||||||||||||||||||||||||||||||||
| 948 | If you specify command-type options, they may be abbreviated, as long as | ||||||||||||||||||||||||||||||||||||||||||||||
| 949 | the abbreviation is unique. Errors in either sort result in an exception | ||||||||||||||||||||||||||||||||||||||||||||||
| 950 | being thrown. | ||||||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||||||
| 952 | The legal options are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||
| 954 | -file | ||||||||||||||||||||||||||||||||||||||||||||||
| 955 | specifies the name of the cache file. If the data | ||||||||||||||||||||||||||||||||||||||||||||||
| 956 | on line are newer than the modification date of | ||||||||||||||||||||||||||||||||||||||||||||||
| 957 | the cache file, the cache file will be updated. | ||||||||||||||||||||||||||||||||||||||||||||||
| 958 | Otherwise the data will be returned from the file. | ||||||||||||||||||||||||||||||||||||||||||||||
| 959 | Either way the content of the file and the content | ||||||||||||||||||||||||||||||||||||||||||||||
| 960 | of the returned HTTP::Response object end up the | ||||||||||||||||||||||||||||||||||||||||||||||
| 961 | same. | ||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||
| 963 | On a successful return, the response object will contain headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||
| 965 | Pragma: spacetrack-type = orbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 966 | Pragma: spacetrack-source = amsat | ||||||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||||||
| 968 | These can be accessed by C<< $st->content_type( $resp ) >> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 969 | C<< $st->content_source( $resp ) >> respectively. | ||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||
| 971 | If the C<file> option was passed, the following additional header will | ||||||||||||||||||||||||||||||||||||||||||||||
| 972 | be provided: | ||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||
| 974 | Pragma: spacetrack-cache-hit = (either true or false) | ||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||
| 976 | This can be accessed by the C<cache_hit()> method. If this pragma is | ||||||||||||||||||||||||||||||||||||||||||||||
| 977 | true, the C<Last-Modified> header of the response will contain the | ||||||||||||||||||||||||||||||||||||||||||||||
| 978 | modification time of the file. | ||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||
| 980 | This method is a web page scraper. Any change in the location of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 981 | web page will break this method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||
| 983 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||||||
| 985 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | ▶ | sub _amsat_opts { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_amsat_opts: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 987 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | 'file=s' => 'Name of cache file', | |||||||||||||||||||||||||||||||||||||||||||||
| 989 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | ▶ | sub amsat { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
amsat: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | $self->_deprecation_notice( 'amsat' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ( my $opt, @args ) = _parse_args( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||
| 999 | return $self->_get_from_net( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | %{ $opt }, | |||||||||||||||||||||||||||||||||||||||||||||
| 1001 | # url => 'http://www.amsat.org/amsat/ftp/keps/current/nasabare.txt', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | url => 'https://www.amsat.org/tle/current/nasabare.txt', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | ▶ | post_process => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | my ( $self, $resp ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | ▶ | unless ( $self->{with_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | my @content = split qr{ \015? \012 }smx, | |||||||||||||||||||||||||||||||||||||||||||||
| 1007 | $resp->content(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | ▶ | @content % 3 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | and return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | HTTP_PRECONDITION_FAILED, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 'Response does not contain a multiple of 3 lines' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | my $ct = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | ▶ | while ( @content ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | shift @content; | |||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | $ct .= join '', map { "$_\n" } splice @content, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 1016 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | $resp->content( $ct ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | ▶ | '' eq $resp->content() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | and return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | HTTP_PRECONDITION_FAILED, NO_CAT_ID ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 1023 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | spacetrack_type => 'orbit', | |||||||||||||||||||||||||||||||||||||||||||||
| 1025 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | =for html <a name="attribute_names"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | =item @names = $st->attribute_names | ||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | This method returns a list of legal attribute names. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 1 | ▶ | sub attribute_names { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute_names: called CC=5 SCAR=24.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 1 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 1 | my @keys = grep { ! { | |||||||||||||||||||||||||||||||||||||||||||||
| 1039 | url_iridium_status_kelso => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | url_iridium_status_mccants => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | url_iridium_status_sladen => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 25 | }->{$_} } sort keys %mutator; | |||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 1 | ▶ | ref $self | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | or return wantarray ? @keys : \@keys; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | my $space_track_version = $self->getv( 'space_track_version' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1046 | my @names = grep { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | $mutator{$_} == \&_mutate_spacetrack_interface ? | |||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | ▶ | exists $self->{_space_track_interface}[$space_track_version]{$_} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | : 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | } @keys; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | ▶ | return wantarray ? @names : \@names; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | =for html <a name="banner"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | =item $resp = $st->banner (); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | This method is a convenience/nuisance: it simply returns a fake | ||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | HTTP::Response with standard banner text. It's really just for the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | benefit of the shell method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 7 | my $perl_version; | |||||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 1 | ▶ | sub banner { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
banner: called CC=4 SCAR=15.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 1 | ▶ | $perl_version ||= do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$perl_version ||= do {
$] >= "5.01" ? $^V : do {
require Config;
'v' . $Config::Config{"version"}
}
}
MC/DC0%0/2
$perl_version ||= do {
$] >= "5.01" ? $^V : do {
require Config;
'v' . $Config::Config{"version"}
}
}
$perl_version
do {
$] >= "5.01" ? $^V : do {
require Config;
'v' . $Config::Config{"version"}
}
}
Truth table33%1/3
A ||= B
A= $perl_versionB= do {
$] >= "5.01" ? $^V : do {
require Config;
'v' . $Config::Config{"version"}
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 1 | ▶ | $] >= 5.01 ? $^V : do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | require Config; | |||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | 'v' . $Config::Config{version}; ## no critic (ProhibitPackageVars) | |||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 1 | my $url = $self->_make_space_track_base_url(); | |||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 1 | return HTTP::Response->new (HTTP_OK, undef, undef, <<"EOD"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 1 | @{[__PACKAGE__]} version $VERSION | |||||||||||||||||||||||||||||||||||||||||||||
| 1080 | Perl $perl_version under $^O | ||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | This package acquires satellite orbital elements and other data from a | ||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | variety of web sites. It is your responsibility to abide by the terms of | ||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | use of the individual web sites. In particular, to acquire data from | ||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | Space Track ($url/) you must register and | ||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | get a username and password, and you may not make the data available to | ||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | a third party without prior permission from Space Track. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | Copyright 2005-2022 by T. R. Wyant (harryfmudd at comcast dot net). | ||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | under the same terms as Perl 5.10.0. For more details, see the full text | ||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | of the licenses in the files F<LICENSE-Artistic> and F<LICENSE-GPL>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | This program is distributed in the hope that it will be useful, but | ||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | without any warranty; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | merchantability or fitness for a particular purpose. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 1 | ▶ | @{[$self->{addendum} || '']} | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'addendum'} || ''
MC/DC0%0/1
$self->{'addendum'} || ''
$self->{'addendum'}
Truth table50%1/2
A
A= $self->{'addendum'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | =for html <a name="box_score"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | =item $resp = $st->box_score (); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | This method returns an HTTP::Response object. If the request succeeds, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | the content of the object will be the SATCAT Satellite Box Score | ||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | information in the desired format. If the desired format is C<'legacy'> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | or C<'json'> and the method is called in list context, the second | ||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | returned item will be a reference to an array containing the parsed | ||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | This method takes the following options, specified either command-style | ||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | or as a hash reference. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | C<-format> specifies the desired format of the retrieved data. Possible | ||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | values are C<'xml'>, C<'json'>, C<'html'>, C<'csv'>, and C<'legacy'>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | which is the default. The legacy format is tab-delimited text, such as | ||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | was returned by the version 1 interface. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | C<-json> specifies JSON format. If you specify both C<-json> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | C<-format> you will get an exception unless you specify C<-format=json>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | This method requires a Space Track username and password. It implicitly | ||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | calls the C<login()> method if the session cookie is missing or expired. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | If C<login()> fails, you will get the HTTP::Response from C<login()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | If this method succeeds, the response will contain headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | Pragma: spacetrack-type = box_score | ||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | There are no arguments. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 7 | my @fields = qw{ SPADOC_CD | |||||||||||||||||||||||||||||||||||||||||||||
| 1142 | ORBITAL_PAYLOAD_COUNT ORBITAL_ROCKET_BODY_COUNT | ||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | ORBITAL_DEBRIS_COUNT ORBITAL_TOTAL_COUNT | ||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | DECAYED_PAYLOAD_COUNT DECAYED_ROCKET_BODY_COUNT | ||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | DECAYED_DEBRIS_COUNT DECAYED_TOTAL_COUNT | ||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | COUNTRY_TOTAL | ||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 7 | my @head = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 1150 | [ '', 'Objects in Orbit', 'Decayed Objects' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | [ 'Country/Organization', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 'Payload', 'Rocket Body', 'Debris', 'Total', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 'Payload', 'Rocket Body', 'Debris', 'Total', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 'Grand Total', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 2 | ▶ | sub _box_score_opts { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_box_score_opts: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 2 | 'json!' => 'Return data in JSON format', | |||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 'format=s' => 'Specify return format', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 2 | ▶ | sub box_score { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
box_score: called CC=13 SCAR=32.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 2 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 2 | ( my $opt, @args ) = _parse_args( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 2 | my $format = _retrieval_format( box_score => $opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 2 | my $resp = $self->spacetrack_query_v2( qw{ | |||||||||||||||||||||||||||||||||||||||||||||
| 1173 | basicspacedata query class boxscore }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | format => $format, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | qw{ predicates all }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 2 | ▶ | $resp->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 1 | $self->_add_pragmata($resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 'spacetrack-type' => 'box_score', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 'spacetrack-source' => 'spacetrack', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 'spacetrack-interface' => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 1 | ▶ | 'json' eq $format | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 1 | my $data; | |||||||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 1 | ▶ | if ( ! $opt->{json} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 1 | $data = $self->_get_json_object()->decode( $resp->content() ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 1 | my $content; | |||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 1 | foreach my $row ( @head ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 2 | $content .= join( "\t", @{ $row } ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 1 | foreach my $datum ( @{ $data } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1200 | defined $datum->{SPADOC_CD} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | and $datum->{SPADOC_CD} eq 'ALL' | ||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 100 | ▶ | and $datum->{SPADOC_CD} = 'Total'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $datum->{"SPADOC_CD"} and $datum->{"SPADOC_CD"} eq "ALL"
MC/DC0%0/2
defined $datum->{"SPADOC_CD"} and $datum->{"SPADOC_CD"} eq "ALL"
defined $datum->{"SPADOC_CD"}
$datum->{"SPADOC_CD"} eq "ALL"
Truth table33%1/3
A and B
A= defined $datum->{"SPADOC_CD"}B= $datum->{"SPADOC_CD"} eq "ALL"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | $content .= join( "\t", map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 100 | ▶ | defined $datum->{$_} ? $datum->{$_} : '<undef>' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | } @fields ) . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 1 | $resp = HTTP::Response->new (HTTP_OK, undef, undef, $content); | |||||||||||||||||||||||||||||||||||||||||||||
| 1209 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | wantarray | ||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 1 | ▶ | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | my @table; | |||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | foreach my $row ( @head ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | push @table, [ @{ $row } ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 1217 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | ▶ | $data ||= $self->_get_json_object()->decode( $resp->content() ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$data ||= $self->_get_json_object->decode($resp->content)
MC/DC0%0/2
$data ||= $self->_get_json_object->decode($resp->content)
$data
$self->_get_json_object->decode($resp->content)
Truth table0%0/3
A ||= B
A= $dataB= $self->_get_json_object->decode($resp->content)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | foreach my $datum ( @{ $data } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 0 | push @table, [ map { $datum->{$_} } @fields ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 1221 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | return ( $resp, \@table ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1223 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | # Given a catalog name, return the catalog, which MUST NOT be modified. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | # UNSUPPORTED AND SUBJECT TO CHANGE OR REMOVAL WITHOUT NOTICE! | ||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | # If you have a use for this information, please let me know and I will | ||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | # see about putting together something I believe I can support. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 7 | ▶ | sub __catalog { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__catalog: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 2 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 2 | $name = lc $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 2 | my $src = $catalogs{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 2 | ▶ | $name eq 'spacetrack' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | and $src = $src->[ $self->getv( 'space_track_version' ) ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 2 | return $src; | |||||||||||||||||||||||||||||||||||||||||||||
| 1237 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | =for html <a name="celestrak"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | =item $resp = $st->celestrak ($name); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | As of version 0.158 this version is an interface to the CelesTrak API. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | The argument is the argument of a Celestrak query (see | ||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | L<https://celestrak.org/NORAD/documentation/gp-data-formats.php>). The | ||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | following options are available: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | =item format | ||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | --format json | ||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | This option specifies the format of the returned data. Valid values are | ||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | C<'TLE'>, C<'3LE'>, C<'2LE'>, C<'XML'>, C<'KVN'>, C<'JSON'>, or | ||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | C<'CSV'>. See | ||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | L<https://celestrak.org/NORAD/documentation/gp-data-formats.php> for a | ||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | discussion of these. C<'JSON-PRETTY'> is not a valid format option, but | ||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | will be generated if the C<pretty> attribute is true. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | The default is C<'TLE'>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | =item query | ||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | --query name | ||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | This option specifies the type of query to be done. Valid values are | ||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | =item CATNR | ||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | The argument is a NORAD catalog number (1-9 digits). | ||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | =item GROUP | ||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | The argument is the name of a named group of satellites. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | =item INTDES | ||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | The argument is an international launch designator of the form yyyy-nnn, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | where the C<yyyy> is the Gregorian year, and the C<nnn> is the launch | ||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | number in the year. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | =item NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | The argument is a satellite name or a portion thereof. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | =item SPECIAL | ||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | The argument specifies a special data set. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | The default is C<'CATNR'> if the argument is numeric, C<'INTDES'> if the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | argument looks like an international designator, or C<'GROUP'> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | A list of valid C<GROUP> names and brief descriptions can be obtained by | ||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | calling C<< $st->names ('celestrak') >>. If you have set the C<verbose> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | attribute true (e.g. C<< $st->set (verbose => 1) >>), the content of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | error response will include this list. Note, however, that this list | ||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | does not determine what can be retrieved; if Dr. Kelso adds a data set, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | it can be retrieved even if it is not on the list, and if he removes | ||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | one, being on the list won't help. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | If this method succeeds, the response will contain headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | Pragma: spacetrack-type = orbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | Pragma: spacetrack-source = celestrak | ||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | These can be accessed by C<< $st->content_type( $resp ) >> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | C<< $st->content_source( $resp ) >> respectively. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 0 | ▶ | sub _celestrak_opts { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_celestrak_opts: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 0 | return CELESTRAK_OPTIONS; | |||||||||||||||||||||||||||||||||||||||||||||
| 1322 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 2 | ▶ | sub celestrak { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
celestrak: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 2 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 2 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 2 | ( my $opt, @args ) = _parse_args( CELESTRAK_OPTIONS, @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 2 | my $name = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 2 | ▶ | defined $name | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | or return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | HTTP_PRECONDITION_FAILED, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 'No catalog name specified' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | # $self->_deprecation_notice( celestrak => $name ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | # $self->_deprecation_notice( celestrak => "--$_" ) foreach sort keys %{ $opt }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 2 | my $query; | |||||||||||||||||||||||||||||||||||||||||||||
| 1340 | ref( $query = $self->_celestrak_validate_query( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 2 | ▶ | delete $opt->{query}, $name, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | CELESTRAK_VALID_QUERY, 'GROUP' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | and return $query; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 2 | my $format; | |||||||||||||||||||||||||||||||||||||||||||||
| 1346 | ref( $format = $self->_celestrak_validate_format( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 2 | ▶ | delete $opt->{format} ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | and return $format; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 2 | my $uri = URI->new( 'https://celestrak.org/NORAD/elements/gp.php' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 2 | $uri->query_form( | |||||||||||||||||||||||||||||||||||||||||||||
| 1352 | $query => $name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | FORMAT => $format, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | return $self->_get_from_net( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 2 | %{ $opt }, | |||||||||||||||||||||||||||||||||||||||||||||
| 1358 | url => $uri, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 2 | ▶ | post_process => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 2 | my ( $self, $resp ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1361 | 2 | my $check; | |||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 2 | ▶ | $check = $self->_celestrak_response_check( $resp, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | celestrak => $name ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | and return $check; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 1 | ▶ | $name eq 'iridium' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | and _celestrak_repack_iridium( $resp ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 1 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 1368 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 2 | spacetrack_source => 'celestrak', | |||||||||||||||||||||||||||||||||||||||||||||
| 1370 | spacetrack_type => 'orbit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | =for html <a name="celestrak_supplemental"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | =item $resp = $st->celestrak_supplemental ($name); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | This method takes the name of a Celestrak supplemental data set and | ||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | returns an HTTP::Response object whose content is the relevant element | ||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | sets. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | These TLE data are B<not> redistributed from Space Track, but are | ||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | derived from publicly available ephemeris data for the satellites in | ||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | question. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | As of version 0.158 this version is an interface to the CelesTrak API. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | The argument is the argument of a Celestrak query (see | ||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | L<https://celestrak.org/NORAD/documentation/gp-data-formats.php>). The | ||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | following options are available: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | =item file | ||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | --file my_data.tle | ||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | This option specifies the name of an output file for the data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | =item format | ||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | --format json | ||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | This option specifies the format of the returned data. Valid values are | ||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | C<'TLE'>, C<'3LE'>, C<'2LE'>, C<'XML'>, C<'KVN'>, C<'JSON'>, or | ||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | C<'CSV'>. See | ||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | L<https://celestrak.org/NORAD/documentation/gp-data-formats.php> for a | ||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | discussion of these. C<'JSON-PRETTY'> is not a valid format option, but | ||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | will be generated if the C<pretty> attribute is true. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | The default is C<'TLE'>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | =item match | ||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | This Boolean option specifies that match data be returned rather than | ||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | TLE data, if available. This option is valid only on known catalogs that | ||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | actually have match data. If this option is asserted, C<--format> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | C<--query> are invalid. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | =item query | ||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | --query name | ||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | This option specifies the type of query to be done. Valid values are | ||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | =item CATNR | ||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | The argument is a NORAD catalog number (1-9 digits). | ||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | =item FILE | ||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | The argument is the name of a standard data set. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | =item INTDES | ||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | The argument is an international launch designator of the form yyyy-nnn, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | where the C<yyyy> is the Gregorian year, and the C<nnn> is the launch | ||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | number in the year. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | =item NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | The argument is a satellite name or a portion thereof. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | =item SOURCE | ||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | The argument specifies a data source as specified at | ||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | L<https://celestrak.org/NORAD/documentation/sup-gp-queries.php>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | =item SPECIAL | ||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | The argument specifies a special data set. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | The default is C<'CATNR'> if the argument is numeric, C<'INTDES'> if the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | argument looks like an international designator, or C<'FILE'> otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | =item rms | ||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | This Boolean option specifies that RMS data be returned rather than TLE | ||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | data, if available. This option is valid only on known catalogs that | ||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | actually have RMS data. If this option is asserted, C<--format> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | C<--query> are invalid. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | Valid catalog names are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | ast AST Space Mobile | ||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | cpf CPF (no match data) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | css CSS (no match data) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | glonass Glonass satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | gps GPS satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | intelsat Intelsat satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | iridium Iridium Next | ||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | iss ISS (from NASA, no match data) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | kuiper Project Kuiper (Amazon; no match data) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | oneweb OneWeb | ||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | planet Planet (no, not Mercury etc.) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | ses SES satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | starlink Starlink | ||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | telesat Telesat | ||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | You can specify options as either command-type options (e.g. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | C<< celestrak_supplemental( '-file', 'foo.dat' ) >>) or as a leading | ||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | hash reference (e.g. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | C<< celestrak_supplemental( { file => 'foo.dat' }) >>). If you specify | ||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | the hash reference, option names must be specified in full, without the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | leading '-', and the argument list will not be parsed for command-type | ||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | options. If you specify command-type options, they may be abbreviated, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | as long as the abbreviation is unique. Errors in either sort result in | ||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | an exception being thrown. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | A list of valid catalog names and brief descriptions can be obtained by | ||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | calling C<< $st->names( 'celestrak_supplemental' ) >>. If you have set | ||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | the C<verbose> attribute true (e.g. C<< $st->set (verbose => 1) >>), the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | content of the error response will include this list. Note, however, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | that this list does not determine what can be retrieved; if Dr. Kelso | ||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | adds a data set, it can be retrieved even if it is not on the list, and | ||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | if he removes one, being on the list won't help. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | If the C<file> option was passed, the following additional header will | ||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | be provided: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | Pragma: spacetrack-cache-hit = (either true or false) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | This can be accessed by the C<cache_hit()> method. If this pragma is | ||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | true, the C<Last-Modified> header of the response will contain the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | modification time of the file. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | B<Note> that it is my belief that the current Celestrak API (as of | ||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | September 26 2022) does not support this kind of functionality, so | ||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | C<cache_hit()> will always return false. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | For more information, see | ||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | L<https://celestrak.org/NORAD/elements/supplemental/>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 2 | ▶ | sub _celestrak_supplemental_opts { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_celestrak_supplemental_opts: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 2 | @{ CELESTRAK_API_OPTIONS() }, | |||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 'file=s' => 'Name of cache file', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 'rms!' => 'Return RMS data', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 'match!' => 'Return match data', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | 2 | ▶ | sub celestrak_supplemental { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
celestrak_supplemental: called CC=15 SCAR=28.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | 2 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 2 | ( my $opt, @args ) = _parse_args( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1534 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | $opt->{rms} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | and $opt->{match} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | 2 | ▶ | and return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opt->{"rms"} and $opt->{"match"}
MC/DC0%0/2
$opt->{"rms"} and $opt->{"match"}
$opt->{"rms"}
$opt->{"match"}
Truth table66%2/3
A and B
A= $opt->{"rms"}B= $opt->{"match"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | HTTP_PRECONDITION_FAILED, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | 'You may not assert both --rms and --match', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 2 | ▶ | if ( $opt->{rms} || $opt->{match} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opt->{"rms"} or $opt->{"match"}
MC/DC50%1/2
$opt->{"rms"} or $opt->{"match"}
$opt->{"rms"}
$opt->{"match"}
Truth table66%2/3
A or B
A= $opt->{"rms"}B= $opt->{"match"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | 1 | foreach my $key ( qw{ query format } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 2 | ▶ | defined $opt->{$key} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | and return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | HTTP_PRECONDITION_FAILED, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | "You may not assert --$key with --rms or --match", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | 2 | my $name = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 1553 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 2 | my $info = $catalogs{celestrak_supplemental}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1555 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 2 | foreach my $key ( qw{ rms match } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1557 | not $opt->{$key} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 4 | ▶ | or $info->{$key} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $opt->{$key} or $info->{$key}
MC/DC0%0/2
not $opt->{$key} or $info->{$key}
not $opt->{$key}
$info->{$key}
Truth table66%2/3
not(A) or B
A= not $opt->{$key}B= $info->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | or return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | HTTP_PRECONDITION_FAILED, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | "$name does not take the --$key option" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | 2 | my $base_url = 'https://celestrak.org/NORAD/elements/supplemental'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1565 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 2 | my ( $spacetrack_type, $uri ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 2 | ▶ | if ( $opt->{rms} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 1 | $spacetrack_type = 'rms'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1570 | 1 | $uri = URI->new( "$base_url/$name.rms.txt" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1571 | } elsif ( $opt->{match} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 0 | $spacetrack_type = 'match'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 0 | $uri = URI->new( "$base_url/$name.match.txt" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1574 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 1 | $spacetrack_type = 'orbit'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 1 | my $source = $info->{source}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 1 | ▶ | defined $source | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | or $source = $name; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | 1 | my $query; | |||||||||||||||||||||||||||||||||||||||||||||
| 1582 | ref( $query = $self->_celestrak_validate_query( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 1 | ▶ | delete $opt->{query}, $name, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | CELESTRAK_SUPPLEMENTAL_VALID_QUERY, 'FILE' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | and return $query; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 1 | my $format; | |||||||||||||||||||||||||||||||||||||||||||||
| 1588 | ref( $format = $self->_celestrak_validate_format( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 1 | ▶ | delete $opt->{format} ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | and return $format; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 1 | $uri = URI->new( "$base_url/sup-gp.php" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1593 | 1 | $uri->query_form( | |||||||||||||||||||||||||||||||||||||||||||||
| 1594 | $query => $source, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | FORMAT => $format, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | return $self->_get_from_net( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 2 | %{ $opt }, | |||||||||||||||||||||||||||||||||||||||||||||
| 1601 | url => $uri, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | 2 | ▶ | post_process => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | 2 | my ( $self, $resp ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1604 | 2 | my $check; | |||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 2 | ▶ | $check = $self->_celestrak_response_check( $resp, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | celestrak_supplemental => $name ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | and return $check; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | 2 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 1609 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | 2 | spacetrack_source => 'celestrak', | |||||||||||||||||||||||||||||||||||||||||||||
| 1611 | spacetrack_type => $spacetrack_type, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 7 | my %valid_format = map { $_ => 1 } qw{ TLE 3LE 2LE XML KVN JSON CSV }; | |||||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | 3 | ▶ | sub _celestrak_validate_format { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_celestrak_validate_format: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 3 | my ( $self, $format ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1620 | 3 | ▶ | $format = defined $format ? uc( $format ) : 'TLE'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | 3 | ▶ | $valid_format{$format} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | or return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | HTTP_PRECONDITION_FAILED, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | "Format '$format' is not valid" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 3 | ▶ | $format eq 'JSON' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$format eq "JSON" and $self->getv("pretty")
MC/DC0%0/2
$format eq "JSON" and $self->getv("pretty")
$format eq "JSON"
$self->getv("pretty")
Truth table33%1/3
A and B
A= $format eq "JSON"B= $self->getv("pretty")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | and $self->getv( 'pretty' ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | and $format = 'JSON-PRETTY'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | 3 | return $format; | |||||||||||||||||||||||||||||||||||||||||||||
| 1629 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | 7 | ▶ | sub _celestrak_validate_query { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_celestrak_validate_query: called CC=7 SCAR=21.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | 3 | my ( undef, $query, $name, $valid, $dflt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1634 | 3 | ▶ | $query = defined $query ? uc( $query ) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | $name =~ m/ \A [0-9]+ \z /smx ? 'CATNR' : | ||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | $name =~ m/ \A [0-9]{4}-[0-9]+ \z /smx ? 'INTDES' : | ||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | defined $dflt ? uc( $dflt ) : $dflt; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 3 | ▶ | defined $query | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | or return $query; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | 3 | ▶ | $valid->{$query} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | or return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | HTTP_PRECONDITION_FAILED, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | "Query '$query' is not valid" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | 3 | return $query; | |||||||||||||||||||||||||||||||||||||||||||||
| 1645 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | 0 | ▶ | sub _celestrak_repack_iridium { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_celestrak_repack_iridium: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | 0 | my ( $resp ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 0 | local $_ = $resp->content(); | |||||||||||||||||||||||||||||||||||||||||||||
| 1650 | 0 | s/ \s+ [[] . []] [ \t]* (?= \r? \n | \z ) //smxg; | |||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 0 | $resp->content( $_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1652 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 1653 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | { # Local symbol block. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 7 | my %valid_type = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||||||
| 1658 | qw{ text/plain text/text application/json application/xml }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | 4 | ▶ | sub _celestrak_response_check { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_celestrak_response_check: called CC=16 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | 4 | my ($self, $resp, $source, $name, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1662 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | # As of 2023-10-17, celestrak( 'fubar' ) gives 200 OK, with | ||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | # content | ||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | # Invalid query: "GROUP=fubar&FORMAT=TLE" (GROUP=fubar not found) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | 4 | ▶ | unless ( $resp->is_success() ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 0 | ▶ | $resp->code == HTTP_NOT_FOUND | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | and return $self->_no_such_catalog( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | $source => $name, @args); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 0 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 1672 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | 4 | my $content = $resp->decoded_content(); | |||||||||||||||||||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | 4 | ▶ | if ( $content =~ m/ \A Invalid \s+ query: /smx ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 1 | ▶ | $content =~ m/ \b (?: GROUP | FILE ) =\Q$name\E \s not \s found \b /smx | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | and return $self->_no_such_catalog( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | $source => $name, @args); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | $resp->code( HTTP_BAD_REQUEST ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1681 | 0 | $resp->message( HTTP::Status::status_message( | |||||||||||||||||||||||||||||||||||||||||||||
| 1682 | HTTP_BAD_REQUEST ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 1684 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 3 | ▶ | if (my $loc = $resp->header('Content-Location')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | ▶ | if ($loc =~ m/ redirect [.] htm [?] ( \d{3} ) ; /smx) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | 0 | my $msg = "redirected $1"; | |||||||||||||||||||||||||||||||||||||||||||||
| 1689 | 0 | ▶ | @args and $msg = "@args; $msg"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | 0 | ▶ | $1 == HTTP_NOT_FOUND | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | and return $self->_no_such_catalog( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | $source => $name, $msg); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | 0 | return HTTP::Response->new (+$1, "$msg\n") | |||||||||||||||||||||||||||||||||||||||||||||
| 1694 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | my $type = lc $resp->header('Content-Type') | ||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 3 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | 0 | my $msg = 'No Content-Type header found'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1699 | 0 | ▶ | @args and $msg = "@args; $msg"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | 0 | return $self->_no_such_catalog( | |||||||||||||||||||||||||||||||||||||||||||||
| 1701 | $source => $name, $msg); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 3 | foreach my $type ( _trim( split ',', $type ) ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1704 | 3 | $type =~ s/ ; .* //smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 3 | ▶ | $valid_type{$type} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | 3 | local $_ = $resp->decoded_content(); | |||||||||||||||||||||||||||||||||||||||||||||
| 1708 | # As of February 12 2022 Celestrak does this | ||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | # As of July 23 2022 this is not at the beginning of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | # string | ||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 3 | ▶ | m/^No GP data found\b/sm | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | and last; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | # As of July 25 2022 Celestrak does this. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | 3 | ▶ | m/^(?:GROUP|FILE) "[^"]+" does not exist/sm | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | and last; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 1717 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | 0 | my $msg = "Content-Type: $type"; | |||||||||||||||||||||||||||||||||||||||||||||
| 1719 | 0 | ▶ | @args and $msg = "@args; $msg"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | 0 | return $self->_no_such_catalog( | |||||||||||||||||||||||||||||||||||||||||||||
| 1721 | $source => $name, $msg); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | } # End local symbol block. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | =item $bool = $st->cache_hit( $resp ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | This method takes the given HTTP::Response object and returns the cache | ||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | hit indicator specified by the 'Pragma: spacetrack-cache-hit =' header. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | This will be true if the response came from cache, false if it did not, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | and C<undef> if cache was not available. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | If the response object is not provided, it returns the data type | ||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | from the last method call that returned an HTTP::Response object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 7 | ▶ | sub cache_hit { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cache_hit: not called CC=1 SCAR=2.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | 0 | $_[2] = 'spacetrack-cache-hit'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1740 | 0 | goto &_get_pragma_value; | |||||||||||||||||||||||||||||||||||||||||||||
| 1741 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | =item $source = $st->content_source($resp); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | This method takes the given HTTP::Response object and returns the data | ||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | source specified by the 'Pragma: spacetrack-source =' header. What | ||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | values you can expect depend on the content_type (see below) as follows: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | If the C<content_type()> method returns C<'box_score'>, you can expect | ||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | a content-source value of C<'spacetrack'>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | If the content_type method returns C<'iridium-status'>, you can expect | ||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | content_source values of C<'kelso'>, C<'mccants'>, or C<'sladen'>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | corresponding to the main source of the data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | If the content_type method returns C<'molczan'>, you can expect a | ||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | content_source value of C<'mccants'>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | If the C<content_type()> method returns C<'orbit'>, you can expect | ||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | content-source values of C<'amsat'>, C<'celestrak'>, C<'mccants'>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | or C<'spacetrack'>, corresponding to the actual source | ||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | of the TLE data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | If the C<content_type()> method returns C<'search'>, you can expect a | ||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | content-source value of C<'spacetrack'>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | For any other values of content-type (e.g. C<'get'>, C<'help'>), the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | expected values are undefined. In fact, you will probably literally get | ||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | undef, but the author does not commit even to this. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | If the response object is not provided, it returns the data source | ||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | from the last method call that returned an HTTP::Response object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | If the response object B<is> provided, you can call this as a static | ||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | method (i.e. as Astro::SpaceTrack->content_source($response)). | ||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | 29 | ▶ | sub content_source { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_source: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | 29 | $_[2] = 'spacetrack-source'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1781 | 29 | goto &_get_pragma_value; | |||||||||||||||||||||||||||||||||||||||||||||
| 1782 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | =item $type = $st->content_type ($resp); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | This method takes the given HTTP::Response object and returns the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | data type specified by the 'Pragma: spacetrack-type =' header. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | following values are supported: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 'box_score': The content is the Space Track satellite | ||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | box score. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 'get': The content is a parameter value. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | 'help': The content is help text. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | 'iridium_status': The content is Iridium status. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | 'modeldef': The content is a REST model definition. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | 'molczan': Molczan-format magnitude data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | 'orbit': The content is NORAD data sets. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | 'search': The content is Space Track search results. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | 'set': The content is the result of a 'set' operation. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | undef: No spacetrack-type pragma was specified. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | content is something else (typically 'OK'). | ||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | If the response object is not provided, it returns the data type | ||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | from the last method call that returned an HTTP::Response object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | If the response object B<is> provided, you can call this as a static | ||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | method (i.e. as Astro::SpaceTrack->content_type($response)). | ||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | For the format of the magnitude data, see | ||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | L<https://www.mmccants.org//tles/index.html>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | 30 | ▶ | sub content_type { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | 30 | $_[2] = 'spacetrack-type'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1816 | 30 | goto &_get_pragma_value; | |||||||||||||||||||||||||||||||||||||||||||||
| 1817 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | =item $type = $st->content_interface( $resp ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | This method takes the given HTTP::Response object and returns the Space | ||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | Track interface version specified by the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | C<'Pragma: spacetrack-interface ='> header. The following values are | ||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | supported: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | 1: The content was obtained using the version 1 interface. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 2: The content was obtained using the version 2 interface. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | undef: The content did not come from Space Track. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | If the response object is not provided, it returns the data type | ||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | from the last method call that returned an HTTP::Response object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | If the response object B<is> provided, you can call this as a static | ||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | method (i.e. as Astro::SpaceTrack->content_type($response)). | ||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | 22 | ▶ | sub content_interface { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_interface: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | 22 | $_[2] = 'spacetrack-interface'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1840 | 22 | goto &_get_pragma_value; | |||||||||||||||||||||||||||||||||||||||||||||
| 1841 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | 81 | ▶ | sub _get_pragma_value { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_pragma_value: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | 81 | my ( $self, $resp, $pragma ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1845 | defined $resp | ||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | 81 | ▶ | or return $self->{_pragmata}{$pragma}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | 5 | ( my $re = $pragma ) =~ s/ _ /-/smxg; | |||||||||||||||||||||||||||||||||||||||||||||
| 1848 | 5 | $re = qr{ \Q$re\E }smxi; | |||||||||||||||||||||||||||||||||||||||||||||
| 1849 | 5 | foreach ( $resp->header( 'Pragma' ) ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1850 | 3 | ▶ | m/ $re \s+ = \s+ (.+) /smxi and return $1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | # Sorry, PBP -- to be compatible with the performance of this method | ||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | # when $resp is defined, we must return an explicit undef here. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | 3 | return undef; ## no critic (ProhibitExplicitReturnUndef) | |||||||||||||||||||||||||||||||||||||||||||||
| 1855 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | =for html <a name="country_names"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | =item $resp = $st->country_names() | ||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | This method returns an HTTP::Response object. If the request succeeds, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | the content of the object will be the known country names and their | ||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | abbreviations in the desired format. If the desired format is | ||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | C<'legacy'> or C<'json'> and the method is called in list context, the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | second returned item will be a reference to an array containing the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | parsed data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | This method takes the following options, specified either command-style | ||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | or as a hash reference. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | C<-format> specifies the desired format of the retrieved data. Possible | ||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | values are C<'xml'>, C<'json'>, C<'html'>, C<'csv'>, and C<'legacy'>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | which is the default. The legacy format is tab-delimited text, such as | ||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | was returned by the version 1 interface. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | C<-json> specifies JSON format. If you specify both C<-json> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | C<-format> you will get an exception unless you specify C<-format=json>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | This method requires a Space Track username and password. It | ||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | implicitly calls the C<login()> method if the session cookie is | ||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | missing or expired. If C<login()> fails, you will get the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | HTTP::Response from C<login()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | If this method succeeds, the response will contain headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | Pragma: spacetrack-type = country_names | ||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | There are no arguments. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | 1 | ▶ | sub country_names { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
country_names: called CC=6 SCAR=18.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1896 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | 1 | ( my $opt, @args ) = _parse_args( | |||||||||||||||||||||||||||||||||||||||||||||
| 1898 | [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | 'json!' => 'Return data in JSON format', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | 'format=s' => 'Specify return format', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | ], @args ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | 1 | my $format = _retrieval_format( country_names => $opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1903 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | 1 | my $resp = $self->spacetrack_query_v2( | |||||||||||||||||||||||||||||||||||||||||||||
| 1905 | basicspacedata => 'query', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | class => 'boxscore', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | format => $format, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | predicates => 'COUNTRY,SPADOC_CD', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | 1 | ▶ | $resp->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | 1 | $self->_add_pragmata( $resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 1914 | 'spacetrack-type' => 'country_names', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | 'spacetrack-source' => 'spacetrack', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | 'spacetrack-interface' => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | 1 | ▶ | 'json' eq $format | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | 1 | my $json = $self->_get_json_object(); | |||||||||||||||||||||||||||||||||||||||||||||
| 1923 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | 1 | my $data = $json->decode( $resp->content() ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | 1 | my %dict; | |||||||||||||||||||||||||||||||||||||||||||||
| 1927 | 1 | foreach my $datum ( @{ $data } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1928 | defined $datum->{SPADOC_CD} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | 100 | ▶ | and $dict{$datum->{SPADOC_CD}} = $datum->{COUNTRY}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | 1 | ▶ | if ( $opt->{json} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | 0 | $resp->content( $json->encode( \%dict ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1935 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | $resp->content( | ||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | join '', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | join( "\t", 'Abbreviation', 'Country/Organization' ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | . "\n", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | 0 | map { "$_\t$dict{$_}\n" } sort keys %dict | |||||||||||||||||||||||||||||||||||||||||||||
| 1943 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | 1 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 1948 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | =for html <a name="favorite"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | =item $resp = $st->favorite( $name ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | This method returns an HTTP::Response object. If the request succeeds, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | the content of the response will be TLE data specified by the named | ||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | favorite in the desired format. The named favorite must have previously | ||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | been set up by the user, or be one of the 'global' favorites (e.g. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | C<'Navigation'>, C<'Weather'>, and so on). | ||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | This method takes the following options, specified either command-style | ||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | or as a hash reference. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | C<-format> specifies the desired format of the retrieved data. Possible | ||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | values are C<'xml'>, C<'json'>, C<'html'>, C<'csv'>, and C<'legacy'>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | which is the default. The legacy format is tab-delimited text, such as | ||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | was returned by the version 1 interface. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | C<-json> specifies JSON format. If you specify both C<-json> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | C<-format> you will get an exception unless you specify C<-format=json>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | This method requires a Space Track username and password. It | ||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | implicitly calls the C<login()> method if the session cookie is | ||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | missing or expired. If C<login()> fails, you will get the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | HTTP::Response from C<login()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | 1 | ▶ | sub _favorite_opts { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_favorite_opts: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | 1 | 'json!' => 'Return data in JSON format', | |||||||||||||||||||||||||||||||||||||||||||||
| 1983 | 'format=s' => 'Specify return format', | ||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | 1 | ▶ | sub favorite { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
favorite: called CC=6 SCAR=20.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | 1 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1989 | 1 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1990 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | 1 | ( my $opt, @args ) = _parse_args( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1992 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | @args | ||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | 1 | ▶ | and defined $args[0] | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@args and defined $args[0]
MC/DC0%0/2
@args and defined $args[0]
@args
defined $args[0]
Truth table33%1/3
A and B
A= @argsB= defined $args[0]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | or Carp::croak 'Must specify a favorite'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | 1 | ▶ | @args > 1 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | and Carp::croak 'Can not specify more than one favorite'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | # https://beta.space-track.org/basicspacedata/query/class/tle_latest/favorites/Visible/ORDINAL/1/EPOCH/%3Enow-30/format/3le | ||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | 1 | my $rest = $self->_convert_retrieve_options_to_rest( $opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2001 | 1 | $rest->{favorites} = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 2002 | 1 | $rest->{EPOCH} = '>now-30'; | |||||||||||||||||||||||||||||||||||||||||||||
| 2003 | 1 | delete $rest->{orderby}; | |||||||||||||||||||||||||||||||||||||||||||||
| 2004 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | 1 | my $resp = $self->spacetrack_query_v2( | |||||||||||||||||||||||||||||||||||||||||||||
| 2006 | basicspacedata => 'query', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | _sort_rest_arguments( $rest ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | 1 | ▶ | $resp->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | 0 | ▶ | _spacetrack_v2_response_is_empty( $resp ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | and return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | HTTP_NOT_FOUND, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | "Favorite '$args[0]' not found" | ||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | 0 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 2020 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | =for html <a name="file"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | =item $resp = $st->file ($name) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | This method takes the name of an observing list file, or a handle to an | ||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | open observing list file, and returns an HTTP::Response object whose | ||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | content is the relevant element sets, retrieved from the Space Track web | ||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | site. If called in list context, the first element of the list is the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | aforementioned HTTP::Response object, and the second element is a list | ||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | reference to list references (i.e. a list of lists). Each of the list | ||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | references contains the catalog ID of a satellite or other orbiting body | ||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | and the common name of the body. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | This method requires a Space Track username and password. It implicitly | ||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | calls the C<login()> method if the session cookie is missing or expired. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | If C<login()> fails, you will get the HTTP::Response from C<login()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | The observing list file is (how convenient!) in the Celestrak format, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | with the first five characters of each line containing the object ID, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | and the rest containing a name of the object. Lines whose first five | ||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | characters do not look like a right-justified number will be ignored. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | If this method succeeds, the response will contain headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | Pragma: spacetrack-type = orbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | These can be accessed by C<< $st->content_type( $resp ) >> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | C<< $st->content_source( $resp ) >> respectively. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | You can specify the C<retrieve()> options on this method as well. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | 0 | ▶ | sub _file_opts { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_file_opts: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | 0 | return [ _get_retrieve_options() ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 2060 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | 1 | ▶ | sub file { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | 1 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 2064 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | 1 | my ( $opt, $file ) = $self->_parse_retrieve_args( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2066 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | 1 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 2068 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | 1 | ▶ | if ( ! Scalar::Util::openhandle( $file ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | 1 | ▶ | -e $file or return HTTP::Response->new ( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | HTTP_NOT_FOUND, "Can't find file $file"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | 1 | ▶ | my $fh = IO::File->new($file, '<') or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | return HTTP::Response->new ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | HTTP_INTERNAL_SERVER_ERROR, "Can't open $file: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | 1 | $file = $fh; | |||||||||||||||||||||||||||||||||||||||||||||
| 2076 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | 1 | local $/ = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 2079 | 1 | return $self->_handle_observing_list( $opt, <$file> ) | |||||||||||||||||||||||||||||||||||||||||||||
| 2080 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | =for html <a name="get"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | =item $resp = $st->get (attrib) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | B<This method returns an HTTP::Response object> whose content is the value | ||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | of the given attribute. If called in list context, the second element | ||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | of the list is just the value of the attribute, for those who don't want | ||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | to winkle it out of the response object. We croak on a bad attribute name. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | If this method succeeds, the response will contain header | ||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | Pragma: spacetrack-type = get | ||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | This can be accessed by C<< $st->content_type( $resp ) >>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | See L</Attributes> for the names and functions of the attributes. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | 0 | ▶ | sub _readline_complete_command_get { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readline_complete_command_get: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | # my ( $self, $text, $line, $start, $cmd_line ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | 0 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 2106 | 0 | ▶ | $text eq '' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | and return( $self->attribute_names() ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | 0 | my $re = qr/ \A \Q$text\E /smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 2109 | 0 | return( sort grep { $_ =~ $re } $self->attribute_names() ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2110 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | 1 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | 1 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 2114 | 1 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 2115 | 1 | ▶ | my $code = $self->can( "_get_attr_$name" ) || $self->can( 'getv' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->can("_get_attr_$name") || $self->can('getv')
MC/DC0%0/2
$self->can("_get_attr_$name") || $self->can('getv')
$self->can("_get_attr_$name")
$self->can('getv')
Truth table33%1/3
A || B
A= $self->can("_get_attr_$name")B= $self->can('getv')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | 1 | my $value = $code->( $self, $name ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2117 | 1 | my $resp = HTTP::Response->new( HTTP_OK, COPACETIC, undef, $value ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2118 | 1 | $self->_add_pragmata( $resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 2119 | 'spacetrack-type' => 'get', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | 1 | $self->__dump_response( $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2122 | 1 | ▶ | return wantarray ? ($resp, $value ) : $resp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | 0 | ▶ | sub _get_attr_dump_headers { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_attr_dump_headers: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | 0 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 2128 | 0 | my $value = $self->getv( $name ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2129 | 0 | my @opts = ( $value, '#' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2130 | 0 | ▶ | if ( $value ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | 0 | foreach my $key ( @dump_options ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 2132 | 0 | my $const = "DUMP_\U$key"; | |||||||||||||||||||||||||||||||||||||||||||||
| 2133 | 0 | my $mask = __PACKAGE__->$const(); | |||||||||||||||||||||||||||||||||||||||||||||
| 2134 | 0 | ▶ | $value & $mask | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | and push @opts, "--$key"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | 0 | push @opts, '--none'; | |||||||||||||||||||||||||||||||||||||||||||||
| 2139 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | 0 | return "@opts"; | |||||||||||||||||||||||||||||||||||||||||||||
| 2141 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | =for html <a name="getv"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | =item $value = $st->getv (attrib) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | This method returns the value of the given attribute, which is what | ||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | C<get()> should have done. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | See L</Attributes> for the names and functions of the attributes. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | 56 | ▶ | sub getv { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getv: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | 56 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 2157 | 56 | ▶ | defined $name | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | or Carp::croak 'No attribute name specified'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | 56 | ▶ | my $code = $accessor{$name} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | or Carp::croak "No such attribute as '$name'"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | 56 | return $code->( $self, $name ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2162 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | =for html <a name="help"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | =item $resp = $st->help () | ||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | This method exists for the convenience of the shell () method. It | ||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | always returns success, with the content being whatever it's | ||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | convenient (to the author) to include. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | If the C<webcmd> attribute is set, the L<https://metacpan.org/> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | web page for Astro::Satpass is launched. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | If this method succeeds B<and> the webcmd attribute is not set, the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | response will contain header | ||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | Pragma: spacetrack-type = help | ||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | This can be accessed by C<< $st->content_type( $resp ) >>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | Otherwise (i.e. in any case where the response does B<not> contain | ||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | actual help text) this header will be absent. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | 1 | ▶ | sub help { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
help: called CC=3 SCAR=15.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 2190 | 1 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 2191 | 1 | ▶ | if ($self->{webcmd}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | 0 | my $cmd = $self->{webcmd}; | |||||||||||||||||||||||||||||||||||||||||||||
| 2193 | 0 | ▶ | if ( '1' eq $cmd ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | 0 | require Browser::Open; | |||||||||||||||||||||||||||||||||||||||||||||
| 2195 | 0 | $cmd = Browser::Open::open_browser_cmd(); | |||||||||||||||||||||||||||||||||||||||||||||
| 2196 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | # TODO just use open_browser() once webcmd becomes Boolean. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | 0 | system { $cmd } $cmd, | |||||||||||||||||||||||||||||||||||||||||||||
| 2199 | 'https://metacpan.org/release/Astro-SpaceTrack'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | 0 | return HTTP::Response->new (HTTP_OK, undef, undef, 'OK'); | |||||||||||||||||||||||||||||||||||||||||||||
| 2201 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | 1 | my $resp = HTTP::Response->new (HTTP_OK, undef, undef, <<'EOD'); | |||||||||||||||||||||||||||||||||||||||||||||
| 2203 | The following commands are defined: | ||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | box_score | ||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | Retrieve the SATCAT box score. A Space Track login is needed. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | celestrak name | ||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | Retrieves the named catalog of IDs from Celestrak. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | exit (or bye) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | Terminate the shell. End-of-file also works. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | file filename | ||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | Retrieve the catalog IDs given in the named file (one per | ||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | line, with the first five characters being the ID). | ||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | get | ||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | Get the value of a single attribute. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | help | ||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | Display this help text. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | iridium_status | ||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | Status of Iridium satellites, from Rod Sladen and/or T. S. Kelso. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | login | ||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | Acquire a session cookie. You must have already set the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | username and password attributes. This will be called | ||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | implicitly if needed by any method that accesses data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | names source | ||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | Lists the catalog names from the given source. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | retrieve number ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | Retieves the latest orbital elements for the given | ||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | catalog numbers. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | search_date date ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | Retrieves orbital elements by launch date. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | search_decay date ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | Retrieves orbital elements by decay date. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | search_id id ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | Retrieves orbital elements by international designator. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | search_name name ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | Retrieves orbital elements by satellite common name. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | set attribute value ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | Sets the given attributes. Legal attributes are | ||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | addendum = extra text for the shell () banner; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | banner = false to supress the shell () banner; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | cookie_expires = Perl date the session cookie expires; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | filter = true supresses all output to stdout except | ||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | orbital elements; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | identity = load username and password from identity file | ||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | if true and Config::Identity can be loaded; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | max_range = largest range of numbers that can be re- | ||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | trieved (default: 500); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | password = the Space-Track password; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | session_cookie = the text of the session cookie; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | username = the Space-Track username; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | verbose = true for verbose catalog error messages; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | webcmd = command to launch a URL (for web-based help); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | with_name = true to retrieve common names as well. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2253 | The session_cookie and cookie_expires attributes should | ||||||||||||||||||||||||||||||||||||||||||||||
| 2254 | only be set to previously-retrieved, matching values. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2255 | source filename | ||||||||||||||||||||||||||||||||||||||||||||||
| 2256 | Executes the contents of the given file as shell commands. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2257 | spacetrack name | ||||||||||||||||||||||||||||||||||||||||||||||
| 2258 | Retrieves the named catalog of orbital elements from | ||||||||||||||||||||||||||||||||||||||||||||||
| 2259 | Space Track. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2260 | The shell supports a pseudo-redirection of standard output, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2261 | using the usual Unix shell syntax (i.e. '>output_file'). | ||||||||||||||||||||||||||||||||||||||||||||||
| 2262 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 2263 | 1 | $self->_add_pragmata($resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 2264 | 'spacetrack-type' => 'help', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2265 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2266 | 1 | $self->__dump_response( $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2267 | 1 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 2268 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2269 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2270 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2271 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2272 | =for html <a name="iridium_status"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2273 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2274 | =item $resp = $st->iridium_status ($format); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2276 | This method queries its sources of Iridium status, returning an | ||||||||||||||||||||||||||||||||||||||||||||||
| 2277 | HTTP::Response object containing the relevant data (if all queries | ||||||||||||||||||||||||||||||||||||||||||||||
| 2278 | succeeded) or the status of the first failure. If the queries succeed, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2279 | the content is a series of lines formatted by "%6d %-15s%-8s %s\n", | ||||||||||||||||||||||||||||||||||||||||||||||
| 2280 | with NORAD ID, name, status, and comment substituted in. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2281 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2282 | If no format is specified, the format specified in the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2283 | C<iridium_status_format> attribute is used. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2284 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2285 | There is one option, C<'raw'>, which can be specified either | ||||||||||||||||||||||||||||||||||||||||||||||
| 2286 | command-line style (i.e. C<-raw>) or as a leading hash reference. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2287 | Asserting this option causes status information from sources other than | ||||||||||||||||||||||||||||||||||||||||||||||
| 2288 | Celestrak and Rod Sladen not to be supplemented by Celestrak data. In | ||||||||||||||||||||||||||||||||||||||||||||||
| 2289 | addition, it prevents all sources from being supplemented by canned data | ||||||||||||||||||||||||||||||||||||||||||||||
| 2290 | that includes all original-design Iridium satellites, including those | ||||||||||||||||||||||||||||||||||||||||||||||
| 2291 | that have decayed. By default this option is not asserted. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2293 | Format C<'mccants'> is B<deprecated>, and throws an exception as of | ||||||||||||||||||||||||||||||||||||||||||||||
| 2294 | version 0.137. This entire method will be deprecated and removed once | ||||||||||||||||||||||||||||||||||||||||||||||
| 2295 | the last flaring Iridium satellite is removed from service. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2296 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2297 | A Space Track username and password are required only if the format is | ||||||||||||||||||||||||||||||||||||||||||||||
| 2298 | C<'spacetrack'>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2299 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2300 | If this method succeeds, the response will contain headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 2301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2302 | Pragma: spacetrack-type = iridium_status | ||||||||||||||||||||||||||||||||||||||||||||||
| 2303 | Pragma: spacetrack-source = | ||||||||||||||||||||||||||||||||||||||||||||||
| 2304 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2305 | The spacetrack-source will be C<'kelso'>, C<'sladen'>, or | ||||||||||||||||||||||||||||||||||||||||||||||
| 2306 | C<'spacetrack'>, depending on the format requested. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2307 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2308 | These can be accessed by C<< $st->content_type( $resp ) >> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 2309 | C<< $st->content_source( $resp ) >> respectively. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2311 | The source of the data and, to a certain extent, the format of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2312 | results is determined by the optional $format argument, which defaults | ||||||||||||||||||||||||||||||||||||||||||||||
| 2313 | to the value of the C<iridium_status_format> attribute. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2314 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2315 | If the format is 'kelso', only Dr. Kelso's Celestrak web site | ||||||||||||||||||||||||||||||||||||||||||||||
| 2316 | (C<https://celestrak.org/SpaceTrack/query/iridium.txt>) is queried for | ||||||||||||||||||||||||||||||||||||||||||||||
| 2317 | the data. The possible status values are documented at | ||||||||||||||||||||||||||||||||||||||||||||||
| 2318 | L<https://celestrak.org/satcat/status.php>, and repeated here for | ||||||||||||||||||||||||||||||||||||||||||||||
| 2319 | convenience: | ||||||||||||||||||||||||||||||||||||||||||||||
| 2320 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2321 | '[+]' - Operational | ||||||||||||||||||||||||||||||||||||||||||||||
| 2322 | '[-]' - Nonoperational | ||||||||||||||||||||||||||||||||||||||||||||||
| 2323 | '[P]' - Partially Operational | ||||||||||||||||||||||||||||||||||||||||||||||
| 2324 | '[B]' - Backup/Standby | ||||||||||||||||||||||||||||||||||||||||||||||
| 2325 | '[S]' - Spare | ||||||||||||||||||||||||||||||||||||||||||||||
| 2326 | '[X]' - Extended Mission | ||||||||||||||||||||||||||||||||||||||||||||||
| 2327 | '[D]' - Decayed | ||||||||||||||||||||||||||||||||||||||||||||||
| 2328 | '[?]' - Unknown | ||||||||||||||||||||||||||||||||||||||||||||||
| 2329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2330 | The comment will be 'Spare', 'Tumbling', or '' depending on the status. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2331 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2332 | In addition, the data from Celestrak may contain the following | ||||||||||||||||||||||||||||||||||||||||||||||
| 2333 | status: | ||||||||||||||||||||||||||||||||||||||||||||||
| 2334 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2335 | 'dum' - Dummy mass | ||||||||||||||||||||||||||||||||||||||||||||||
| 2336 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2337 | A blank status indicates that the satellite is in service and | ||||||||||||||||||||||||||||||||||||||||||||||
| 2338 | therefore capable of producing flares. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2339 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2340 | If the format is 'sladen', the primary source of information will be Rod | ||||||||||||||||||||||||||||||||||||||||||||||
| 2341 | Sladen's "Iridium Constellation Status" web page, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2342 | L<http://www.rod.sladen.org.uk/iridium.htm>, which gives status on all | ||||||||||||||||||||||||||||||||||||||||||||||
| 2343 | Iridium satellites, but no OID. The Celestrak list will be used to | ||||||||||||||||||||||||||||||||||||||||||||||
| 2344 | provide OIDs for Iridium satellite numbers, so that a complete list is | ||||||||||||||||||||||||||||||||||||||||||||||
| 2345 | generated. Mr. Sladen's page simply lists operational and failed | ||||||||||||||||||||||||||||||||||||||||||||||
| 2346 | satellites in each plane, so this software imposes Kelso-style statuses | ||||||||||||||||||||||||||||||||||||||||||||||
| 2347 | on the data. That is to say, operational satellites will be marked | ||||||||||||||||||||||||||||||||||||||||||||||
| 2348 | '[+]', spares will be marked '[S]', and failed satellites will be | ||||||||||||||||||||||||||||||||||||||||||||||
| 2349 | marked '[-]', with the corresponding portable statuses. As of version | ||||||||||||||||||||||||||||||||||||||||||||||
| 2350 | 0.035, all failed satellites will be marked '[-]'. Previous to this | ||||||||||||||||||||||||||||||||||||||||||||||
| 2351 | release, failed satellites not specifically marked as tumbling were | ||||||||||||||||||||||||||||||||||||||||||||||
| 2352 | considered spares. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2354 | The comment field in 'sladen' format data will contain the orbital plane | ||||||||||||||||||||||||||||||||||||||||||||||
| 2355 | designation for the satellite, 'Plane n' with 'n' being a number from 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2356 | to 6. If the satellite is failed but not tumbling, the text ' - Failed | ||||||||||||||||||||||||||||||||||||||||||||||
| 2357 | on station?' will be appended to the comment. The dummy masses will be | ||||||||||||||||||||||||||||||||||||||||||||||
| 2358 | included from the Kelso data, with status '[-]' but comment 'Dummy'. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2359 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2360 | If the format is 'spacetrack', the data come from both Celestrak and | ||||||||||||||||||||||||||||||||||||||||||||||
| 2361 | Space Track. For any given OID, we take the Space Track data if it shows | ||||||||||||||||||||||||||||||||||||||||||||||
| 2362 | the OID as being decayed, or if the OID does not appear in the Celestrak | ||||||||||||||||||||||||||||||||||||||||||||||
| 2363 | data; otherwise we take the Celestrak data. The idea here is to get a | ||||||||||||||||||||||||||||||||||||||||||||||
| 2364 | list of statuses that include decayed satellites dropped from the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2365 | Celestrak list. You will need a Space Track username and password for | ||||||||||||||||||||||||||||||||||||||||||||||
| 2366 | this. The format of the returned data is the same as for Celestrak data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2367 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2368 | If the method is called in list context, the first element of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2369 | returned list will be the HTTP::Response object, and the second | ||||||||||||||||||||||||||||||||||||||||||||||
| 2370 | element will be a reference to a list of anonymous lists, each | ||||||||||||||||||||||||||||||||||||||||||||||
| 2371 | containing [$id, $name, $status, $comment, $portable_status] for | ||||||||||||||||||||||||||||||||||||||||||||||
| 2372 | an Iridium satellite. The portable statuses are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 2373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2374 | 0 = BODY_STATUS_IS_OPERATIONAL means object is operational, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2375 | and capable of producing predictable flares; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2376 | 1 = BODY_STATUS_IS_SPARE means object is a spare or | ||||||||||||||||||||||||||||||||||||||||||||||
| 2377 | otherwise not in regular service, but is controlled | ||||||||||||||||||||||||||||||||||||||||||||||
| 2378 | and may be capable of producing predictable flares; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2379 | 2 = BODY_STATUS_IS_TUMBLING means object is tumbling | ||||||||||||||||||||||||||||||||||||||||||||||
| 2380 | or otherwise unservicable, and incapable of producing | ||||||||||||||||||||||||||||||||||||||||||||||
| 2381 | predictable flares | ||||||||||||||||||||||||||||||||||||||||||||||
| 2382 | 3 - BODY_STATUS_IS_DECAYED neans that the object is decayed. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2383 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2384 | In terms of the Kelso statuses, the mapping is: | ||||||||||||||||||||||||||||||||||||||||||||||
| 2385 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2386 | '[+]' - BODY_STATUS_IS_OPERATIONAL | ||||||||||||||||||||||||||||||||||||||||||||||
| 2387 | '[-]' - BODY_STATUS_IS_TUMBLING | ||||||||||||||||||||||||||||||||||||||||||||||
| 2388 | '[P]' - BODY_STATUS_IS_SPARE | ||||||||||||||||||||||||||||||||||||||||||||||
| 2389 | '[B]' - BODY_STATUS_IS_SPARE | ||||||||||||||||||||||||||||||||||||||||||||||
| 2390 | '[S]' - BODY_STATUS_IS_SPARE | ||||||||||||||||||||||||||||||||||||||||||||||
| 2391 | '[X]' - BODY_STATUS_IS_SPARE | ||||||||||||||||||||||||||||||||||||||||||||||
| 2392 | '[D]' - BODY_STATUS_IS_DECAYED | ||||||||||||||||||||||||||||||||||||||||||||||
| 2393 | '[?]' - BODY_STATUS_IS_TUMBLING | ||||||||||||||||||||||||||||||||||||||||||||||
| 2394 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2395 | The BODY_STATUS constants are exportable using the :status tag. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2396 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2397 | This method and the associated manifest constants are B<deprecated>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2398 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2399 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 2400 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2401 | { # Begin local symbol block. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2402 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2403 | # NOTE the indirection here is so that, at the next deprecation | ||||||||||||||||||||||||||||||||||||||||||||||
| 2404 | # step, the exported stuff can become a normal subroutine that | ||||||||||||||||||||||||||||||||||||||||||||||
| 2405 | # triggers a deprecation warning, but the internal stuff can still | ||||||||||||||||||||||||||||||||||||||||||||||
| 2406 | # be in-lined and trigger no warning. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2407 | 7 | ▶ | use constant _BODY_STATUS_IS_OPERATIONAL => 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2408 | 7 | ▶ | use constant _BODY_STATUS_IS_SPARE => 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2409 | 7 | ▶ | use constant _BODY_STATUS_IS_TUMBLING => 2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2410 | 7 | ▶ | use constant _BODY_STATUS_IS_DECAYED => 3; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2411 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2412 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2413 | 7 | foreach ( qw{ | |||||||||||||||||||||||||||||||||||||||||||||
| 2414 | BODY_STATUS_IS_OPERATIONAL | ||||||||||||||||||||||||||||||||||||||||||||||
| 2415 | BODY_STATUS_IS_SPARE | ||||||||||||||||||||||||||||||||||||||||||||||
| 2416 | BODY_STATUS_IS_TUMBLING | ||||||||||||||||||||||||||||||||||||||||||||||
| 2417 | BODY_STATUS_IS_DECAYED | ||||||||||||||||||||||||||||||||||||||||||||||
| 2418 | } ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2419 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2420 | 0 | ▶ | eval "sub $_ () { _deprecation_notice(); return _$_ }"; ## no critic (ProhibitStringyEval,RequireCheckingReturnValueOfEval) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BODY_STATUS_IS_DECAYED: not called CC=1 SCAR=5.3
Subroutine
BODY_STATUS_IS_OPERATIONAL: not called CC=1 SCAR=5.3
Subroutine
BODY_STATUS_IS_SPARE: not called CC=1 SCAR=5.3
Subroutine
BODY_STATUS_IS_TUMBLING: not called CC=1 SCAR=5.3
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2421 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2422 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2423 | 7 | my %kelso_comment = ( # Expand Kelso status. | |||||||||||||||||||||||||||||||||||||||||||||
| 2424 | '[S]' => 'Spare', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2425 | '[-]' => 'Tumbling', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2426 | '[D]' => 'Decayed', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2427 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2428 | 7 | my %status_portable = ( # Map statuses to portable. | |||||||||||||||||||||||||||||||||||||||||||||
| 2429 | kelso => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2430 | '' => _BODY_STATUS_IS_OPERATIONAL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2431 | '[+]' => _BODY_STATUS_IS_OPERATIONAL, # Operational | ||||||||||||||||||||||||||||||||||||||||||||||
| 2432 | '[-]' => _BODY_STATUS_IS_TUMBLING, # Nonoperational | ||||||||||||||||||||||||||||||||||||||||||||||
| 2433 | '[P]' => _BODY_STATUS_IS_SPARE, # Partially Operational | ||||||||||||||||||||||||||||||||||||||||||||||
| 2434 | '[B]' => _BODY_STATUS_IS_SPARE, # Backup/Standby | ||||||||||||||||||||||||||||||||||||||||||||||
| 2435 | '[S]' => _BODY_STATUS_IS_SPARE, # Spare | ||||||||||||||||||||||||||||||||||||||||||||||
| 2436 | '[X]' => _BODY_STATUS_IS_SPARE, # Extended Mission | ||||||||||||||||||||||||||||||||||||||||||||||
| 2437 | '[D]' => _BODY_STATUS_IS_DECAYED, # Decayed | ||||||||||||||||||||||||||||||||||||||||||||||
| 2438 | '[?]' => _BODY_STATUS_IS_TUMBLING, # Unknown | ||||||||||||||||||||||||||||||||||||||||||||||
| 2439 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2440 | # sladen => undef, # Not needed; done programmatically. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2441 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2442 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2443 | $status_portable{kelso_inverse} = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2444 | 7 | map { $status_portable{kelso}{$_} => $_ } qw{ [-] [S] [+] } }; | |||||||||||||||||||||||||||||||||||||||||||||
| 2445 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2446 | # All Iridium Classic satellites. The order of the data is: | ||||||||||||||||||||||||||||||||||||||||||||||
| 2447 | # OID, name, status string, comment, portable status. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2448 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 2449 | # Generated by tools/all_iridium_classic -indent=4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2450 | # on Sun May 31 12:27:10 2020 GMT | ||||||||||||||||||||||||||||||||||||||||||||||
| 2451 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2452 | 7 | my @all_iridium_classic = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 2453 | [ 24792, 'Iridium 8', '[D]', 'Decayed 2017-11-24', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2454 | [ 24793, 'Iridium 7', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2455 | [ 24794, 'Iridium 6', '[D]', 'Decayed 2017-12-23', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2456 | [ 24795, 'Iridium 5', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2457 | [ 24796, 'Iridium 4', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2458 | [ 24836, 'Iridium 914', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2459 | [ 24837, 'Iridium 12', '[D]', 'Decayed 2018-09-02', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2460 | [ 24838, 'Iridium 9', '[D]', 'Decayed 2003-03-11', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2461 | [ 24839, 'Iridium 10', '[D]', 'Decayed 2018-10-06', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2462 | [ 24840, 'Iridium 13', '[D]', 'Decayed 2018-04-29', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2463 | [ 24841, 'Iridium 16', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2464 | [ 24842, 'Iridium 911', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2465 | [ 24869, 'Iridium 15', '[D]', 'Decayed 2018-10-14', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2466 | [ 24870, 'Iridium 17', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2467 | [ 24871, 'Iridium 920', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2468 | [ 24872, 'Iridium 18', '[D]', 'Decayed 2018-08-19', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2469 | [ 24873, 'Iridium 921', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2470 | [ 24903, 'Iridium 26', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2471 | [ 24904, 'Iridium 25', '[D]', 'Decayed 2018-05-14', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2472 | [ 24905, 'Iridium 46', '[D]', 'Decayed 2019-05-11', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2473 | [ 24906, 'Iridium 23', '[D]', 'Decayed 2018-03-28', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2474 | [ 24907, 'Iridium 22', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2475 | [ 24944, 'Iridium 29', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2476 | [ 24945, 'Iridium 32', '[D]', 'Decayed 2019-03-10', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2477 | [ 24946, 'Iridium 33', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2478 | [ 24947, 'Iridium 27', '[D]', 'Decayed 2002-02-01', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2479 | [ 24948, 'Iridium 28', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2480 | [ 24949, 'Iridium 30', '[D]', 'Decayed 2017-09-28', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2481 | [ 24950, 'Iridium 31', '[D]', 'Decayed 2018-12-20', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2482 | [ 24965, 'Iridium 19', '[D]', 'Decayed 2018-04-07', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2483 | [ 24966, 'Iridium 35', '[D]', 'Decayed 2018-12-26', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2484 | [ 24967, 'Iridium 36', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2485 | [ 24968, 'Iridium 37', '[D]', 'Decayed 2018-05-26', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2486 | [ 24969, 'Iridium 34', '[D]', 'Decayed 2018-01-08', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2487 | [ 25039, 'Iridium 43', '[D]', 'Decayed 2018-02-11', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2488 | [ 25040, 'Iridium 41', '[D]', 'Decayed 2018-07-28', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2489 | [ 25041, 'Iridium 40', '[D]', 'Decayed 2018-09-23', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2490 | [ 25042, 'Iridium 39', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2491 | [ 25043, 'Iridium 38', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2492 | [ 25077, 'Iridium 42', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2493 | [ 25078, 'Iridium 44', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2494 | [ 25104, 'Iridium 45', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2495 | [ 25105, 'Iridium 24', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2496 | [ 25106, 'Iridium 47', '[D]', 'Decayed 2018-09-01', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2497 | [ 25107, 'Iridium 48', '[D]', 'Decayed 2001-05-05', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2498 | [ 25108, 'Iridium 49', '[D]', 'Decayed 2018-02-13', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2499 | [ 25169, 'Iridium 52', '[D]', 'Decayed 2018-11-05', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2500 | [ 25170, 'Iridium 56', '[D]', 'Decayed 2018-10-11', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2501 | [ 25171, 'Iridium 54', '[D]', 'Decayed 2019-05-11', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2502 | [ 25172, 'Iridium 50', '[D]', 'Decayed 2018-09-23', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2503 | [ 25173, 'Iridium 53', '[D]', 'Decayed 2018-09-30', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2504 | [ 25262, 'Iridium 51', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2505 | [ 25263, 'Iridium 61', '[D]', 'Decayed 2019-07-23', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2506 | [ 25272, 'Iridium 55', '[D]', 'Decayed 2019-03-31', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2507 | [ 25273, 'Iridium 57', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2508 | [ 25274, 'Iridium 58', '[D]', 'Decayed 2019-04-07', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2509 | [ 25275, 'Iridium 59', '[D]', 'Decayed 2019-03-11', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2510 | [ 25276, 'Iridium 60', '[D]', 'Decayed 2019-03-17', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2511 | [ 25285, 'Iridium 62', '[D]', 'Decayed 2018-11-07', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2512 | [ 25286, 'Iridium 63', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2513 | [ 25287, 'Iridium 64', '[D]', 'Decayed 2019-04-01', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2514 | [ 25288, 'Iridium 65', '[D]', 'Decayed 2018-07-19', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2515 | [ 25289, 'Iridium 66', '[D]', 'Decayed 2018-08-23', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2516 | [ 25290, 'Iridium 67', '[D]', 'Decayed 2018-07-02', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2517 | [ 25291, 'Iridium 68', '[D]', 'Decayed 2018-06-06', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2518 | [ 25319, 'Iridium 69', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2519 | [ 25320, 'Iridium 71', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2520 | [ 25342, 'Iridium 70', '[D]', 'Decayed 2018-10-11', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2521 | [ 25343, 'Iridium 72', '[D]', 'Decayed 2018-05-14', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2522 | [ 25344, 'Iridium 73', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2523 | [ 25345, 'Iridium 74', '[D]', 'Decayed 2017-06-11', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2524 | [ 25346, 'Iridium 75', '[D]', 'Decayed 2018-07-10', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2525 | [ 25431, 'Iridium 3', '[D]', 'Decayed 2018-02-08', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2526 | [ 25432, 'Iridium 76', '[D]', 'Decayed 2018-08-28', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2527 | [ 25467, 'Iridium 82', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2528 | [ 25468, 'Iridium 81', '[D]', 'Decayed 2018-07-17', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2529 | [ 25469, 'Iridium 80', '[D]', 'Decayed 2018-08-12', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2530 | [ 25470, 'Iridium 79', '[D]', 'Decayed 2000-11-29', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2531 | [ 25471, 'Iridium 77', '[D]', 'Decayed 2017-09-22', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2532 | [ 25527, 'Iridium 2', '[?]', 'SpaceTrack', 2 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2533 | [ 25528, 'Iridium 86', '[D]', 'Decayed 2018-10-05', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2534 | [ 25529, 'Iridium 85', '[D]', 'Decayed 2000-12-30', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2535 | [ 25530, 'Iridium 84', '[D]', 'Decayed 2018-11-04', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2536 | [ 25531, 'Iridium 83', '[D]', 'Decayed 2018-11-05', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2537 | [ 25577, 'Iridium 20', '[D]', 'Decayed 2018-10-22', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2538 | [ 25578, 'Iridium 11', '[D]', 'Decayed 2018-10-22', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2539 | [ 25777, 'Iridium 14', '[D]', 'Decayed 2019-03-15', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2540 | [ 25778, 'Iridium 21', '[D]', 'Decayed 2018-05-24', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2541 | [ 27372, 'Iridium 91', '[D]', 'Decayed 2019-03-13', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2542 | [ 27373, 'Iridium 90', '[D]', 'Decayed 2019-01-23', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2543 | [ 27374, 'Iridium 94', '[D]', 'Decayed 2018-04-18', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2544 | [ 27375, 'Iridium 95', '[D]', 'Decayed 2019-03-25', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2545 | [ 27376, 'Iridium 96', '[D]', 'Decayed 2020-05-30', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2546 | [ 27450, 'Iridium 97', '[D]', 'Decayed 2019-12-27', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2547 | [ 27451, 'Iridium 98', '[D]', 'Decayed 2018-08-24', 3 ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2548 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2549 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2550 | 7 | my %ignore_raw = map { $_ => 1 } qw{ kelso sladen }; | |||||||||||||||||||||||||||||||||||||||||||||
| 2551 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2552 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 2553 | 0 | ▶ | sub _iridium_status_opts { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_iridium_status_opts: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2554 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 2555 | 0 | 'raw!' => 'Do not supplement with kelso data' | |||||||||||||||||||||||||||||||||||||||||||||
| 2556 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2557 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2558 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2559 | 0 | ▶ | sub iridium_status { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iridium_status: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2560 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 2561 | 0 | my ( $opt, $fmt ) = _parse_args( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2562 | defined $fmt | ||||||||||||||||||||||||||||||||||||||||||||||
| 2563 | 0 | ▶ | or $fmt = $self->{iridium_status_format}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2564 | 0 | $self->_deprecation_notice( iridium_status => $fmt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2565 | 0 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 2566 | 0 | my %rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 2567 | my $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2568 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2569 | 0 | ▶ | if ( ! $opt->{raw} || $ignore_raw{$fmt} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $opt->{"raw"} or $ignore_raw{$fmt}
MC/DC0%0/2
not $opt->{"raw"} or $ignore_raw{$fmt}
not $opt->{"raw"}
$ignore_raw{$fmt}
Truth table0%0/3
not(A) or B
A= not $opt->{"raw"}B= $ignore_raw{$fmt}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2570 | 0 | $resp = $self->_iridium_status_kelso( $fmt, \%rslt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2571 | 0 | ▶ | $resp->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2572 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2573 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2574 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2575 | 0 | ▶ | unless ( 'kelso' eq $fmt ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2576 | 0 | ▶ | my $code = $self->can( "_iridium_status_$fmt" ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2577 | or Carp::croak "Bad iridium_status format '$fmt'"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2578 | 0 | ▶ | ( $resp = $code->( $self, $fmt, \%rslt ) )->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2579 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2580 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2581 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2582 | 0 | ▶ | unless ( $opt->{raw} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2583 | 0 | foreach my $body ( @all_iridium_classic ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 2584 | 0 | ▶ | $rslt{$body->[0]} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rslt{$body->[0]} and $body->[4] != 3
MC/DC0%0/2
$rslt{$body->[0]} and $body->[4] != 3
$rslt{$body->[0]}
$body->[4] != 3
Truth table0%0/3
A and B
A= $rslt{$body->[0]}B= $body->[4] != 3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2585 | and $body->[4] != _BODY_STATUS_IS_DECAYED | ||||||||||||||||||||||||||||||||||||||||||||||
| 2586 | and next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2587 | 0 | $rslt{$body->[0]} = [ @{ $body } ]; # shallow clone | |||||||||||||||||||||||||||||||||||||||||||||
| 2588 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2589 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2590 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2591 | $resp->content (join '', map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2592 | 0 | sprintf "%6d %-15s%-8s %s\n", @{$rslt{$_}}[0 .. 3]} | |||||||||||||||||||||||||||||||||||||||||||||
| 2593 | 0 | sort {$a <=> $b} keys %rslt); | |||||||||||||||||||||||||||||||||||||||||||||
| 2594 | 0 | $self->_add_pragmata($resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 2595 | 'spacetrack-type' => 'iridium-status', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2596 | 'spacetrack-source' => $fmt, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2597 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2598 | 0 | $self->__dump_response( $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2599 | return wantarray ? ($resp, [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 2600 | 0 | ▶ | sort { $a->[0] <=> $b->[0] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2601 | values %rslt | ||||||||||||||||||||||||||||||||||||||||||||||
| 2602 | ]) : $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2603 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2604 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2605 | # Get Iridium data from Celestrak. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2606 | 0 | ▶ | sub _iridium_status_kelso { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_iridium_status_kelso: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2607 | # my ( $self, $fmt, $rslt ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2608 | 0 | my ( $self, undef, $rslt ) = @_; # $fmt only relevant to mccants | |||||||||||||||||||||||||||||||||||||||||||||
| 2609 | 0 | my $resp = $self->_get_agent()->get( | |||||||||||||||||||||||||||||||||||||||||||||
| 2610 | $self->getv( 'url_iridium_status_kelso' ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2611 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2612 | 0 | ▶ | $resp->is_success or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2613 | 0 | foreach my $buffer (split '\n', $resp->content) { | |||||||||||||||||||||||||||||||||||||||||||||
| 2614 | 0 | $buffer =~ s/ \s+ \z //smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 2615 | 0 | my $id = substr ($buffer, 0, 5) + 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 2616 | 0 | my $name = substr ($buffer, 5); | |||||||||||||||||||||||||||||||||||||||||||||
| 2617 | 0 | my $status = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 2618 | 0 | ▶ | $name =~ s/ \s+ ( [[] .+? []] ) \s* \z //smx | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2619 | and $status = $1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2620 | 0 | my $portable_status = $status_portable{kelso}{$status}; | |||||||||||||||||||||||||||||||||||||||||||||
| 2621 | 0 | ▶ | my $comment = $kelso_comment{$status} || ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$kelso_comment{$status} || ''
MC/DC0%0/1
$kelso_comment{$status} || ''
$kelso_comment{$status}
Truth table0%0/2
A
A= $kelso_comment{$status}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2622 | 0 | $name = ucfirst lc $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 2623 | 0 | $rslt->{$id} = [ $id, $name, $status, $comment, | |||||||||||||||||||||||||||||||||||||||||||||
| 2624 | $portable_status ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2625 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2626 | 0 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 2627 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2628 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2629 | # Mung an Iridium status hash to assume all actual Iridium | ||||||||||||||||||||||||||||||||||||||||||||||
| 2630 | # satellites are good. This is used to prevent bleed-through from | ||||||||||||||||||||||||||||||||||||||||||||||
| 2631 | # Kelso to McCants, since the latter only reports by exception. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2632 | 0 | ▶ | sub _iridium_status_assume_good { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_iridium_status_assume_good: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2633 | 0 | my ( undef, $rslt ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 2634 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2635 | 0 | foreach my $val ( values %{ $rslt } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 2636 | 0 | ▶ | $val->[1] =~ m/ \A iridium \b /smxi | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2637 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2638 | 0 | $val->[2] = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 2639 | 0 | $val->[4] = _BODY_STATUS_IS_OPERATIONAL; | |||||||||||||||||||||||||||||||||||||||||||||
| 2640 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2641 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2642 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 2643 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2644 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2645 | my %sladen_interpret_detail = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 2646 | 0 | ▶ | '' => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2647 | 0 | my ( $rslt, $id, $name, $plane ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 2648 | 0 | $rslt->{$id} = [ $id, $name, '[-]', | |||||||||||||||||||||||||||||||||||||||||||||
| 2649 | "$plane - Failed on station?", | ||||||||||||||||||||||||||||||||||||||||||||||
| 2650 | _BODY_STATUS_IS_TUMBLING ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2651 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 2652 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2653 | 0 | ▶ | d => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2654 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 2655 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2656 | 0 | ▶ | t => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2657 | 0 | my ( $rslt, $id, $name, $plane ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 2658 | 0 | $rslt->{$id} = [ $id, $name, '[-]', $plane, | |||||||||||||||||||||||||||||||||||||||||||||
| 2659 | _BODY_STATUS_IS_TUMBLING ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2660 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2661 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2662 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2663 | # Get Iridium status from Rod Sladen. Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 2664 | 0 | ▶ | sub _iridium_status_sladen { ## no critic (ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_iridium_status_sladen: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2665 | 0 | my ( $self, undef, $rslt ) = @_; # $fmt arg not used | |||||||||||||||||||||||||||||||||||||||||||||
| 2666 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2667 | 0 | $self->_iridium_status_assume_good( $rslt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2668 | 0 | my $resp = $self->_get_agent()->get( | |||||||||||||||||||||||||||||||||||||||||||||
| 2669 | $self->getv( 'url_iridium_status_sladen' ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2670 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2671 | 0 | ▶ | $resp->is_success or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2672 | 0 | my %oid; | |||||||||||||||||||||||||||||||||||||||||||||
| 2673 | my %dummy; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2674 | 0 | foreach my $id (keys %{ $rslt } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 2675 | 0 | ▶ | $rslt->{$id}[1] =~ m/ dummy /smxi and do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2676 | 0 | $dummy{$id} = $rslt->{$id}; | |||||||||||||||||||||||||||||||||||||||||||||
| 2677 | 0 | $dummy{$id}[3] = 'Dummy'; | |||||||||||||||||||||||||||||||||||||||||||||
| 2678 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 2679 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2680 | 0 | ▶ | $rslt->{$id}[1] =~ m/ (\d+) /smx or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2681 | 0 | $oid{+$1} = $id; | |||||||||||||||||||||||||||||||||||||||||||||
| 2682 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2683 | 0 | %{ $rslt } = %dummy; | |||||||||||||||||||||||||||||||||||||||||||||
| 2684 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2685 | 0 | my $fail; | |||||||||||||||||||||||||||||||||||||||||||||
| 2686 | 0 | my $re = qr{ ( [\d/]+) }smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 2687 | 0 | local $_ = $resp->content; | |||||||||||||||||||||||||||||||||||||||||||||
| 2688 | #### s{ <em> .*? </em> }{}smxgi; # Strip emphasis notes | ||||||||||||||||||||||||||||||||||||||||||||||
| 2689 | 0 | s/ < .*? > //smxg; # Strip markup | |||||||||||||||||||||||||||||||||||||||||||||
| 2690 | # Parenthesized numbers are assumed to represent tumbling | ||||||||||||||||||||||||||||||||||||||||||||||
| 2691 | # satellites in the in-service or spare grids. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2692 | 0 | my %exception; | |||||||||||||||||||||||||||||||||||||||||||||
| 2693 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2694 | # 23-Nov-2017 update double-parenthesized 6. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2695 | 0 | s< [(]+ (\d+) [)]+ > | |||||||||||||||||||||||||||||||||||||||||||||
| 2696 | 0 | < $exception{$1} = _BODY_STATUS_IS_TUMBLING; $1>smxge; | |||||||||||||||||||||||||||||||||||||||||||||
| 2697 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2698 | 0 | s/ [(] .*? [)\n] //smxg; # Strip parenthetical comments | |||||||||||||||||||||||||||||||||||||||||||||
| 2699 | 0 | foreach ( split qr{ \n }smx ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 2700 | 0 | ▶ | if (m/ < -+ \s+ failed \s+ (?: or \s+ retired \s+ )? -+ > /smxi) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2701 | 0 | $fail++; | |||||||||||||||||||||||||||||||||||||||||||||
| 2702 | 0 | $re = qr{ (\d+) (\w?) }smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 2703 | } elsif ( s/ \A \s* ( plane \s+ \d+ ) \s* : \s* //smxi ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2704 | 0 | my $plane = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 2705 | ## s/ \A \D+ //smx; # Strip leading non-digits | ||||||||||||||||||||||||||||||||||||||||||||||
| 2706 | 0 | s/ \b [[:alpha:]] .* //smx; # Strip trailing comments | |||||||||||||||||||||||||||||||||||||||||||||
| 2707 | 0 | s/ \s+ \z //smx; # Strip trailing whitespace | |||||||||||||||||||||||||||||||||||||||||||||
| 2708 | 0 | my $inx = 0; # First 11 functional are in service | |||||||||||||||||||||||||||||||||||||||||||||
| 2709 | 0 | ▶ | while (m/ $re /smxg) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2710 | 0 | my $num_list = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 2711 | 0 | my $detail = $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 2712 | 0 | foreach my $num ( split qr{ / }smx, $num_list ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 2713 | 0 | $num = $num + 0; # Numify. | |||||||||||||||||||||||||||||||||||||||||||||
| 2714 | 0 | ▶ | my $id = $oid{$num} or do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2715 | # This is normal for decayed satellites or Iridium | ||||||||||||||||||||||||||||||||||||||||||||||
| 2716 | # NEXT. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2717 | # warn "No oid for Iridium $num\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2718 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 2719 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2720 | 0 | my $name = "Iridium $num"; | |||||||||||||||||||||||||||||||||||||||||||||
| 2721 | 0 | ▶ | if ($fail) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2722 | my $interp = $sladen_interpret_detail{$detail} | ||||||||||||||||||||||||||||||||||||||||||||||
| 2723 | 0 | ▶ | || $sladen_interpret_detail{''}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$sladen_interpret_detail{$detail} || $sladen_interpret_detail{''}
MC/DC0%0/2
$sladen_interpret_detail{$detail} || $sladen_interpret_detail{''}
$sladen_interpret_detail{$detail}
$sladen_interpret_detail{''}
Truth table0%0/3
A || B
A= $sladen_interpret_detail{$detail}B= $sladen_interpret_detail{''}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2724 | 0 | $interp->( $rslt, $id, $name, $plane ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2725 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2726 | 0 | ▶ | my $status = $inx > 10 ? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2727 | _BODY_STATUS_IS_SPARE : | ||||||||||||||||||||||||||||||||||||||||||||||
| 2728 | _BODY_STATUS_IS_OPERATIONAL; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2729 | exists $exception{$num} | ||||||||||||||||||||||||||||||||||||||||||||||
| 2730 | 0 | ▶ | and $status = $exception{$num}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2731 | $rslt->{$id} = [ $id, $name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2732 | 0 | $status_portable{kelso_inverse}{$status}, | |||||||||||||||||||||||||||||||||||||||||||||
| 2733 | $plane, $status ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2734 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2735 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2736 | } continue { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2737 | 0 | $inx++; | |||||||||||||||||||||||||||||||||||||||||||||
| 2738 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2739 | } elsif ( m/ Notes: /smx ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2740 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 2741 | } else { # TODO this is just for debugging. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2742 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 2743 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2744 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2745 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2746 | 0 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 2747 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2748 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2749 | # FIXME in the last couple days this has started returning nothing. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2750 | # It looks like -exclude debris excludes everything, as does | ||||||||||||||||||||||||||||||||||||||||||||||
| 2751 | # -exclude rocket. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2752 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2753 | # Get Iridium status from Space Track. Unlike the other sources, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2754 | # Space Track does not know whether satellites are in service or | ||||||||||||||||||||||||||||||||||||||||||||||
| 2755 | # not, but it does know about all of them, and whether or not they | ||||||||||||||||||||||||||||||||||||||||||||||
| 2756 | # are on orbit. So the statuses we report are unknown and decayed. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2757 | # Note that the portable status for unknown is | ||||||||||||||||||||||||||||||||||||||||||||||
| 2758 | # BODY_STATUS_IS_TUMBLING. Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 2759 | 0 | ▶ | sub _iridium_status_spacetrack { ## no critic (ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_iridium_status_spacetrack: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2760 | 0 | my ( $self, undef, $rslt ) = @_; # $fmt arg not used | |||||||||||||||||||||||||||||||||||||||||||||
| 2761 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2762 | 0 | my ( $resp, $data ) = $self->search_name( { | |||||||||||||||||||||||||||||||||||||||||||||
| 2763 | tle => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2764 | status => 'all', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2765 | include => [ qw{ payload } ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 2766 | format => 'legacy', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2767 | }, 'iridium' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2768 | 0 | ▶ | $resp->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2769 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2770 | 0 | foreach my $body ( @{ $data } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 2771 | # Starting in 2017, the launches were Iridium Next | ||||||||||||||||||||||||||||||||||||||||||||||
| 2772 | # satellites, which do not flare. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2773 | 0 | ▶ | $body->{LAUNCH_YEAR} < 2017 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2774 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2775 | 0 | my $oid = $body->{NORAD_CAT_ID}; | |||||||||||||||||||||||||||||||||||||||||||||
| 2776 | $rslt->{$oid} | ||||||||||||||||||||||||||||||||||||||||||||||
| 2777 | and not $body->{DECAY} | ||||||||||||||||||||||||||||||||||||||||||||||
| 2778 | 0 | ▶ | and next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rslt->{$oid} and not $body->{"DECAY"}
MC/DC0%0/2
$rslt->{$oid} and not $body->{"DECAY"}
$rslt->{$oid}
not $body->{"DECAY"}
Truth table0%0/3
A and not(B)
A= $rslt->{$oid}B= not $body->{"DECAY"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2779 | $rslt->{$oid} = [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 2780 | $oid, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2781 | ucfirst lc $body->{OBJECT_NAME}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2782 | defined $body->{DECAY} ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 2783 | 0 | ▶ | ( '[D]', "Decayed $body->{DECAY}", _BODY_STATUS_IS_DECAYED ) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2784 | ( '[?]', 'SpaceTrack', _BODY_STATUS_IS_TUMBLING ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2785 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2786 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2787 | $resp->content( join '', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2788 | 0 | map { "$_->[0]\t$_->[1]\t$_->[2]\t$_->[3]\n" } | |||||||||||||||||||||||||||||||||||||||||||||
| 2789 | 0 | sort { $a->[0] <=> $b->[0] } | |||||||||||||||||||||||||||||||||||||||||||||
| 2790 | 0 | values %{ $rslt } | |||||||||||||||||||||||||||||||||||||||||||||
| 2791 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2792 | 0 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 2793 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2794 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2795 | } # End of local symbol block. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2796 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2797 | =for html <a name="launch_sites"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2798 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2799 | =item $resp = $st->launch_sites() | ||||||||||||||||||||||||||||||||||||||||||||||
| 2800 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2801 | This method returns an HTTP::Response object. If the request succeeds, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2802 | the content of the object will be the known launch sites and their | ||||||||||||||||||||||||||||||||||||||||||||||
| 2803 | abbreviations in the desired format. If the desired format is | ||||||||||||||||||||||||||||||||||||||||||||||
| 2804 | C<'legacy'> or C<'json'> and the method is called in list context, the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2805 | second returned item will be a reference to an array containing the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2806 | parsed data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2807 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2808 | This method takes the following options, specified either command-style | ||||||||||||||||||||||||||||||||||||||||||||||
| 2809 | or as a hash reference. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2810 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2811 | C<-format> specifies the desired format of the retrieved data. Possible | ||||||||||||||||||||||||||||||||||||||||||||||
| 2812 | values are C<'xml'>, C<'json'>, C<'html'>, C<'csv'>, and C<'legacy'>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2813 | which is the default. The legacy format is tab-delimited text, such as | ||||||||||||||||||||||||||||||||||||||||||||||
| 2814 | was returned by the version 1 interface. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2815 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2816 | C<-json> specifies JSON format. If you specify both C<-json> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 2817 | C<-format> you will get an exception unless you specify C<-format=json>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2818 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2819 | This method requires a Space Track username and password. It | ||||||||||||||||||||||||||||||||||||||||||||||
| 2820 | implicitly calls the C<login()> method if the session cookie is | ||||||||||||||||||||||||||||||||||||||||||||||
| 2821 | missing or expired. If C<login()> fails, you will get the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2822 | HTTP::Response from C<login()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2823 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2824 | If this method succeeds, the response will contain headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 2825 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2826 | Pragma: spacetrack-type = launch_sites | ||||||||||||||||||||||||||||||||||||||||||||||
| 2827 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 2828 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2829 | There are no arguments. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2830 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2831 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 2832 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2833 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2834 | 7 | my @headings = ( 'Abbreviation', 'Launch Site' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2835 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2836 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 2837 | 1 | ▶ | sub _launch_sites_opts { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_launch_sites_opts: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2838 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 2839 | 1 | 'json!' => 'Return data in JSON format', | |||||||||||||||||||||||||||||||||||||||||||||
| 2840 | 'format=s' => 'Specify return format', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2841 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2842 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2843 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2844 | 1 | ▶ | sub launch_sites { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
launch_sites: called CC=8 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2845 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 2846 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2847 | 1 | ( my $opt, @args ) = _parse_args( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2848 | 1 | my $format = _retrieval_format( launch_sites => $opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2849 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2850 | 1 | my $resp = $self->spacetrack_query_v2( qw{ | |||||||||||||||||||||||||||||||||||||||||||||
| 2851 | basicspacedata query class launch_site }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2852 | format => $format, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2853 | orderby => 'SITE_CODE asc', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2854 | qw{ predicates all | ||||||||||||||||||||||||||||||||||||||||||||||
| 2855 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2856 | 1 | ▶ | $resp->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2857 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2858 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2859 | 1 | $self->_add_pragmata($resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 2860 | 'spacetrack-type' => 'launch_sites', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2861 | 'spacetrack-source' => 'spacetrack', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2862 | 'spacetrack-interface' => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2863 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2864 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2865 | 1 | ▶ | 'json' ne $format | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2866 | and return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2867 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2868 | 1 | my $json = $self->_get_json_object(); | |||||||||||||||||||||||||||||||||||||||||||||
| 2869 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2870 | 1 | my $data = $json->decode( $resp->content() ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2871 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2872 | 1 | my %dict; | |||||||||||||||||||||||||||||||||||||||||||||
| 2873 | 1 | foreach my $datum ( @{ $data } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 2874 | defined $datum->{SITE_CODE} | ||||||||||||||||||||||||||||||||||||||||||||||
| 2875 | 34 | ▶ | and $dict{$datum->{SITE_CODE}} = $datum->{LAUNCH_SITE}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2876 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2877 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2878 | 1 | ▶ | if ( $opt->{json} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2879 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2880 | 0 | $resp->content( $json->encode( \%dict ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2881 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2882 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 2883 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2884 | $resp->content( | ||||||||||||||||||||||||||||||||||||||||||||||
| 2885 | join '', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2886 | join( "\t", @headings ) . "\n", | ||||||||||||||||||||||||||||||||||||||||||||||
| 2887 | 0 | map { "$_\t$dict{$_}\n" } sort keys %dict | |||||||||||||||||||||||||||||||||||||||||||||
| 2888 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2889 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2890 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2891 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2892 | wantarray | ||||||||||||||||||||||||||||||||||||||||||||||
| 2893 | 1 | ▶ | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2894 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2895 | 0 | my @table; | |||||||||||||||||||||||||||||||||||||||||||||
| 2896 | 0 | push @table, [ @headings ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 2897 | 0 | foreach my $key ( sort keys %dict ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 2898 | 0 | push @table, [ $key, $dict{$key} ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 2899 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2900 | 0 | return ( $resp, \@table ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2901 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2902 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2903 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2904 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2905 | =for html <a name="login"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2906 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2907 | =item $resp = $st->login ( ... ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2908 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2909 | If any arguments are given, this method passes them to the set () | ||||||||||||||||||||||||||||||||||||||||||||||
| 2910 | method. Then it executes a login to the Space Track web site. The return | ||||||||||||||||||||||||||||||||||||||||||||||
| 2911 | is normally the HTTP::Response object from the login. But if no session | ||||||||||||||||||||||||||||||||||||||||||||||
| 2912 | cookie was obtained, the return is an HTTP::Response with an appropriate | ||||||||||||||||||||||||||||||||||||||||||||||
| 2913 | message and the code set to HTTP_UNAUTHORIZED from HTTP::Status (a.k.a. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2914 | 401). If a login is attempted without the username and password being | ||||||||||||||||||||||||||||||||||||||||||||||
| 2915 | set, the return is an HTTP::Response with an appropriate message and the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2916 | code set to HTTP_PRECONDITION_FAILED from HTTP::Status (a.k.a. 412). | ||||||||||||||||||||||||||||||||||||||||||||||
| 2917 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2918 | A Space Track username and password are required to use this method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2919 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2920 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 2921 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2922 | 7 | ▶ | sub login { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
login: called CC=9 SCAR=23.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2923 | 2 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 2924 | 2 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 2925 | 2 | ▶ | @args and $self->set( @args ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2926 | 2 | ▶ | ( $self->{username} && $self->{password} ) or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"username"} and $self->{"password"}
MC/DC0%0/2
$self->{"username"} and $self->{"password"}
$self->{"username"}
$self->{"password"}
Truth table33%1/3
A and B
A= $self->{"username"}B= $self->{"password"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2927 | return HTTP::Response->new ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 2928 | HTTP_PRECONDITION_FAILED, NO_CREDENTIALS); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2929 | 2 | ▶ | $self->{dump_headers} & DUMP_TRACE and warn <<"EOD"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2930 | Logging in as $self->{username}. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2931 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 2932 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2933 | # Do not use the spacetrack_query_v2 method to retrieve the session | ||||||||||||||||||||||||||||||||||||||||||||||
| 2934 | # cookie, unless you like bottomless recursions. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2935 | 2 | my $url = $self->_make_space_track_base_url( 2 ) . | |||||||||||||||||||||||||||||||||||||||||||||
| 2936 | '/ajaxauth/login'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2937 | $self->_dump_request( | ||||||||||||||||||||||||||||||||||||||||||||||
| 2938 | arg => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 2939 | identity => $self->{username}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2940 | password => $self->{password}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2941 | 2 | ], | |||||||||||||||||||||||||||||||||||||||||||||
| 2942 | method => 'POST', | ||||||||||||||||||||||||||||||||||||||||||||||
| 2943 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2944 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2945 | my $resp = $self->_get_agent()->post( | ||||||||||||||||||||||||||||||||||||||||||||||
| 2946 | $url, [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 2947 | identity => $self->{username}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2948 | password => $self->{password}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 2949 | 2 | ] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2950 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2951 | 2 | ▶ | $resp->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2952 | or return _mung_login_status( $resp ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2953 | 2 | $self->__dump_response( $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 2954 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2955 | 2 | ▶ | $resp->content() =~ m/ \b failed \b /smxi | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2956 | and return HTTP::Response->new( HTTP_UNAUTHORIZED, LOGIN_FAILED ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2957 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2958 | 2 | ▶ | $self->_record_cookie_generic( 2 ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2959 | or return HTTP::Response->new( HTTP_UNAUTHORIZED, LOGIN_FAILED ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2960 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2961 | 2 | ▶ | $self->{dump_headers} & DUMP_TRACE and warn <<'EOD'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2962 | Login successful. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2963 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 2964 | 2 | return HTTP::Response->new (HTTP_OK, undef, undef, "Login successful.\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 2965 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2966 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2967 | =for html <a name="logout"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2968 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2969 | =item $st->logout() | ||||||||||||||||||||||||||||||||||||||||||||||
| 2970 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2971 | This method deletes all session cookies. It returns an HTTP::Response | ||||||||||||||||||||||||||||||||||||||||||||||
| 2972 | object that indicates success. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2973 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2974 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 2975 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2976 | 4 | ▶ | sub logout { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logout: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2977 | 4 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 2978 | 4 | foreach my $spacetrack_interface_info ( | |||||||||||||||||||||||||||||||||||||||||||||
| 2979 | 4 | @{ $self->{_space_track_interface} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 2980 | 12 | ▶ | $spacetrack_interface_info | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2981 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2982 | exists $spacetrack_interface_info->{session_cookie} | ||||||||||||||||||||||||||||||||||||||||||||||
| 2983 | 4 | ▶ | and $spacetrack_interface_info->{session_cookie} = undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2984 | exists $spacetrack_interface_info->{cookie_expires} | ||||||||||||||||||||||||||||||||||||||||||||||
| 2985 | 4 | ▶ | and $spacetrack_interface_info->{cookie_expires} = 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2986 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2987 | 4 | return HTTP::Response->new( | |||||||||||||||||||||||||||||||||||||||||||||
| 2988 | HTTP_OK, undef, undef, "Logout successful.\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2989 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 2990 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2991 | =for html <a name="mccants"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2992 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2993 | =item $resp = $st->mccants( catalog ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2994 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2995 | This method retrieves one of several pieces of data that Mike McCants | ||||||||||||||||||||||||||||||||||||||||||||||
| 2996 | makes available on his web site. The return is the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2997 | L<HTTP::Response|HTTP::Response> object from the retrieval. Valid | ||||||||||||||||||||||||||||||||||||||||||||||
| 2998 | catalog names are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 2999 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3000 | classified: Classified TLE file (classfd.zip) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3001 | integrated: Integrated TLE file (inttles.zip) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3002 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3003 | The files marked B<REMOVED> have been removed from Mike McCants' web | ||||||||||||||||||||||||||||||||||||||||||||||
| 3004 | site. As of version 0.181, use of the associated arguments is fatal. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3005 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3006 | You can specify options as either command-type options (e.g. C<< | ||||||||||||||||||||||||||||||||||||||||||||||
| 3007 | mccants( '-file', 'foo.dat', ... ) >>) or as a leading hash reference | ||||||||||||||||||||||||||||||||||||||||||||||
| 3008 | (e.g. C<< mccants( { file => 'foo.dat' }, ...) >>). If you specify the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3009 | hash reference, option names must be specified in full, without the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3010 | leading '-', and the argument list will not be parsed for command-type | ||||||||||||||||||||||||||||||||||||||||||||||
| 3011 | options. If you specify command-type options, they may be abbreviated, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3012 | as long as the abbreviation is unique. Errors in either sort result in | ||||||||||||||||||||||||||||||||||||||||||||||
| 3013 | an exception being thrown. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3014 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3015 | The legal options are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3016 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3017 | -file | ||||||||||||||||||||||||||||||||||||||||||||||
| 3018 | specifies the name of the cache file. If the data | ||||||||||||||||||||||||||||||||||||||||||||||
| 3019 | on line are newer than the modification date of | ||||||||||||||||||||||||||||||||||||||||||||||
| 3020 | the cache file, the cache file will be updated. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3021 | Otherwise the data will be returned from the file. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3022 | Either way the content of the file and the content | ||||||||||||||||||||||||||||||||||||||||||||||
| 3023 | of the returned HTTP::Response object end up the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3024 | same. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3025 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3026 | On success, the content of the returned object is the actual data, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3027 | unzipped and with line endings normalized for the current system. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3028 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3029 | If this method succeeds, the response will contain headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 3030 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3031 | Pragma: spacetrack-type = (see below) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3032 | Pragma: spacetrack-source = mccants | ||||||||||||||||||||||||||||||||||||||||||||||
| 3033 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3034 | The content of the spacetrack-type pragma depends on the catalog | ||||||||||||||||||||||||||||||||||||||||||||||
| 3035 | fetched, as follows: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3036 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3037 | classified: 'orbit' | ||||||||||||||||||||||||||||||||||||||||||||||
| 3038 | integrated: 'orbit' | ||||||||||||||||||||||||||||||||||||||||||||||
| 3039 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3040 | If the C<file> option was passed, the following additional header will | ||||||||||||||||||||||||||||||||||||||||||||||
| 3041 | be provided: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3042 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3043 | Pragma: spacetrack-cache-hit = (either true or false) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3044 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3045 | This can be accessed by the C<cache_hit()> method. If this pragma is | ||||||||||||||||||||||||||||||||||||||||||||||
| 3046 | true, the C<Last-Modified> header of the response will contain the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3047 | modification time of the file. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3048 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3049 | No Space Track username and password are required to use this method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3050 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3051 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 3052 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3053 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 3054 | 3 | ▶ | sub _mccants_opts { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mccants_opts: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3055 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 3056 | 3 | 'file=s' => 'Name of cache file', | |||||||||||||||||||||||||||||||||||||||||||||
| 3057 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3058 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3059 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3060 | 3 | ▶ | sub mccants { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mccants: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3061 | 3 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 3062 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3063 | 3 | ( my $opt, @args ) = _parse_args( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3064 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3065 | return $self->_get_from_net( | ||||||||||||||||||||||||||||||||||||||||||||||
| 3066 | 3 | %{ $opt }, | |||||||||||||||||||||||||||||||||||||||||||||
| 3067 | catalog => $args[0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3068 | 2 | ▶ | post_process => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3069 | 2 | my ( undef, $resp, $info ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 3070 | 2 | my ( $content, @zip_opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3071 | defined $info->{member} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3072 | 2 | ▶ | and push @zip_opt, Name => $info->{member}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3073 | 2 | ▶ | IO::Uncompress::Unzip::unzip( \( $resp->content() ), | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3074 | \$content, @zip_opt ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3075 | or return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 3076 | HTTP_NOT_FOUND, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3077 | $IO::Uncompress::Unzip::UnzipError ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3078 | 2 | $resp->content( $content ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3079 | 2 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 3080 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3081 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3082 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3083 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3084 | =for html <a name="names"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 3085 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3086 | =item $resp = $st->names (source) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3087 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3088 | This method retrieves the names of the catalogs for the given source, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3089 | either C<'celestrak'>, C<'celestrak_supplemental'>, C<'iridium_status'>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3090 | C<'mccants'>, or C<'spacetrack'>, in the content of | ||||||||||||||||||||||||||||||||||||||||||||||
| 3091 | the given HTTP::Response object. If the argument is not one of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3092 | supported values, the C<$resp> object represents a 404 (Not found) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3093 | error. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3094 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3095 | In list context, you also get a reference to a list of two-element | ||||||||||||||||||||||||||||||||||||||||||||||
| 3096 | lists; each inner list contains the description and the catalog name, in | ||||||||||||||||||||||||||||||||||||||||||||||
| 3097 | that order (suitable for inserting into a Tk Optionmenu). If the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3098 | argument is not one of the supported values, the second return will be | ||||||||||||||||||||||||||||||||||||||||||||||
| 3099 | C<undef>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3101 | No Space Track username and password are required to use this method, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3102 | since all it is doing is returning data kept by this module. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3104 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 3105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3106 | 2 | ▶ | sub names { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names: called CC=8 SCAR=25.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3107 | 2 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 3108 | 2 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 3109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3110 | 2 | ▶ | my $src = $self->__catalog( $name ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3111 | or return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 3112 | HTTP_NOT_FOUND, "Data source '$name' not found."); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3114 | 1 | my @list; | |||||||||||||||||||||||||||||||||||||||||||||
| 3115 | 1 | foreach my $cat (sort keys %$src) { | |||||||||||||||||||||||||||||||||||||||||||||
| 3116 | 49 | ▶ | push @list, defined ($src->{$cat}{number}) ? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3117 | "$cat ($src->{$cat}{number}): $src->{$cat}{name}\n" : | ||||||||||||||||||||||||||||||||||||||||||||||
| 3118 | "$cat: $src->{$cat}{name}\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3119 | defined $src->{$cat}{note} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3120 | 49 | ▶ | and $list[-1] .= " $src->{$cat}{note}\n"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3121 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3122 | 1 | my $resp = HTTP::Response->new (HTTP_OK, undef, undef, join ('', @list)); | |||||||||||||||||||||||||||||||||||||||||||||
| 3123 | 1 | ▶ | return $resp unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3124 | 0 | @list = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 3125 | 0 | foreach my $cat (sort {$src->{$a}{name} cmp $src->{$b}{name}} | |||||||||||||||||||||||||||||||||||||||||||||
| 3126 | keys %$src) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 3127 | 0 | push @list, [$src->{$cat}{name}, $cat]; | |||||||||||||||||||||||||||||||||||||||||||||
| 3128 | defined $src->{$cat}{note} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3129 | 0 | ▶ | and push @{ $list[-1] }, $src->{$cat}{note}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3130 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3131 | 0 | return ($resp, \@list); | |||||||||||||||||||||||||||||||||||||||||||||
| 3132 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3134 | =for html <a name="retrieve"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 3135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3136 | =item $resp = $st->retrieve (number_or_range ...) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3137 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3138 | This method retrieves the latest element set for each of the given | ||||||||||||||||||||||||||||||||||||||||||||||
| 3139 | satellite ID numbers (also known as SATCAT IDs, NORAD IDs, or OIDs) from | ||||||||||||||||||||||||||||||||||||||||||||||
| 3140 | The Space Track web site. Non-numeric catalog numbers are ignored, as | ||||||||||||||||||||||||||||||||||||||||||||||
| 3141 | are (at a later stage) numbers that do not actually represent a | ||||||||||||||||||||||||||||||||||||||||||||||
| 3142 | satellite. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3144 | A Space Track username and password are required to use this method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3146 | If this method succeeds, the response will contain headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 3147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3148 | Pragma: spacetrack-type = orbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 3149 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 3150 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3151 | These can be accessed by C<< $st->content_type( $resp ) >> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 3152 | C<< $st->content_source( $resp ) >> respectively. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3154 | Number ranges are represented as 'start-end', where both 'start' and | ||||||||||||||||||||||||||||||||||||||||||||||
| 3155 | 'end' are catalog numbers. If 'start' > 'end', the numbers will be | ||||||||||||||||||||||||||||||||||||||||||||||
| 3156 | taken in the reverse order. Non-numeric ranges are ignored. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3158 | You can specify options for the retrieval as either command-type options | ||||||||||||||||||||||||||||||||||||||||||||||
| 3159 | (e.g. C<< retrieve ('-json', ...) >>) or as a leading hash reference | ||||||||||||||||||||||||||||||||||||||||||||||
| 3160 | (e.g. C<< retrieve ({json => 1}, ...) >>). If you specify the hash | ||||||||||||||||||||||||||||||||||||||||||||||
| 3161 | reference, option names must be specified in full, without the leading | ||||||||||||||||||||||||||||||||||||||||||||||
| 3162 | '-', and the argument list will not be parsed for command-type options. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3163 | If you specify command-type options, they may be abbreviated, as long as | ||||||||||||||||||||||||||||||||||||||||||||||
| 3164 | the abbreviation is unique. Errors in either sort result in an exception | ||||||||||||||||||||||||||||||||||||||||||||||
| 3165 | being thrown. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3166 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3167 | The legal options are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3169 | -descending | ||||||||||||||||||||||||||||||||||||||||||||||
| 3170 | specifies the data be returned in descending order. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3171 | -end_epoch date | ||||||||||||||||||||||||||||||||||||||||||||||
| 3172 | specifies the end epoch for the desired data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3173 | -format format_name | ||||||||||||||||||||||||||||||||||||||||||||||
| 3174 | specifies the format in which the data are retrieved. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3175 | -json | ||||||||||||||||||||||||||||||||||||||||||||||
| 3176 | specifies the TLE be returned in JSON format. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3177 | -last5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 3178 | Ignored and deprecated. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3179 | -start_epoch date | ||||||||||||||||||||||||||||||||||||||||||||||
| 3180 | specifies the start epoch for the desired data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3181 | -since_file number | ||||||||||||||||||||||||||||||||||||||||||||||
| 3182 | specifies that only data since the given Space Track | ||||||||||||||||||||||||||||||||||||||||||||||
| 3183 | file number be retrieved. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3184 | -sort type | ||||||||||||||||||||||||||||||||||||||||||||||
| 3185 | specifies how to sort the data. Legal types are | ||||||||||||||||||||||||||||||||||||||||||||||
| 3186 | 'catnum' and 'epoch', with 'catnum' the default. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3188 | The C<-format> option takes any argument supported by the Space Track | ||||||||||||||||||||||||||||||||||||||||||||||
| 3189 | interface: C<tle>, C<3le>, C<json>, C<csv>, C<html>, or C<xml>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3190 | Specifying C<-json> is equivalent to specifying C<-format json>, and if | ||||||||||||||||||||||||||||||||||||||||||||||
| 3191 | you specify C<-json>, specifying C<-format> with any other value than | ||||||||||||||||||||||||||||||||||||||||||||||
| 3192 | C<'json'> results in an exception being thrown. In addition, you can | ||||||||||||||||||||||||||||||||||||||||||||||
| 3193 | specify format C<'legacy'> which is equivalent to C<'tle'> if the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3194 | C<with_name> attribute is false, or C<'3le'> (but without the leading | ||||||||||||||||||||||||||||||||||||||||||||||
| 3195 | C<'0 '> before the common name) if C<with_name> is true. The default is | ||||||||||||||||||||||||||||||||||||||||||||||
| 3196 | C<'legacy'> unless C<-json> is specified. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3197 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3198 | If you specify either start_epoch or end_epoch, you get data with epochs | ||||||||||||||||||||||||||||||||||||||||||||||
| 3199 | at least equal to the start epoch, but less than the end epoch (i.e. the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3200 | interval is closed at the beginning but open at the end). If you specify | ||||||||||||||||||||||||||||||||||||||||||||||
| 3201 | only one of these, you get a one-day interval. Dates are specified | ||||||||||||||||||||||||||||||||||||||||||||||
| 3202 | either numerically (as a Perl date) or as numeric year-month-day (and | ||||||||||||||||||||||||||||||||||||||||||||||
| 3203 | optional hour, hour:minute, or hour:minute:second), punctuated by any | ||||||||||||||||||||||||||||||||||||||||||||||
| 3204 | non-numeric string. It is an error to specify an end_epoch before the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3205 | start_epoch. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3206 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3207 | If you are passing the options as a hash reference, you must specify | ||||||||||||||||||||||||||||||||||||||||||||||
| 3208 | a value for Boolean options like 'descending' and 'json'. This value is | ||||||||||||||||||||||||||||||||||||||||||||||
| 3209 | interpreted in the Perl sense - that is, undef, 0, and '' are false, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3210 | and anything else is true. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3212 | In order not to load the Space Track web site too heavily, data are | ||||||||||||||||||||||||||||||||||||||||||||||
| 3213 | retrieved in batches of 200. Ranges will be subdivided and handled in | ||||||||||||||||||||||||||||||||||||||||||||||
| 3214 | more than one retrieval if necessary. To limit the damage done by a | ||||||||||||||||||||||||||||||||||||||||||||||
| 3215 | pernicious range, ranges greater than the max_range setting (which | ||||||||||||||||||||||||||||||||||||||||||||||
| 3216 | defaults to 500) will be ignored with a warning to STDERR. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3218 | If you specify C<-json> and more than one retrieval is needed, data from | ||||||||||||||||||||||||||||||||||||||||||||||
| 3219 | retrievals after the first B<may> have field C<_file_of_record> added. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3220 | This is because of the theoretical possibility that the database may be | ||||||||||||||||||||||||||||||||||||||||||||||
| 3221 | updated between the first and last queries, and therefore taking the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3222 | maximum C<FILE> from queries after the first may cause updates to be | ||||||||||||||||||||||||||||||||||||||||||||||
| 3223 | skipped. The C<_file_of_record> key will appear only in data having a | ||||||||||||||||||||||||||||||||||||||||||||||
| 3224 | C<FILE> value greater than the largest C<FILE> in the first retrieval. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3225 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3226 | This method implicitly calls the C<login()> method if the session cookie | ||||||||||||||||||||||||||||||||||||||||||||||
| 3227 | is missing or expired. If C<login()> fails, you will get the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3228 | HTTP::Response from C<login()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3230 | If this method succeeds, a 'Pragma: spacetrack-type = orbit' header is | ||||||||||||||||||||||||||||||||||||||||||||||
| 3231 | added to the HTTP::Response object returned. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3232 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3233 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 3234 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3235 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 3236 | 0 | ▶ | sub _retrieve_opts { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_retrieve_opts: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3237 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 3238 | 0 | _get_retrieve_options(), | |||||||||||||||||||||||||||||||||||||||||||||
| 3239 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3240 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3241 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3242 | 31 | ▶ | sub retrieve { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
retrieve: called CC=9 SCAR=22.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3243 | 31 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 3244 | 31 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 3245 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3246 | 31 | @args = $self->_parse_retrieve_args( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3247 | 31 | my $opt = _parse_retrieve_dates( shift @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3249 | 31 | my $rest = $self->_convert_retrieve_options_to_rest( $opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3250 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3251 | 31 | ▶ | @args = $self->_expand_oid_list( @args ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3252 | or return HTTP::Response->new( HTTP_PRECONDITION_FAILED, NO_CAT_ID ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3253 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3254 | 30 | my $no_execute = $self->getv( 'dump_headers' ) & DUMP_DRY_RUN; | |||||||||||||||||||||||||||||||||||||||||||||
| 3255 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3256 | ## $rest->{orderby} = 'EPOCH desc'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3257 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3258 | my $accumulator = _accumulator_for ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 3259 | $no_execute ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 3260 | ( json => { pretty => 1 } ) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 3261 | ( $rest->{format}, { | ||||||||||||||||||||||||||||||||||||||||||||||
| 3262 | 30 | ▶ | file => 1, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3263 | pretty => $self->getv( 'pretty' ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3264 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3265 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3266 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3267 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3268 | 30 | ▶ | while ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3269 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3270 | 32 | my @batch = splice @args, 0, $RETRIEVAL_SIZE; | |||||||||||||||||||||||||||||||||||||||||||||
| 3271 | 32 | $rest->{NORAD_CAT_ID} = _stringify_oid_list( { | |||||||||||||||||||||||||||||||||||||||||||||
| 3272 | separator => ',', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3273 | range_operator => '--', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3274 | }, @batch ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3276 | 32 | my $resp = $self->spacetrack_query_v2( | |||||||||||||||||||||||||||||||||||||||||||||
| 3277 | basicspacedata => 'query', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3278 | _sort_rest_arguments( $rest ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3279 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3280 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3281 | 32 | ▶ | $resp->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$resp->is_success or $resp->code == 418
MC/DC0%0/2
$resp->is_success or $resp->code == 418
$resp->is_success
$resp->code == 418
Truth table66%2/3
A or B
A= $resp->is_successB= $resp->code == 418
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3282 | or $resp->code() == HTTP_I_AM_A_TEAPOT | ||||||||||||||||||||||||||||||||||||||||||||||
| 3283 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3284 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3285 | 32 | $accumulator->( $self, $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3286 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3287 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3288 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3289 | 30 | ▶ | ( my $data = $accumulator->( $self ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3290 | or return HTTP::Response->new ( HTTP_NOT_FOUND, NO_RECORDS ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3291 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3292 | 30 | ▶ | ref $data | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3293 | and $data = $self->_get_json_object()->encode( $data ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3294 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3295 | 30 | ▶ | $no_execute | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3296 | and return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 3297 | HTTP_I_AM_A_TEAPOT, undef, undef, $data ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3298 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3299 | 20 | my $resp = HTTP::Response->new( HTTP_OK, COPACETIC, undef, | |||||||||||||||||||||||||||||||||||||||||||||
| 3300 | $data ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3302 | 20 | $self->_convert_content( $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3303 | 20 | $self->_add_pragmata( $resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 3304 | 'spacetrack-type' => 'orbit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3305 | 'spacetrack-source' => 'spacetrack', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3306 | 'spacetrack-interface' => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3307 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3308 | 20 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 3309 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3311 | 35 | ▶ | sub _convert_retrieve_options_to_rest { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_retrieve_options_to_rest: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3312 | 35 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 3313 | 35 | my $method = "_convert_retrieve_options_to_rest_v$self->{space_track_version}"; | |||||||||||||||||||||||||||||||||||||||||||||
| 3314 | 35 | ▶ | my $code = $self->can( $method ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3315 | or Carp::confess( "Bug - method $method() not found" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3316 | 35 | goto $code; | |||||||||||||||||||||||||||||||||||||||||||||
| 3317 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3318 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3319 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 3320 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3321 | 7 | my %rest_sort_map = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 3322 | catnum => 'NORAD_CAT_ID', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3323 | epoch => 'EPOCH', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3324 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3325 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3326 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 3327 | 35 | ▶ | sub _convert_retrieve_options_to_rest_v2 { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_retrieve_options_to_rest_v2: called CC=15 SCAR=27.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3328 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3329 | 35 | my ( $self, $opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 3330 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3331 | 35 | my %rest = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 3332 | class => 'gp', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3333 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3334 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3335 | 35 | ▶ | if ( $opt->{start_epoch} || $opt->{end_epoch} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opt->{"start_epoch"} or $opt->{"end_epoch"}
MC/DC50%1/2
$opt->{"start_epoch"} or $opt->{"end_epoch"}
$opt->{"start_epoch"}
$opt->{"end_epoch"}
Truth table66%2/3
A or B
A= $opt->{"start_epoch"}B= $opt->{"end_epoch"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3336 | 4 | $rest{EPOCH} = join '--', map { _rest_date( $opt->{$_} ) } | |||||||||||||||||||||||||||||||||||||||||||||
| 3337 | qw{ _start_epoch _end_epoch }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3338 | 4 | $rest{class} = 'gp_history'; | |||||||||||||||||||||||||||||||||||||||||||||
| 3339 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3340 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3341 | $rest{orderby} = ( $rest_sort_map{$opt->{sort} || 'catnum'} || | ||||||||||||||||||||||||||||||||||||||||||||||
| 3342 | 'NORAD_CAT_ID' ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3343 | 35 | ▶ | . ( $opt->{descending} ? ' desc' : ' asc' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%3/4
$rest_sort_map{$opt->{'sort'} or 'catnum'} || 'NORAD_CAT_ID'
$opt->{'sort'} || 'catnum'
MC/DC0%0/1
$rest_sort_map{$opt->{'sort'} or 'catnum'} || 'NORAD_CAT_ID'
$rest_sort_map{$opt->{'sort'} or 'catnum'}
MC/DC100%1/1
$opt->{'sort'} || 'catnum'
$opt->{'sort'}
Truth table50%1/2
A
A= $rest_sort_map{$opt->{'sort'} or 'catnum'}
Truth table100%2/2
A
A= $opt->{'sort'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3344 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3345 | 35 | ▶ | if ( $opt->{since_file} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3346 | 1 | $rest{FILE} = ">$opt->{since_file}"; | |||||||||||||||||||||||||||||||||||||||||||||
| 3347 | 1 | $rest{class} = 'gp_history'; | |||||||||||||||||||||||||||||||||||||||||||||
| 3348 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3349 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3350 | 35 | ▶ | if ( $opt->{status} && $opt->{status} ne 'onorbit' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt->{"status"} and $opt->{"status"} ne "onorbit"
MC/DC0%0/2
$opt->{"status"} and $opt->{"status"} ne "onorbit"
$opt->{"status"}
$opt->{"status"} ne "onorbit"
Truth table33%1/3
A and B
A= $opt->{"status"}B= $opt->{"status"} ne "onorbit"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3351 | 0 | $rest{class} = 'gp_history'; | |||||||||||||||||||||||||||||||||||||||||||||
| 3352 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3354 | 35 | foreach my $name ( | |||||||||||||||||||||||||||||||||||||||||||||
| 3355 | qw{ class format }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3356 | qw{ ECCENTRICITY FILE MEAN_MOTION OBJECT_NAME }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3357 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 3358 | defined $opt->{$name} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3359 | 210 | ▶ | and $rest{$name} = $opt->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3360 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3361 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3362 | 35 | ▶ | if ( 'legacy' eq $rest{format} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3363 | 31 | ▶ | if ( $self->{with_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3364 | 9 | $rest{format} = '3le'; | |||||||||||||||||||||||||||||||||||||||||||||
| 3365 | defined $rest{predicates} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3366 | 9 | ▶ | or $rest{predicates} = 'OBJECT_NAME,TLE_LINE1,TLE_LINE2'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3367 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 3368 | 22 | $rest{format} = 'tle'; | |||||||||||||||||||||||||||||||||||||||||||||
| 3369 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3370 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3371 | $opt->{last5} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3372 | 35 | ▶ | and $self->_deprecation_notice( qw{ option last5 } ); # v2.1 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3374 | 35 | return \%rest; | |||||||||||||||||||||||||||||||||||||||||||||
| 3375 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3376 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3377 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3378 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3379 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 3380 | 7 | my @heading_info = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 3381 | [ undef, NORAD_CAT_ID => 'Catalog Number' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3382 | [ undef, OBJECT_NAME => 'Common Name' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3383 | [ undef, OBJECT_ID => 'International Designator' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3384 | [ undef, COUNTRY => 'Country' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3385 | [ undef, LAUNCH => 'Launch Date' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3386 | [ undef, SITE => 'Launch Site' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3387 | [ undef, DECAY => 'Decay Date' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3388 | [ undef, PERIOD => 'Period' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3389 | [ undef, APOGEE => 'Apogee' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3390 | [ undef, PERIGEE => 'Perigee' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3391 | [ 'comment', COMMENT => 'Comment' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3392 | [ undef, RCSVALUE => 'RCS' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 3393 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3394 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3395 | 5 | ▶ | sub _search_heading_order { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_search_heading_order: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3396 | 5 | my ( $opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 3397 | 5 | return ( map { $_->[1] } | |||||||||||||||||||||||||||||||||||||||||||||
| 3398 | _search_heading_relevant( $opt ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3399 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3400 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3401 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3402 | 10 | ▶ | sub _search_heading_relevant { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_search_heading_relevant: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3403 | 10 | my ( $opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 3404 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 3405 | 10 | ▶ | grep { ! defined $_->[0] || $opt->{$_->[0]} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
!defined($_->[0]) || $$opt{$_->[0]}
MC/DC50%1/2
!defined($_->[0]) || $$opt{$_->[0]}
!defined($_->[0])
$$opt{$_->[0]}
Truth table66%2/3
not(A) || B
A= !defined($_->[0])B= $$opt{$_->[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3406 | @heading_info | ||||||||||||||||||||||||||||||||||||||||||||||
| 3407 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3408 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3409 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3410 | 5 | ▶ | sub _search_heading_hash_ref { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_search_heading_hash_ref: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3411 | 5 | my ( $opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 3412 | return { | ||||||||||||||||||||||||||||||||||||||||||||||
| 3413 | 5 | map { $_->[1] => $_->[2] } | |||||||||||||||||||||||||||||||||||||||||||||
| 3414 | _search_heading_relevant( $opt ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3415 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3416 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3417 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3418 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3419 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3420 | 7 | ▶ | sub _search_rest { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_search_rest: called CC=16 SCAR=28.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3421 | 50 | my ( $self, $pred, $xfrm, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 3422 | 50 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 3423 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3424 | 50 | ( my $opt, @args ) = $self->_parse_search_args( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3425 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3426 | 50 | ▶ | if ( $pred eq 'NORAD_CAT_ID' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3427 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3428 | 12 | ▶ | @args = $self->_expand_oid_list( @args ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3429 | or return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 3430 | HTTP_PRECONDITION_FAILED, NO_CAT_ID ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3431 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3432 | 12 | @args = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 3433 | _stringify_oid_list( { | ||||||||||||||||||||||||||||||||||||||||||||||
| 3434 | separator => ',', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3435 | range_operator => '--', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3436 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3437 | @args | ||||||||||||||||||||||||||||||||||||||||||||||
| 3438 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3439 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3440 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3441 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3442 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3443 | 50 | my $rest_args = $self->_convert_search_options_to_rest( $opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3444 | 50 | ▶ | if ( $opt->{tle} || 'legacy' eq $opt->{format} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opt->{"tle"} or "legacy" eq $opt->{"format"}
MC/DC0%0/2
$opt->{"tle"} or "legacy" eq $opt->{"format"}
$opt->{"tle"}
"legacy" eq $opt->{"format"}
Truth table66%2/3
A or B
A= $opt->{"tle"}B= "legacy" eq $opt->{"format"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3445 | 50 | $rest_args->{format} = 'json' | |||||||||||||||||||||||||||||||||||||||||||||
| 3446 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 3447 | 0 | $rest_args->{format} = $opt->{format}; | |||||||||||||||||||||||||||||||||||||||||||||
| 3448 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3449 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3450 | my $class = defined $rest_args->{class} ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 3451 | $rest_args->{class} : | ||||||||||||||||||||||||||||||||||||||||||||||
| 3452 | 50 | ▶ | DEFAULT_SPACE_TRACK_REST_SEARCH_CLASS; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3453 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3454 | 50 | my $accumulator = _accumulator_for( $rest_args->{format} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3455 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3456 | 50 | foreach my $search_for ( map { $xfrm->( $_, $class ) } @args ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 3457 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3458 | 50 | my $rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 3459 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 3460 | 50 | local $self->{pretty} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 3461 | 50 | $rslt = $self->__search_rest_raw( %{ $rest_args }, | |||||||||||||||||||||||||||||||||||||||||||||
| 3462 | $pred, $search_for ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3463 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3464 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3465 | $rslt->is_success() | ||||||||||||||||||||||||||||||||||||||||||||||
| 3466 | 50 | ▶ | or return $rslt; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3467 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3468 | 19 | $accumulator->( $self, $rslt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3469 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3470 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3471 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3472 | 19 | my ( $content, $data ) = $accumulator->( $self ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3473 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3474 | 19 | ▶ | if ( $opt->{tle} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3475 | defined $opt->{format} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3476 | 14 | ▶ | or $opt->{format} = 'tle'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3477 | 14 | ▶ | ARRAY_REF eq ref $data | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3478 | or Carp::croak "Format $rest_args->{format} does not support TLE retrieval"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3479 | 14 | my $ropt = _remove_search_options( $opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3480 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3481 | my $rslt = $self->retrieve( $ropt, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3482 | 14 | map { $_->{NORAD_CAT_ID} } @{ $data } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3483 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3484 | 14 | return $rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 3485 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3486 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 3487 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3488 | 5 | ▶ | if ( 'legacy' eq $opt->{format} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3489 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3490 | 5 | my $headings = _search_heading_hash_ref( $opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3491 | 5 | my @heading_order = _search_heading_order( $opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3492 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3493 | 5 | $content = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 3494 | 5 | foreach my $datum ( | |||||||||||||||||||||||||||||||||||||||||||||
| 3495 | $headings, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3496 | 5 | @{ $data } | |||||||||||||||||||||||||||||||||||||||||||||
| 3497 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 3498 | $content .= join( "\t", | ||||||||||||||||||||||||||||||||||||||||||||||
| 3499 | 12 | ▶ | map { defined $datum->{$_} ? $datum->{$_} : '' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3500 | @heading_order | ||||||||||||||||||||||||||||||||||||||||||||||
| 3501 | ) . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3502 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3503 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3504 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3505 | 5 | my $rslt = HTTP::Response->new( HTTP_OK, undef, undef, $content ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3506 | 5 | $self->_add_pragmata( $rslt, | |||||||||||||||||||||||||||||||||||||||||||||
| 3507 | 'spacetrack-type' => 'search', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3508 | 'spacetrack-source' => 'spacetrack', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3509 | 'spacetrack-interface' => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3510 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3511 | wantarray | ||||||||||||||||||||||||||||||||||||||||||||||
| 3512 | 5 | ▶ | and $data | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
wantarray and $data
MC/DC0%0/2
wantarray and $data
wantarray
$data
Truth table33%1/3
A and B
A= wantarrayB= $data
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3513 | and return ( $rslt, $data ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3514 | 5 | return $rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 3515 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3516 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3517 | # Note - if we're doing the tab output, the names and order are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3518 | # Catalog Number: NORAD_CAT_ID | ||||||||||||||||||||||||||||||||||||||||||||||
| 3519 | # Common Name: OBJECT_NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 3520 | # International Designator: OBJECT_ID | ||||||||||||||||||||||||||||||||||||||||||||||
| 3521 | # Country: COUNTRY | ||||||||||||||||||||||||||||||||||||||||||||||
| 3522 | # Launch Date: LAUNCH (yyyy-mm-dd) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3523 | # Launch Site: SITE | ||||||||||||||||||||||||||||||||||||||||||||||
| 3524 | # Decay Date: DECAY | ||||||||||||||||||||||||||||||||||||||||||||||
| 3525 | # Period: PERIOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 3526 | # Incl.: INCLINATION | ||||||||||||||||||||||||||||||||||||||||||||||
| 3527 | # Apogee: APOGEE | ||||||||||||||||||||||||||||||||||||||||||||||
| 3528 | # Perigee: PERIGEE | ||||||||||||||||||||||||||||||||||||||||||||||
| 3529 | # RCS: RCSVALUE | ||||||||||||||||||||||||||||||||||||||||||||||
| 3530 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3531 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3532 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3533 | 50 | ▶ | sub __search_rest_raw { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__search_rest_raw: called CC=8 SCAR=22.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3534 | 50 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 3535 | 50 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 3536 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3537 | 50 | ▶ | %args | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3538 | or return HTTP::Response->new( HTTP_PRECONDITION_FAILED, NO_CAT_ID ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3539 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3540 | exists $args{class} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3541 | 50 | ▶ | or $args{class} = DEFAULT_SPACE_TRACK_REST_SEARCH_CLASS; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3542 | $args{class} ne 'satcat' | ||||||||||||||||||||||||||||||||||||||||||||||
| 3543 | or exists $args{CURRENT} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3544 | 50 | ▶ | or $args{CURRENT} = 'Y'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{"class"} ne "satcat" or exists $args{"CURRENT"}
MC/DC0%0/2
$args{"class"} ne "satcat" or exists $args{"CURRENT"}
$args{"class"} ne "satcat"
exists $args{"CURRENT"}
Truth table33%1/3
A or B
A= $args{"class"} ne "satcat"B= exists $args{"CURRENT"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3545 | exists $args{format} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3546 | 50 | ▶ | or $args{format} = 'json'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3547 | exists $args{predicates} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3548 | 50 | ▶ | or $args{predicates} = 'all'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3549 | exists $args{orderby} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3550 | 50 | ▶ | or $args{orderby} = 'NORAD_CAT_ID asc'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3551 | # exists $args{limit} | ||||||||||||||||||||||||||||||||||||||||||||||
| 3552 | # or $args{limit} = 1000; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3553 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3554 | 50 | my $resp = $self->spacetrack_query_v2( | |||||||||||||||||||||||||||||||||||||||||||||
| 3555 | basicspacedata => 'query', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3556 | _sort_rest_arguments( \%args ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 3557 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3558 | # $resp->content( $content ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3559 | # $self->_convert_content( $resp ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3560 | 50 | $self->_add_pragmata( $resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 3561 | 'spacetrack-type' => 'orbit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3562 | 'spacetrack-source' => 'spacetrack', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3563 | 'spacetrack-interface' => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3564 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3565 | 50 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 3566 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3567 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3568 | =for html <a name="search_date"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 3569 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3570 | =item $resp = $st->search_date (date ...) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3571 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3572 | This method searches the Space Track database for objects launched on | ||||||||||||||||||||||||||||||||||||||||||||||
| 3573 | the given date. The date is specified as year-month-day, with any | ||||||||||||||||||||||||||||||||||||||||||||||
| 3574 | non-digit being legal as the separator. You can omit -day or specify it | ||||||||||||||||||||||||||||||||||||||||||||||
| 3575 | as 0 to get all launches for the given month. You can omit -month (or | ||||||||||||||||||||||||||||||||||||||||||||||
| 3576 | specify it as 0) as well to get all launches for the given year. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3577 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3578 | A Space Track username and password are required to use this method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3579 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3580 | You can specify options for the search as either command-type options | ||||||||||||||||||||||||||||||||||||||||||||||
| 3581 | (e.g. C<< $st->search_date (-status => 'onorbit', ...) >>) or as a | ||||||||||||||||||||||||||||||||||||||||||||||
| 3582 | leading hash reference (e.g. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3583 | C<< $st->search_date ({status => onorbit}, ...) >>). If you specify the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3584 | hash reference, option names must be specified in full, without the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3585 | leading '-', and the argument list will not be parsed for command-type | ||||||||||||||||||||||||||||||||||||||||||||||
| 3586 | options. Options that take multiple values (i.e. 'exclude') must have | ||||||||||||||||||||||||||||||||||||||||||||||
| 3587 | their values specified as a hash reference, even if you only specify one | ||||||||||||||||||||||||||||||||||||||||||||||
| 3588 | value - or none at all. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3589 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3590 | If you specify command-type options, they may be abbreviated, as long as | ||||||||||||||||||||||||||||||||||||||||||||||
| 3591 | the abbreviation is unique. Errors in either sort of specification | ||||||||||||||||||||||||||||||||||||||||||||||
| 3592 | result in an exception being thrown. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3593 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3594 | In addition to the options available for C<retrieve()>, the following | ||||||||||||||||||||||||||||||||||||||||||||||
| 3595 | options may be specified: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3596 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3597 | -exclude | ||||||||||||||||||||||||||||||||||||||||||||||
| 3598 | specifies the types of bodies to exclude. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 3599 | value is one or more of 'payload', 'debris', 'rocket', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3600 | 'unknown', 'tba', or 'other'. If you specify this as a | ||||||||||||||||||||||||||||||||||||||||||||||
| 3601 | command-line option you may either specify this more | ||||||||||||||||||||||||||||||||||||||||||||||
| 3602 | than once or specify the values comma-separated. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3603 | -include | ||||||||||||||||||||||||||||||||||||||||||||||
| 3604 | specifies the types of bodies to include. The possible | ||||||||||||||||||||||||||||||||||||||||||||||
| 3605 | values are the same as for -exclude. If you specify a | ||||||||||||||||||||||||||||||||||||||||||||||
| 3606 | given body as both included and excluded it is included. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3607 | -rcs | ||||||||||||||||||||||||||||||||||||||||||||||
| 3608 | used to specify that the radar cross-section returned | ||||||||||||||||||||||||||||||||||||||||||||||
| 3609 | by the search was to be appended to the name, in the form | ||||||||||||||||||||||||||||||||||||||||||||||
| 3610 | --rcs radar_cross_section. Beginning with version 0.086_02 | ||||||||||||||||||||||||||||||||||||||||||||||
| 3611 | it does nothing, since as of August 18 2014 Space Track | ||||||||||||||||||||||||||||||||||||||||||||||
| 3612 | no longer provides quantitative RCS data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3613 | -status | ||||||||||||||||||||||||||||||||||||||||||||||
| 3614 | specifies the desired status of the returned body (or | ||||||||||||||||||||||||||||||||||||||||||||||
| 3615 | bodies). Must be 'onorbit', 'decayed', or 'all'. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 3616 | default is 'onorbit'. Note that this option represents | ||||||||||||||||||||||||||||||||||||||||||||||
| 3617 | status at the time the search was done; you can not combine | ||||||||||||||||||||||||||||||||||||||||||||||
| 3618 | it with the retrieve() date options to find bodies onorbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 3619 | as of a given date in the past. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3620 | -tle | ||||||||||||||||||||||||||||||||||||||||||||||
| 3621 | specifies that you want TLE data retrieved for all | ||||||||||||||||||||||||||||||||||||||||||||||
| 3622 | bodies that satisfy the search criteria. This is | ||||||||||||||||||||||||||||||||||||||||||||||
| 3623 | true by default, but may be negated by specifying | ||||||||||||||||||||||||||||||||||||||||||||||
| 3624 | -notle ( or { tle => 0 } ). If negated, the content | ||||||||||||||||||||||||||||||||||||||||||||||
| 3625 | of the response object is the results of the search, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3626 | one line per body found, with the fields tab- | ||||||||||||||||||||||||||||||||||||||||||||||
| 3627 | delimited. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3628 | -comment | ||||||||||||||||||||||||||||||||||||||||||||||
| 3629 | specifies that you want the comment field. This will | ||||||||||||||||||||||||||||||||||||||||||||||
| 3630 | not appear in the TLE data, but in the satcat data | ||||||||||||||||||||||||||||||||||||||||||||||
| 3631 | returned in array context, or if C<-notle> is | ||||||||||||||||||||||||||||||||||||||||||||||
| 3632 | specified. The default is C<-nocomment> for backward | ||||||||||||||||||||||||||||||||||||||||||||||
| 3633 | compatibility. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3634 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3635 | The C<-rcs> option does not work with all values of C<-format>. An | ||||||||||||||||||||||||||||||||||||||||||||||
| 3636 | exception will be thrown unless C<-format> is C<'tle'>, C<'3le'>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3637 | C<'legacy'>, or C<'json'>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3638 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3639 | Examples: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3640 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3641 | search_date (-status => 'onorbit', -exclude => | ||||||||||||||||||||||||||||||||||||||||||||||
| 3642 | 'debris,rocket', '2005-12-25'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3643 | search_date (-exclude => 'debris', | ||||||||||||||||||||||||||||||||||||||||||||||
| 3644 | -exclude => 'rocket', '2005/12/25'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3645 | search_date ({exclude => ['debris', 'rocket']}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3646 | '2005-12-25'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3647 | search_date ({exclude => 'debris,rocket'}, # INVALID! | ||||||||||||||||||||||||||||||||||||||||||||||
| 3648 | '2005-12-25'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3649 | search_date ( '-notle', '2005-12-25' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 3650 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3651 | The C<-exclude> option is implemented in terms of the C<OBJECT_TYPE> | ||||||||||||||||||||||||||||||||||||||||||||||
| 3652 | predicate, which is one of the values C<'PAYLOAD'>, C<'ROCKET BODY'>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3653 | C<'DEBRIS'>, C<'UNKNOWN'>, C<'TBA'>, or C<'OTHER'>. It works by | ||||||||||||||||||||||||||||||||||||||||||||||
| 3654 | selecting all values other than the ones specifically excluded. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 3655 | C<'TBA'> status was introduced October 1 2013, supposedly replacing | ||||||||||||||||||||||||||||||||||||||||||||||
| 3656 | C<'UNKNOWN'>, but I have retained both. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3657 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3658 | This method implicitly calls the C<login()> method if the session cookie | ||||||||||||||||||||||||||||||||||||||||||||||
| 3659 | is missing or expired. If C<login()> fails, you will get the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3660 | HTTP::Response from C<login()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3661 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3662 | What you get on success depends on the value specified for the -tle | ||||||||||||||||||||||||||||||||||||||||||||||
| 3663 | option. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3664 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3665 | Unless you explicitly specified C<-notle> (or C<< { tle => 0 } >>), this | ||||||||||||||||||||||||||||||||||||||||||||||
| 3666 | method returns an HTTP::Response object whose content is the relevant | ||||||||||||||||||||||||||||||||||||||||||||||
| 3667 | element sets. It will also have the following headers set: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3668 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3669 | Pragma: spacetrack-type = orbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 3670 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 3671 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3672 | These can be accessed by C<< $st->content_type( $resp ) >> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 3673 | C<< $st->content_source( $resp ) >> respectively. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3674 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3675 | If you explicitly specified C<-notle> (or C<< { tle => 0 } >>), this | ||||||||||||||||||||||||||||||||||||||||||||||
| 3676 | method returns an HTTP::Response object whose content is in the format | ||||||||||||||||||||||||||||||||||||||||||||||
| 3677 | specified by the C<-format> retrieval option (q.v.). If the format is | ||||||||||||||||||||||||||||||||||||||||||||||
| 3678 | C<'legacy'> (the default if C<-json> is not specified) the content | ||||||||||||||||||||||||||||||||||||||||||||||
| 3679 | mimics what was returned under the version 1 interface; that is, it is | ||||||||||||||||||||||||||||||||||||||||||||||
| 3680 | the results of the relevant search, one line per object found. Within a | ||||||||||||||||||||||||||||||||||||||||||||||
| 3681 | line the fields are tab-delimited, and occur in the same order as the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3682 | underlying web page. The first line of the content is the header lines | ||||||||||||||||||||||||||||||||||||||||||||||
| 3683 | from the underlying web page. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3684 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3685 | The returned object will also have the following headers set if | ||||||||||||||||||||||||||||||||||||||||||||||
| 3686 | C<-notle> is specified: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3687 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3688 | Pragma: spacetrack-type = search | ||||||||||||||||||||||||||||||||||||||||||||||
| 3689 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 3690 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3691 | If you call this method in list context, the first element of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3692 | returned object is the aforementioned HTTP::Response object, and the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3693 | second is a reference to an array containing the search results. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 3694 | first element is a reference to an array containing the header lines | ||||||||||||||||||||||||||||||||||||||||||||||
| 3695 | from the web page. Subsequent elements are references to arrays | ||||||||||||||||||||||||||||||||||||||||||||||
| 3696 | containing the actual search results. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3697 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3698 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 3699 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3700 | 7 | *_search_date_opts = \&_get_search_options; | |||||||||||||||||||||||||||||||||||||||||||||
| 3701 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3702 | 12 | ▶ | sub search_date { ## no critic (RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_date: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3703 | 12 | splice @_, 1, 0, LAUNCH => \&_format_launch_date_rest; | |||||||||||||||||||||||||||||||||||||||||||||
| 3704 | 12 | goto &_search_rest; | |||||||||||||||||||||||||||||||||||||||||||||
| 3705 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3706 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3707 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3708 | =for html <a name="search_decay"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 3709 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3710 | =item $resp = $st->search_decay (decay ...) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3711 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3712 | This method searches the Space Track database for objects decayed on | ||||||||||||||||||||||||||||||||||||||||||||||
| 3713 | the given date. The date is specified as year-month-day, with any | ||||||||||||||||||||||||||||||||||||||||||||||
| 3714 | non-digit being legal as the separator. You can omit -day or specify it | ||||||||||||||||||||||||||||||||||||||||||||||
| 3715 | as 0 to get all decays for the given month. You can omit -month (or | ||||||||||||||||||||||||||||||||||||||||||||||
| 3716 | specify it as 0) as well to get all decays for the given year. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3717 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3718 | The options are the same as for C<search_date()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3719 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3720 | A Space Track username and password are required to use this method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3721 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3722 | What you get on success depends on the value specified for the -tle | ||||||||||||||||||||||||||||||||||||||||||||||
| 3723 | option. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3724 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3725 | Unless you explicitly specified C<-notle> (or C<< { tle => 0 } >>), this | ||||||||||||||||||||||||||||||||||||||||||||||
| 3726 | method returns an HTTP::Response object whose content is the relevant | ||||||||||||||||||||||||||||||||||||||||||||||
| 3727 | element sets. It will also have the following headers set: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3728 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3729 | Pragma: spacetrack-type = orbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 3730 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 3731 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3732 | These can be accessed by C<< $st->content_type( $resp ) >> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 3733 | C<< $st->content_source( $resp ) >> respectively. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3734 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3735 | If you explicitly specified C<-notle> (or C<< { tle => 0 } >>), this | ||||||||||||||||||||||||||||||||||||||||||||||
| 3736 | method returns an HTTP::Response object whose content is the results of | ||||||||||||||||||||||||||||||||||||||||||||||
| 3737 | the relevant search, one line per object found. Within a line the fields | ||||||||||||||||||||||||||||||||||||||||||||||
| 3738 | are tab-delimited, and occur in the same order as the underlying web | ||||||||||||||||||||||||||||||||||||||||||||||
| 3739 | page. The first line of the content is the header lines from the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3740 | underlying web page. It will also have the following headers set: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3741 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3742 | Pragma: spacetrack-type = search | ||||||||||||||||||||||||||||||||||||||||||||||
| 3743 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 3744 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3745 | If you call this method in list context, the first element of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3746 | returned object is the aforementioned HTTP::Response object, and the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3747 | second is a reference to an array containing the search results. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 3748 | first element is a reference to an array containing the header lines | ||||||||||||||||||||||||||||||||||||||||||||||
| 3749 | from the web page. Subsequent elements are references to arrays | ||||||||||||||||||||||||||||||||||||||||||||||
| 3750 | containing the actual search results. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3751 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3752 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 3753 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3754 | 7 | *_search_decay_opts = \&_get_search_options; | |||||||||||||||||||||||||||||||||||||||||||||
| 3755 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3756 | 2 | ▶ | sub search_decay { ## no critic (RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_decay: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3757 | 2 | splice @_, 1, 0, DECAY => \&_format_launch_date_rest; | |||||||||||||||||||||||||||||||||||||||||||||
| 3758 | 2 | goto &_search_rest; | |||||||||||||||||||||||||||||||||||||||||||||
| 3759 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3760 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3761 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3762 | =for html <a name="search_id"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 3763 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3764 | =item $resp = $st->search_id (id ...) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3765 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3766 | This method searches the Space Track database for objects having the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3767 | given international IDs. The international ID is the last two digits of | ||||||||||||||||||||||||||||||||||||||||||||||
| 3768 | the launch year (in the range 1957 through 2056), the three-digit | ||||||||||||||||||||||||||||||||||||||||||||||
| 3769 | sequence number of the launch within the year (with leading zeros as | ||||||||||||||||||||||||||||||||||||||||||||||
| 3770 | needed), and the piece (A through ZZZ, with A typically being the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3771 | payload). You can omit the piece and get all pieces of that launch, or | ||||||||||||||||||||||||||||||||||||||||||||||
| 3772 | omit both the piece and the launch number and get all launches for the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3773 | year. There is no mechanism to restrict the search to a given on-orbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 3774 | status, or to filter out debris or rocket bodies. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3775 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3776 | The options are the same as for C<search_date()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3777 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3778 | A Space Track username and password are required to use this method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3779 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3780 | This method implicitly calls the C<login()> method if the session cookie | ||||||||||||||||||||||||||||||||||||||||||||||
| 3781 | is missing or expired. If C<login()> fails, you will get the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3782 | HTTP::Response from C<login()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3783 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3784 | What you get on success depends on the value specified for the C<-tle> | ||||||||||||||||||||||||||||||||||||||||||||||
| 3785 | option. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3786 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3787 | Unless you explicitly specified C<-notle> (or C<< { tle => 0 } >>), this | ||||||||||||||||||||||||||||||||||||||||||||||
| 3788 | method returns an HTTP::Response object whose content is the relevant | ||||||||||||||||||||||||||||||||||||||||||||||
| 3789 | element sets. It will also have the following headers set: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3790 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3791 | Pragma: spacetrack-type = orbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 3792 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 3793 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3794 | These can be accessed by C<< $st->content_type( $resp ) >> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 3795 | C<< $st->content_source( $resp ) >> respectively. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3796 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3797 | If you explicitly specified C<-notle> (or C<< { tle => 0 } >>), this | ||||||||||||||||||||||||||||||||||||||||||||||
| 3798 | method returns an HTTP::Response object whose content is the results of | ||||||||||||||||||||||||||||||||||||||||||||||
| 3799 | the relevant search, one line per object found. Within a line the fields | ||||||||||||||||||||||||||||||||||||||||||||||
| 3800 | are tab-delimited, and occur in the same order as the underlying web | ||||||||||||||||||||||||||||||||||||||||||||||
| 3801 | page. The first line of the content is the header lines from the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3802 | underlying web page. It will also have the following headers set: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3803 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3804 | Pragma: spacetrack-type = search | ||||||||||||||||||||||||||||||||||||||||||||||
| 3805 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 3806 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3807 | If you call this method in list context, the first element of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3808 | returned object is the aforementioned HTTP::Response object, and the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3809 | second is a reference to an array containing the search results. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 3810 | first element is a reference to an array containing the header lines | ||||||||||||||||||||||||||||||||||||||||||||||
| 3811 | from the web page. Subsequent elements are references to arrays | ||||||||||||||||||||||||||||||||||||||||||||||
| 3812 | containing the actual search results. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3813 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3814 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 3815 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3816 | 7 | *_search_id_opts = \&_get_search_options; | |||||||||||||||||||||||||||||||||||||||||||||
| 3817 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3818 | 14 | ▶ | sub search_id { ## no critic (RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3819 | 14 | splice @_, 1, 0, OBJECT_ID => \&_format_international_id_rest; | |||||||||||||||||||||||||||||||||||||||||||||
| 3820 | 14 | goto &_search_rest; | |||||||||||||||||||||||||||||||||||||||||||||
| 3821 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3822 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3823 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3824 | =for html <a name="search_name"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 3825 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3826 | =item $resp = $st->search_name (name ...) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3827 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3828 | This method searches the Space Track database for the named objects. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3829 | Matches are case-insensitive and all matches are returned. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3830 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3831 | The options are the same as for C<search_date()>. The C<-status> option | ||||||||||||||||||||||||||||||||||||||||||||||
| 3832 | is known to work, but I am not sure about the efficacy the C<-exclude> | ||||||||||||||||||||||||||||||||||||||||||||||
| 3833 | option. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3834 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3835 | A Space Track username and password are required to use this method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3836 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3837 | This method implicitly calls the C<login()> method if the session cookie | ||||||||||||||||||||||||||||||||||||||||||||||
| 3838 | is missing or expired. If C<login()> fails, you will get the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3839 | HTTP::Response from C<login()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3840 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3841 | What you get on success depends on the value specified for the -tle | ||||||||||||||||||||||||||||||||||||||||||||||
| 3842 | option. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3843 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3844 | Unless you explicitly specified C<-notle> (or C<< { tle => 0 } >>), this | ||||||||||||||||||||||||||||||||||||||||||||||
| 3845 | method returns an HTTP::Response object whose content is the relevant | ||||||||||||||||||||||||||||||||||||||||||||||
| 3846 | element sets. It will also have the following headers set: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3847 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3848 | Pragma: spacetrack-type = orbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 3849 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 3850 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3851 | These can be accessed by C<< $st->content_type( $resp ) >> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 3852 | C<< $st->content_source( $resp ) >> respectively. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3853 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3854 | If you explicitly specified C<-notle> (or C<< { tle => 0 } >>), this | ||||||||||||||||||||||||||||||||||||||||||||||
| 3855 | method returns an HTTP::Response object whose content is the results of | ||||||||||||||||||||||||||||||||||||||||||||||
| 3856 | the relevant search, one line per object found. Within a line the fields | ||||||||||||||||||||||||||||||||||||||||||||||
| 3857 | are tab-delimited, and occur in the same order as the underlying web | ||||||||||||||||||||||||||||||||||||||||||||||
| 3858 | page. The first line of the content is the header lines from the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3859 | underlying web page. It will also have the following headers set: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3860 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3861 | Pragma: spacetrack-type = search | ||||||||||||||||||||||||||||||||||||||||||||||
| 3862 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 3863 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3864 | If you call this method in list context, the first element of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3865 | returned object is the aforementioned HTTP::Response object, and the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3866 | second is a reference to an array containing the search results. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 3867 | first element is a reference to an array containing the header lines | ||||||||||||||||||||||||||||||||||||||||||||||
| 3868 | from the web page. Subsequent elements are references to arrays | ||||||||||||||||||||||||||||||||||||||||||||||
| 3869 | containing the actual search results. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3870 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3871 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 3872 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3873 | 7 | *_search_name_opts = \&_get_search_options; | |||||||||||||||||||||||||||||||||||||||||||||
| 3874 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3875 | 10 | ▶ | sub search_name { ## no critic (RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3876 | 10 | ▶ | splice @_, 1, 0, OBJECT_NAME => sub { return "~~$_[0]" }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3877 | 10 | goto &_search_rest; | |||||||||||||||||||||||||||||||||||||||||||||
| 3878 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3879 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3880 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3881 | =for html <a name="search_oid"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 3882 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3883 | =item $resp = $st->search_oid (name ...) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3884 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3885 | This method searches the Space Track database for the given Space Track | ||||||||||||||||||||||||||||||||||||||||||||||
| 3886 | IDs (also known as OIDs, hence the method name). | ||||||||||||||||||||||||||||||||||||||||||||||
| 3887 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3888 | B<Note> that in effect this is just a stupid, inefficient version of | ||||||||||||||||||||||||||||||||||||||||||||||
| 3889 | C<retrieve()>, which does not understand ranges. Unless you | ||||||||||||||||||||||||||||||||||||||||||||||
| 3890 | assert C<-notle> or call it in list context to get the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3891 | search data, you should simply call | ||||||||||||||||||||||||||||||||||||||||||||||
| 3892 | C<retrieve()> instead. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3893 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3894 | In addition to the options available for C<retrieve()>, the following | ||||||||||||||||||||||||||||||||||||||||||||||
| 3895 | option may be specified: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3896 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3897 | rcs | ||||||||||||||||||||||||||||||||||||||||||||||
| 3898 | Used to specify that the radar cross-section returned by | ||||||||||||||||||||||||||||||||||||||||||||||
| 3899 | the search is to be appended to the name, in the form | ||||||||||||||||||||||||||||||||||||||||||||||
| 3900 | --rcs radar_cross_section. Starting with version 0.086_02 | ||||||||||||||||||||||||||||||||||||||||||||||
| 3901 | it does nothing, since as of August 18 2014 Space Track | ||||||||||||||||||||||||||||||||||||||||||||||
| 3902 | no longer provides quantitative RCS data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3903 | tle | ||||||||||||||||||||||||||||||||||||||||||||||
| 3904 | specifies that you want TLE data retrieved for all | ||||||||||||||||||||||||||||||||||||||||||||||
| 3905 | bodies that satisfy the search criteria. This is | ||||||||||||||||||||||||||||||||||||||||||||||
| 3906 | true by default, but may be negated by specifying | ||||||||||||||||||||||||||||||||||||||||||||||
| 3907 | -notle ( or { tle => 0 } ). If negated, the content | ||||||||||||||||||||||||||||||||||||||||||||||
| 3908 | of the response object is the results of the search, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3909 | one line per body found, with the fields tab- | ||||||||||||||||||||||||||||||||||||||||||||||
| 3910 | delimited. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3911 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3912 | If you specify C<-notle>, all other options are ignored, except for | ||||||||||||||||||||||||||||||||||||||||||||||
| 3913 | C<-descending>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3914 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3915 | A Space Track username and password are required to use this method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3916 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3917 | This method implicitly calls the C<login()> method if the session cookie | ||||||||||||||||||||||||||||||||||||||||||||||
| 3918 | is missing or expired. If C<login()> fails, you will get the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3919 | HTTP::Response from C<login()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3920 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3921 | What you get on success depends on the value specified for the -tle | ||||||||||||||||||||||||||||||||||||||||||||||
| 3922 | option. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3923 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3924 | Unless you explicitly specified C<-notle> (or C<< { tle => 0 } >>), this | ||||||||||||||||||||||||||||||||||||||||||||||
| 3925 | method returns an HTTP::Response object whose content is the relevant | ||||||||||||||||||||||||||||||||||||||||||||||
| 3926 | element sets. It will also have the following headers set: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3927 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3928 | Pragma: spacetrack-type = orbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 3929 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 3930 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3931 | If the C<content_type()> method returns C<'box_score'>, you can expect | ||||||||||||||||||||||||||||||||||||||||||||||
| 3932 | a content-source value of C<'spacetrack'>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3933 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3934 | If you explicitly specified C<-notle> (or C<< { tle => 0 } >>), this | ||||||||||||||||||||||||||||||||||||||||||||||
| 3935 | method returns an HTTP::Response object whose content is the results of | ||||||||||||||||||||||||||||||||||||||||||||||
| 3936 | the relevant search, one line per object found. Within a line the fields | ||||||||||||||||||||||||||||||||||||||||||||||
| 3937 | are tab-delimited, and occur in the same order as the underlying web | ||||||||||||||||||||||||||||||||||||||||||||||
| 3938 | page. The first line of the content is the header lines from the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3939 | underlying web page. It will also have the following headers set: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3940 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3941 | Pragma: spacetrack-type = search | ||||||||||||||||||||||||||||||||||||||||||||||
| 3942 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 3943 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3944 | If you call this method in list context, the first element of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3945 | returned object is the aforementioned HTTP::Response object, and the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3946 | second is a reference to an array containing the search results. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 3947 | first element is a reference to an array containing the header lines | ||||||||||||||||||||||||||||||||||||||||||||||
| 3948 | from the web page. Subsequent elements are references to arrays | ||||||||||||||||||||||||||||||||||||||||||||||
| 3949 | containing the actual search results. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3950 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3951 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 3952 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3953 | 7 | *_search_oid_opts = \&_get_search_options; | |||||||||||||||||||||||||||||||||||||||||||||
| 3954 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3955 | 12 | ▶ | sub search_oid { ## no critic (RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_oid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3956 | ## my ( $self, @args ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3957 | 12 | ▶ | splice @_, 1, 0, NORAD_CAT_ID => sub { return $_[0] }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3958 | 12 | goto &_search_rest; | |||||||||||||||||||||||||||||||||||||||||||||
| 3959 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3960 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3961 | 1 | ▶ | sub _check_range { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_range: called CC=4 SCAR=15.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3962 | 1 | my ( $self, $lo, $hi ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 3963 | 1 | ▶ | ($lo, $hi) = ($hi, $lo) if $lo > $hi; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3964 | 1 | ▶ | $lo or $lo = 1; # 0 is illegal | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3965 | 1 | ▶ | $hi - $lo >= $self->{max_range} and do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3966 | 0 | Carp::carp <<"EOD"; | |||||||||||||||||||||||||||||||||||||||||||||
| 3967 | Warning - Range $lo-$hi ignored because it is greater than the | ||||||||||||||||||||||||||||||||||||||||||||||
| 3968 | currently-set maximum of $self->{max_range}. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3969 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 3970 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 3971 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3972 | 1 | return ( $lo, $hi ); | |||||||||||||||||||||||||||||||||||||||||||||
| 3973 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 3974 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3975 | =for html <a name="set"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 3976 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3977 | =item $st->set ( ... ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3978 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3979 | This is the mutator method for the object. It can be called explicitly, | ||||||||||||||||||||||||||||||||||||||||||||||
| 3980 | but other methods as noted may call it implicitly also. It croaks if | ||||||||||||||||||||||||||||||||||||||||||||||
| 3981 | you give it an odd number of arguments, or if given an attribute that | ||||||||||||||||||||||||||||||||||||||||||||||
| 3982 | either does not exist or cannot be set. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3983 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3984 | For the convenience of the shell method we return a HTTP::Response | ||||||||||||||||||||||||||||||||||||||||||||||
| 3985 | object with a success status if all goes well. But if we encounter an | ||||||||||||||||||||||||||||||||||||||||||||||
| 3986 | error we croak. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3987 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3988 | See L</Attributes> for the names and functions of the attributes. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3989 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3990 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 3991 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3992 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 3993 | 0 | ▶ | sub _readline_complete_command_set { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readline_complete_command_set: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3994 | # my ( $self, $text, $line, $start, $cmd_line ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3995 | 0 | my ( undef, undef, undef, undef, $cmd_line ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 3996 | 0 | ▶ | @{ $cmd_line } % 2 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3997 | or return; # Can't complete arguments | ||||||||||||||||||||||||||||||||||||||||||||||
| 3998 | 0 | goto &_readline_complete_command_get; | |||||||||||||||||||||||||||||||||||||||||||||
| 3999 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4000 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4001 | 46 | ▶ | sub set { ## no critic (ProhibitAmbiguousNames) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4002 | 46 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4003 | 46 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 4004 | 46 | ▶ | while ( @args > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4005 | 52 | my $name = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||
| 4006 | Carp::croak "Attribute $name may not be set. Legal attributes are ", | ||||||||||||||||||||||||||||||||||||||||||||||
| 4007 | join (', ', sort keys %mutator), ".\n" | ||||||||||||||||||||||||||||||||||||||||||||||
| 4008 | 52 | ▶ | unless $mutator{$name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4009 | 52 | my $value = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 4010 | 52 | $mutator{$name}->( $self, $name, $value, \@args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4011 | 52 | shift @args; | |||||||||||||||||||||||||||||||||||||||||||||
| 4012 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4013 | @args | ||||||||||||||||||||||||||||||||||||||||||||||
| 4014 | 46 | ▶ | and Carp::croak __PACKAGE__, "->set() specifies no value for @args"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4015 | 46 | my $resp = HTTP::Response->new( HTTP_OK, COPACETIC, undef, COPACETIC ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4016 | 46 | $self->_add_pragmata( $resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 4017 | 'spacetrack-type' => 'set', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4018 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4019 | 46 | $self->__dump_response( $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4020 | 46 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 4021 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4022 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4023 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4024 | =for html <a name="shell"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 4025 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4026 | =item $st->shell () | ||||||||||||||||||||||||||||||||||||||||||||||
| 4027 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4028 | This method implements a simple shell. Any public method name except | ||||||||||||||||||||||||||||||||||||||||||||||
| 4029 | 'new' or 'shell' is a command, and its arguments if any are parameters. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4030 | We use L<Text::ParseWords|Text::ParseWords> to parse the line, and blank | ||||||||||||||||||||||||||||||||||||||||||||||
| 4031 | lines or lines beginning with a hash mark ('#') are ignored. Input is | ||||||||||||||||||||||||||||||||||||||||||||||
| 4032 | via Term::ReadLine if that is available. If not, we do the best we can. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4033 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4034 | We also recognize 'bye' and 'exit' as commands, which terminate the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4035 | method. In addition, 'show' is recognized as a synonym for 'get', and | ||||||||||||||||||||||||||||||||||||||||||||||
| 4036 | 'get' (or 'show') without arguments is special-cased to list all | ||||||||||||||||||||||||||||||||||||||||||||||
| 4037 | attribute names and their values. Attributes listed without a value have | ||||||||||||||||||||||||||||||||||||||||||||||
| 4038 | the undefined value. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4039 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4040 | There are also a couple meta-commands, that in effect wrap other | ||||||||||||||||||||||||||||||||||||||||||||||
| 4041 | commands. These are specified before the command, and can (depending on | ||||||||||||||||||||||||||||||||||||||||||||||
| 4042 | the meta-command) have effect either right before the command is | ||||||||||||||||||||||||||||||||||||||||||||||
| 4043 | executed, right after it is executed, or both. If more than one | ||||||||||||||||||||||||||||||||||||||||||||||
| 4044 | meta-command is specified, the before-actions take place in the order | ||||||||||||||||||||||||||||||||||||||||||||||
| 4045 | specified, and the after-actions in the reverse of the order specified. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4046 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4047 | The 'time' meta-command times the command, and writes the timing to | ||||||||||||||||||||||||||||||||||||||||||||||
| 4048 | standard error before any output from the command is written. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4049 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4050 | The 'olist' meta-command turns TLE data into an observing list. This | ||||||||||||||||||||||||||||||||||||||||||||||
| 4051 | only affects results with C<spacetrack-type> of C<'orbit'>. If the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4052 | content is affected, the C<spacetrack-type> will be changed to | ||||||||||||||||||||||||||||||||||||||||||||||
| 4053 | C<'observing-list'>. This meta-command is experimental, and may change | ||||||||||||||||||||||||||||||||||||||||||||||
| 4054 | function or be retracted. It is unsupported when applied to commands | ||||||||||||||||||||||||||||||||||||||||||||||
| 4055 | that do not return TLE data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4056 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4057 | For commands that produce output, we allow a sort of pseudo-redirection | ||||||||||||||||||||||||||||||||||||||||||||||
| 4058 | of the output to a file, using the syntax ">filename" or ">>filename". | ||||||||||||||||||||||||||||||||||||||||||||||
| 4059 | If the ">" is by itself the next argument is the filename. In addition, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4060 | we do pseudo-tilde expansion by replacing a leading tilde with the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4061 | contents of environment variable HOME. Redirection can occur anywhere | ||||||||||||||||||||||||||||||||||||||||||||||
| 4062 | on the line. For example, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4063 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4064 | SpaceTrack> catalog special >special.txt | ||||||||||||||||||||||||||||||||||||||||||||||
| 4065 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4066 | sends the "Special Interest Satellites" to file special.txt. Line | ||||||||||||||||||||||||||||||||||||||||||||||
| 4067 | terminations in the file should be appropriate to your OS. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4068 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4069 | Redirections will not be recognized as such if quoted or escaped. That | ||||||||||||||||||||||||||||||||||||||||||||||
| 4070 | is, both C<< >foo >> and C<< >'foo' >> (without the double quotes) are | ||||||||||||||||||||||||||||||||||||||||||||||
| 4071 | redirections to file F<foo>, but both "C<< '>foo' >>" and C<< \>foo >> | ||||||||||||||||||||||||||||||||||||||||||||||
| 4072 | are arguments whose value is C<< >foo >>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4073 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4074 | This method can also be called as a subroutine - i.e. as | ||||||||||||||||||||||||||||||||||||||||||||||
| 4075 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4076 | Astro::SpaceTrack::shell (...) | ||||||||||||||||||||||||||||||||||||||||||||||
| 4077 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4078 | Whether called as a method or as a subroutine, each argument passed | ||||||||||||||||||||||||||||||||||||||||||||||
| 4079 | (if any) is parsed as though it were a valid command. After all such | ||||||||||||||||||||||||||||||||||||||||||||||
| 4080 | have been executed, control passes to the user. Unless, of course, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4081 | one of the arguments was 'exit'. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4082 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4083 | Unlike most of the other methods, this one returns nothing. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4084 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4085 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 4086 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4087 | 7 | my $rdln; | |||||||||||||||||||||||||||||||||||||||||||||
| 4088 | my %known_meta = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 4089 | olist => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4090 | 0 | ▶ | after => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4091 | 0 | my ( $self, undef, $rslt ) = @_; # Context unused | |||||||||||||||||||||||||||||||||||||||||||||
| 4092 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4093 | 0 | ▶ | ARRAY_REF eq ref $rslt | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4094 | and return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4095 | 0 | ▶ | $rslt->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$rslt->is_success and "orbit" eq ($self->content_type($rslt) || "")
$self->content_type($rslt) || ''
MC/DC0%0/2
$rslt->is_success and "orbit" eq ($self->content_type($rslt) || "")
$rslt->is_success
"orbit" eq ($self->content_type($rslt) || "")
MC/DC0%0/1
$self->content_type($rslt) || ''
$self->content_type($rslt)
Truth table0%0/3
A and B
A= $rslt->is_successB= "orbit" eq ($self->content_type($rslt) || "")
Truth table0%0/2
A
A= $self->content_type($rslt)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4096 | and 'orbit' eq ( $self->content_type( $rslt ) || '' ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 4097 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4098 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4099 | 0 | my $content = $rslt->content(); | |||||||||||||||||||||||||||||||||||||||||||||
| 4100 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||||||
| 4101 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4102 | 0 | ▶ | if ( $content =~ m/ \A [[]? [{] /smx ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4103 | 0 | my $data = $self->_get_json_object()->decode( $content ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4104 | 0 | foreach my $datum ( @{ $data } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 4105 | push @lines, [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 4106 | sprintf '%05d', $datum->{NORAD_CAT_ID}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4107 | defined $datum->{OBJECT_NAME} ? $datum->{OBJECT_NAME} : | ||||||||||||||||||||||||||||||||||||||||||||||
| 4108 | 0 | ▶ | (), | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4109 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4110 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4111 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4113 | 0 | my @name; | |||||||||||||||||||||||||||||||||||||||||||||
| 4114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4115 | 0 | foreach ( split qr{ \n }smx, $content ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 4116 | 0 | ▶ | if ( m/ \A 1 \s+ ( \d+ ) /smx ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4117 | 0 | splice @name, 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 4118 | 0 | push @lines, [ sprintf( '%05d', $1 ), @name ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 4119 | 0 | @name = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 4120 | ▶ | } elsif ( m/ \A 2 \s+ \d+ /smx || m/ \A \s* [#] /smx ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
/ \A 2 \s+ \d+ /msx or / \A \s* [#] /msx
MC/DC0%0/2
/ \A 2 \s+ \d+ /msx or / \A \s* [#] /msx
/ \A 2 \s+ \d+ /msx
/ \A \s* [#] /msx
Truth table0%0/3
A or B
A= / \A 2 \s+ \d+ /msxB= / \A \s* [#] /msx
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4121 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4122 | 0 | push @name, $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4123 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4124 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4125 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4127 | 0 | foreach ( $rslt->header( pragma => undef ) ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 4128 | 0 | my ( $name, $value ) = split qr{ \s* = \s* }smx, $_, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 4129 | 0 | ▶ | 'spacetrack-type' eq $name | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4130 | and $value = 'observing_list'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4131 | 0 | $self->_add_pragmata( $rslt, $name, $value ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4132 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4134 | 0 | $rslt->content( join '', map { "$_\n" } @lines ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4136 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4137 | 0 | local $" = ''; # Make "@a" equivalent to join '', @a. | |||||||||||||||||||||||||||||||||||||||||||||
| 4138 | $rslt->content( join '', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4139 | 0 | map { "@$_\n" } | |||||||||||||||||||||||||||||||||||||||||||||
| 4140 | 0 | sort { $a->[0] <=> $b->[0] } | |||||||||||||||||||||||||||||||||||||||||||||
| 4141 | @lines | ||||||||||||||||||||||||||||||||||||||||||||||
| 4142 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4143 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4144 | 0 | $self->__dump_response( $rslt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4145 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 4146 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4147 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4148 | time => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4149 | 0 | ▶ | before => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4150 | 0 | my ( undef, $context ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 4151 | 0 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4152 | 0 | require Time::HiRes; | |||||||||||||||||||||||||||||||||||||||||||||
| 4153 | 0 | $context->{start_time} = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||||||||||||||
| 4154 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 4155 | } or warn 'No timings available. Can not load Time::HiRes'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4156 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 4157 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4158 | 0 | ▶ | after => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4159 | 0 | my ( undef, $context ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 4160 | $context->{start_time} | ||||||||||||||||||||||||||||||||||||||||||||||
| 4161 | and warn sprintf "Elapsed time: %.2f seconds\n", | ||||||||||||||||||||||||||||||||||||||||||||||
| 4162 | 0 | ▶ | Time::HiRes::time() - $context->{start_time}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4163 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 4164 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4165 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4166 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4168 | 7 | my $readline_word_break_re; | |||||||||||||||||||||||||||||||||||||||||||||
| 4169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4170 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4171 | 7 | my %alias = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 4172 | show => 'get', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4173 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4175 | 1 | ▶ | sub _verb_alias { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_verb_alias: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4176 | 1 | my ( $verb ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4177 | 1 | ▶ | return $alias{$verb} || $verb; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$alias{$verb} || $verb
MC/DC0%0/2
$alias{$verb} || $verb
$alias{$verb}
$verb
Truth table33%1/3
A || B
A= $alias{$verb}B= $verb
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4178 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4179 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4180 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4181 | 7 | ▶ | sub shell { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shell: called CC=43 SCAR=58.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4182 | 1 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4183 | 1 | ▶ | my $self = _instance( $args[0], __PACKAGE__ ) ? shift @args : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4184 | Astro::SpaceTrack->new (addendum => <<'EOD'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4186 | 'help' gets you a list of valid commands. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4187 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 4188 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4189 | 1 | my $stdout = \*STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||
| 4190 | 1 | my $read; | |||||||||||||||||||||||||||||||||||||||||||||
| 4191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4192 | 1 | ▶ | unshift @args, 'banner' if $self->{banner} && !$self->{filter}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"banner"} and not $self->{"filter"}
MC/DC0%0/2
$self->{"banner"} and not $self->{"filter"}
$self->{"banner"}
not $self->{"filter"}
Truth table33%1/3
A and not(B)
A= $self->{"banner"}B= not $self->{"filter"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4193 | # Perl::Critic wants IO::Interactive::is_interactive() here. But | ||||||||||||||||||||||||||||||||||||||||||||||
| 4194 | # that assumes we're using the *ARGV input mechanism, which we're | ||||||||||||||||||||||||||||||||||||||||||||||
| 4195 | # not (command arguments are SpaceTrack commands.) Also, we would | ||||||||||||||||||||||||||||||||||||||||||||||
| 4196 | # like to be prompted even if output is to a pipe, but the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4197 | # recommended module calls that non-interactive even if input is | ||||||||||||||||||||||||||||||||||||||||||||||
| 4198 | # from a terminal. So: | ||||||||||||||||||||||||||||||||||||||||||||||
| 4199 | 1 | my $interactive = -t STDIN; | |||||||||||||||||||||||||||||||||||||||||||||
| 4200 | 1 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||
| 4201 | 4 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||||||
| 4202 | 4 | ▶ | if (@args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4203 | 4 | $buffer = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||
| 4204 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4205 | $read ||= $interactive ? ( eval { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4206 | 0 | $self->_get_readline( $stdout ) | |||||||||||||||||||||||||||||||||||||||||||||
| 4207 | 0 | ▶ | } || sub { print { $stdout } $self->getv( 'prompt' ); return <STDIN> } ) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4208 | 0 | ▶ | sub { return<STDIN> }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
Condition0%0/6
$read ||= $interactive ? eval {
do {
$self->_get_readline($stdout)
}
} || sub {
print {$stdout;} $self->getv("prompt");
return readline STDIN;
}
: sub {
return readline STDIN;
}
eval {
do {
$self->_get_readline($stdout)
}
} or sub {
print {$stdout;} $self->getv("prompt");
return readline STDIN;
}
MC/DC0%0/2
$read ||= $interactive ? eval {
do {
$self->_get_readline($stdout)
}
} || sub {
print {$stdout;} $self->getv("prompt");
return readline STDIN;
}
: sub {
return readline STDIN;
}
$read
$interactive ? eval {
do {
$self->_get_readline($stdout)
}
} || sub {
print {$stdout;} $self->getv("prompt");
return readline STDIN;
}
: sub {
return readline STDIN;
}
MC/DC0%0/2
eval {
do {
$self->_get_readline($stdout)
}
} or sub {
print {$stdout;} $self->getv("prompt");
return readline STDIN;
}
eval {
do {
$self->_get_readline($stdout)
}
}
sub {
print {$stdout;} $self->getv("prompt");
return readline STDIN;
}
Truth table0%0/3
A ||= B
A= $readB= $interactive ? eval {
do {
$self->_get_readline($stdout)
}
} || sub {
print {$stdout;} $self->getv("prompt");
return readline STDIN;
}
: sub {
return readline STDIN;
}
Truth table0%0/3
A or B
A= eval {
do {
$self->_get_readline($stdout)
}
}B= sub {
print {$stdout;} $self->getv("prompt");
return readline STDIN;
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4209 | 0 | $buffer = $read->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 4210 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4211 | 4 | ▶ | last unless defined $buffer; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4212 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4213 | 4 | $buffer =~ s/ \A \s+ //smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 4214 | 4 | $buffer =~ s/ \s+ \z //smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 4215 | 4 | ▶ | next unless $buffer; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4216 | 3 | ▶ | next if $buffer =~ m/ \A [#] /smx; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4218 | # Break the buffer up into tokens, but leave quotes and escapes | ||||||||||||||||||||||||||||||||||||||||||||||
| 4219 | # in place, so that (e.g.) '\>foo' is seen as an argument, not a | ||||||||||||||||||||||||||||||||||||||||||||||
| 4220 | # redirection. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4221 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4222 | 2 | my @cmdarg = Text::ParseWords::parse_line( '\s+', 1, $buffer ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4224 | # Pull off any redirections. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4225 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4226 | 2 | my $redir = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 4227 | @cmdarg = map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4228 | 0 | ▶ | m/ \A > /smx ? do {$redir = $_; ()} : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4229 | 0 | ▶ | $redir =~ m/ \A >+ \z /smx ? do {$redir .= $_; ()} : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4230 | $_ | ||||||||||||||||||||||||||||||||||||||||||||||
| 4231 | } @cmdarg; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4232 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4233 | # Rerun everything through parse_line again, but with the $keep | ||||||||||||||||||||||||||||||||||||||||||||||
| 4234 | # argument false. This should not create any more tokens, it | ||||||||||||||||||||||||||||||||||||||||||||||
| 4235 | # should just un-quote and un-escape the data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4237 | 2 | @cmdarg = map { Text::ParseWords::parse_line( qr{ \s+ }, 0, $_ ) } @cmdarg; | |||||||||||||||||||||||||||||||||||||||||||||
| 4238 | 2 | ▶ | $redir ne '' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4239 | and ( $redir ) = Text::ParseWords::parse_line ( qr{ \s+ }, 0, $redir ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4240 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4241 | 2 | $redir =~ s/ \A (>+) ~ /$1$ENV{HOME}/smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 4242 | 2 | my $verb = lc shift @cmdarg; | |||||||||||||||||||||||||||||||||||||||||||||
| 4243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4244 | 2 | my %meta_command = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 4245 | before => [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 4246 | after => [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 4247 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4249 | 2 | ▶ | while ( my $def = $known_meta{$verb} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4250 | 0 | my %context; | |||||||||||||||||||||||||||||||||||||||||||||
| 4251 | 0 | foreach my $key ( qw{ before after } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 4252 | 0 | ▶ | $def->{$key} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4253 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4254 | 0 | ▶ | push @{ $meta_command{$key} }, sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4255 | 0 | return $def->{$key}->( $self, \%context, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4256 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 4257 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4258 | 0 | $verb = shift @cmdarg; | |||||||||||||||||||||||||||||||||||||||||||||
| 4259 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4260 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4261 | 2 | ▶ | last if $verb eq 'exit' || $verb eq 'bye'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$verb eq "exit" or $verb eq "bye"
MC/DC50%1/2
$verb eq "exit" or $verb eq "bye"
$verb eq "exit"
$verb eq "bye"
Truth table66%2/3
A or B
A= $verb eq "exit"B= $verb eq "bye"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4262 | 1 | $verb = _verb_alias( $verb ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4263 | 1 | ▶ | $verb eq 'source' and do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4264 | 0 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4265 | 0 | splice @args, 0, 0, $self->_source (shift @cmdarg); | |||||||||||||||||||||||||||||||||||||||||||||
| 4266 | 0 | ▶ | 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ || 'An unknown error occurred'
MC/DC0%0/1
$@ || 'An unknown error occurred'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4267 | } or warn ( $@ || 'An unknown error occurred' ); ## no critic (RequireCarping) | ||||||||||||||||||||||||||||||||||||||||||||||
| 4268 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 4269 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4270 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4271 | $verb ne 'new' | ||||||||||||||||||||||||||||||||||||||||||||||
| 4272 | and $verb ne 'shell' | ||||||||||||||||||||||||||||||||||||||||||||||
| 4273 | and $verb !~ m/ \A _ [^_] /smx | ||||||||||||||||||||||||||||||||||||||||||||||
| 4274 | 1 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$verb ne "new" and $verb ne "shell" and not $verb =~ / \A _ [^_] /msx
$verb ne "new" and $verb ne "shell"
MC/DC0%0/3
$verb ne "new" and $verb ne "shell" and not $verb =~ / \A _ [^_] /msx
$verb ne "new"
$verb ne "shell"
not $verb =~ / \A _ [^_] /msx
Truth table25%1/4
A and B and not(C)
A= $verb ne "new"B= $verb ne "shell"C= not $verb =~ / \A _ [^_] /msx
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4275 | 0 | warn <<"EOD"; | |||||||||||||||||||||||||||||||||||||||||||||
| 4276 | Verb '$verb' undefined. Use 'help' to get help. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4277 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 4278 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 4279 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4280 | 1 | my $out; | |||||||||||||||||||||||||||||||||||||||||||||
| 4281 | 1 | ▶ | if ( $redir ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4282 | 0 | ▶ | $out = IO::File->new( $redir ) or do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4283 | 0 | warn <<"EOD"; | |||||||||||||||||||||||||||||||||||||||||||||
| 4284 | Error - Failed to open $redir | ||||||||||||||||||||||||||||||||||||||||||||||
| 4285 | $^E | ||||||||||||||||||||||||||||||||||||||||||||||
| 4286 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 4287 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 4288 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4289 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4290 | 1 | $out = $stdout; | |||||||||||||||||||||||||||||||||||||||||||||
| 4291 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4292 | 1 | my $rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 4293 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4294 | 1 | foreach my $pseudo ( @{ $meta_command{before} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 4295 | 0 | $pseudo->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 4296 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4297 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4298 | 1 | ▶ | if ($verb eq 'get' && @cmdarg == 0) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$verb eq "get" and @cmdarg == 0
MC/DC0%0/2
$verb eq "get" and @cmdarg == 0
$verb eq "get"
@cmdarg == 0
Truth table33%1/3
A and B
A= $verb eq "get"B= @cmdarg == 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4299 | 0 | $rslt = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 4300 | 0 | foreach my $name ($self->attribute_names ()) { | |||||||||||||||||||||||||||||||||||||||||||||
| 4301 | 0 | my $val = $self->getv( $name ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4302 | 0 | ▶ | push @$rslt, defined $val ? "$name $val" : $name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4303 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4304 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4305 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4306 | 1 | $rslt = $self->$verb (@cmdarg); | |||||||||||||||||||||||||||||||||||||||||||||
| 4307 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 4308 | 1 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4309 | 0 | warn $@; ## no critic (RequireCarping) | |||||||||||||||||||||||||||||||||||||||||||||
| 4310 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 4311 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4312 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4313 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4314 | 1 | foreach my $pseudo ( reverse @{ $meta_command{after} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 4315 | 0 | $pseudo->( $rslt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4316 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4317 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4318 | 1 | ▶ | if ( ARRAY_REF eq ref $rslt ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4319 | 0 | foreach (@$rslt) {print { $out } "$_\n"} | |||||||||||||||||||||||||||||||||||||||||||||
| 4320 | } elsif ( ! ref $rslt ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4321 | 0 | print { $out } "$rslt\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 4322 | } elsif ($rslt->is_success) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4323 | $self->content_type() | ||||||||||||||||||||||||||||||||||||||||||||||
| 4324 | or not $self->{filter} | ||||||||||||||||||||||||||||||||||||||||||||||
| 4325 | 1 | ▶ | or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->content_type or not $self->{"filter"}
MC/DC0%0/2
$self->content_type or not $self->{"filter"}
$self->content_type
not $self->{"filter"}
Truth table33%1/3
A or not(B)
A= $self->content_typeB= not $self->{"filter"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4326 | 1 | my $content = $rslt->content; | |||||||||||||||||||||||||||||||||||||||||||||
| 4327 | 1 | chomp $content; | |||||||||||||||||||||||||||||||||||||||||||||
| 4328 | 1 | print { $out } "$content\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 4329 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4330 | 0 | my $status = $rslt->status_line; | |||||||||||||||||||||||||||||||||||||||||||||
| 4331 | 0 | chomp $status; | |||||||||||||||||||||||||||||||||||||||||||||
| 4332 | 0 | warn $status, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 4333 | $rslt->code() == HTTP_I_AM_A_TEAPOT | ||||||||||||||||||||||||||||||||||||||||||||||
| 4334 | 0 | ▶ | and print { $out } $rslt->content(), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4335 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4336 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4337 | $interactive | ||||||||||||||||||||||||||||||||||||||||||||||
| 4338 | and not $self->{filter} | ||||||||||||||||||||||||||||||||||||||||||||||
| 4339 | 0 | ▶ | and print { $stdout } "\n"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$interactive and not $self->{"filter"}
MC/DC0%0/2
$interactive and not $self->{"filter"}
$interactive
not $self->{"filter"}
Truth table33%1/3
A and not(B)
A= $interactiveB= not $self->{"filter"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4340 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 4341 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4342 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4343 | 1 | ▶ | sub _get_readline { ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_readline: called CC=6 SCAR=24.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4344 | 1 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4345 | 1 | require Term::ReadLine; | |||||||||||||||||||||||||||||||||||||||||||||
| 4346 | 1 | ▶ | $rdln ||= Term::ReadLine->new ( | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$rdln ||= "Term::ReadLine"->new("SpaceTrack orbital element access")
MC/DC0%0/2
$rdln ||= "Term::ReadLine"->new("SpaceTrack orbital element access")
$rdln
"Term::ReadLine"->new("SpaceTrack orbital element access")
Truth table33%1/3
A ||= B
A= $rdlnB= "Term::ReadLine"->new("SpaceTrack orbital element access")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4347 | 'SpaceTrack orbital element access'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4348 | 1 | ▶ | @_ > 1 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$rdln->OUT || \*STDOUT
MC/DC0%0/1
$rdln->OUT || \*STDOUT
$rdln->OUT
Truth table0%0/2
A
A= $rdln->OUT
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4349 | and $_[1] = ( $rdln->OUT || \*STDOUT ); # $stdout | ||||||||||||||||||||||||||||||||||||||||||||||
| 4350 | 1 | ▶ | if ( 'Term::ReadLine::Perl' eq $rdln->ReadLine() ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4351 | 0 | require File::Glob; | |||||||||||||||||||||||||||||||||||||||||||||
| 4352 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4353 | 0 | ▶ | $readline_word_break_re ||= qr< | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$readline_word_break_re ||= qr/
[\Q$readline::rl_completer_word_break_characters\E]+
/msx
MC/DC0%0/1
$readline_word_break_re ||= qr/
[\Q$readline::rl_completer_word_break_characters\E]+
/msx
$readline_word_break_re
Truth table0%0/2
A
A= $readline_word_break_re
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4354 | [\Q$readline::rl_completer_word_break_characters\E]+ | ||||||||||||||||||||||||||||||||||||||||||||||
| 4355 | >smx; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4356 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4357 | 7 | ▶ | no warnings qw{ once }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4358 | 0 | ▶ | $readline::rl_completion_function = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4359 | 0 | my ( $text, $line, $start ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4360 | 0 | return $self->__readline_completer( | |||||||||||||||||||||||||||||||||||||||||||||
| 4361 | $text, $line, $start ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4362 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 4363 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4364 | 0 | ▶ | return sub { $rdln->readline ( $self->getv( 'prompt' ) ) }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4365 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4366 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4367 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4368 | =for html <a name="source"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 4369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4370 | =item $st->source ($filename); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4371 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4372 | This convenience method reads the given file, and passes the individual | ||||||||||||||||||||||||||||||||||||||||||||||
| 4373 | lines to the shell method. It croaks if the file is not provided or | ||||||||||||||||||||||||||||||||||||||||||||||
| 4374 | cannot be read. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4375 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4376 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 4377 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4378 | # We really just delegate to _source, which unpacks. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4379 | 0 | ▶ | sub source { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4380 | 0 | ▶ | my $self = _instance( $_[0], __PACKAGE__ ) ? shift : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4381 | Astro::SpaceTrack->new (); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4382 | 0 | $self->shell ($self->_source (@_), 'exit'); | |||||||||||||||||||||||||||||||||||||||||||||
| 4383 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 4384 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4385 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4386 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4387 | =for html <a name="spacetrack"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 4388 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4389 | =item $resp = $st->spacetrack ($name); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4390 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4391 | This method returns predefined sets of data from the Space Track web | ||||||||||||||||||||||||||||||||||||||||||||||
| 4392 | site, using either canned queries or global favorites. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4393 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4394 | The following catalogs are available: | ||||||||||||||||||||||||||||||||||||||||||||||
| 4395 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4396 | Name Description | ||||||||||||||||||||||||||||||||||||||||||||||
| 4397 | full Full catalog | ||||||||||||||||||||||||||||||||||||||||||||||
| 4398 | payloads All payloads | ||||||||||||||||||||||||||||||||||||||||||||||
| 4399 | * navigation Navigation satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 4400 | * weather Weather satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 4401 | geosynchronous Geosynchronous bodies | ||||||||||||||||||||||||||||||||||||||||||||||
| 4402 | iridium Iridium satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 4403 | orbcomm OrbComm satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 4404 | globalstar Globalstar satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 4405 | intelsat Intelsat satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 4406 | inmarsat Inmarsat satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 4407 | * amateur Amateur Radio satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 4408 | * visible Visible satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 4409 | * special Special satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 4410 | * bright_geosynchronous | ||||||||||||||||||||||||||||||||||||||||||||||
| 4411 | Bright Geosynchronous satellites | ||||||||||||||||||||||||||||||||||||||||||||||
| 4412 | * human_spaceflight | ||||||||||||||||||||||||||||||||||||||||||||||
| 4413 | Human Spaceflight | ||||||||||||||||||||||||||||||||||||||||||||||
| 4414 | well_tracked_objects | ||||||||||||||||||||||||||||||||||||||||||||||
| 4415 | Well-Tracked Objects not associated | ||||||||||||||||||||||||||||||||||||||||||||||
| 4416 | with a specific launch | ||||||||||||||||||||||||||||||||||||||||||||||
| 4417 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4418 | The starred items are 404 as of 2026-01-19. Attempts to retrieve them | ||||||||||||||||||||||||||||||||||||||||||||||
| 4419 | produce an exception as of version 1.083. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4420 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4421 | The following option is supported: | ||||||||||||||||||||||||||||||||||||||||||||||
| 4422 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4423 | -json | ||||||||||||||||||||||||||||||||||||||||||||||
| 4424 | specifies the TLE be returned in JSON format | ||||||||||||||||||||||||||||||||||||||||||||||
| 4425 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4426 | Options may be specified either in command-line style | ||||||||||||||||||||||||||||||||||||||||||||||
| 4427 | (that is, as C<< spacetrack( '-json', ... ) >>) or as a hash reference | ||||||||||||||||||||||||||||||||||||||||||||||
| 4428 | (that is, as C<< spacetrack( { json => 1 }, ... ) >>). | ||||||||||||||||||||||||||||||||||||||||||||||
| 4429 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4430 | This method returns an L<HTTP::Response|HTTP::Response> object. If the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4431 | operation succeeded, the content of the response will be the requested | ||||||||||||||||||||||||||||||||||||||||||||||
| 4432 | data, unzipped if you used the version 1 interface. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4433 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4434 | If you requested a non-existent catalog, the response code will be | ||||||||||||||||||||||||||||||||||||||||||||||
| 4435 | C<HTTP_NOT_FOUND> (a.k.a. 404); otherwise the response code will be | ||||||||||||||||||||||||||||||||||||||||||||||
| 4436 | whatever the underlying HTTPS request returned. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4437 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4438 | A Space Track username and password are required to use this method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4439 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4440 | If this method succeeds, the response will contain headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 4441 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4442 | Pragma: spacetrack-type = orbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 4443 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 4444 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4445 | These can be accessed by C<< $st->content_type( $resp ) >> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 4446 | C<< $st->content_source( $resp ) >> respectively. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4447 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4448 | A list of valid names and brief descriptions can be obtained by calling | ||||||||||||||||||||||||||||||||||||||||||||||
| 4449 | C<< $st->names ('spacetrack') >>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4450 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4451 | If you have set the C<verbose> attribute true (e.g. C<< $st->set | ||||||||||||||||||||||||||||||||||||||||||||||
| 4452 | (verbose => 1) >>), the content of the error response will include the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4453 | list of valid names. Note, however, that under version 1 of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4454 | interface this list does not determine what can be retrieved. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4455 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4456 | This method implicitly calls the C<login()> method if the session cookie | ||||||||||||||||||||||||||||||||||||||||||||||
| 4457 | is missing or expired. If C<login()> fails, you will get the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4458 | HTTP::Response from C<login()>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4459 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4460 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 4461 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4462 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4463 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4464 | my %unpack_query = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 4465 | 0 | ▶ | ARRAY_REF() => sub { return @{ $_[0] } }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4466 | 0 | ▶ | HASH_REF() => sub { return $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4467 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4468 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4469 | # Unpack a Space Track REST query. References are unpacked per the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4470 | # above table, if found there. Undefined values return an empty hash | ||||||||||||||||||||||||||||||||||||||||||||||
| 4471 | # reference. Anything else croaks with a stack trace. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4472 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4473 | 0 | ▶ | sub _unpack_query { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unpack_query: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4474 | 0 | my ( $arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4475 | 0 | ▶ | my $code = $unpack_query{ref $arg} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4476 | or Carp::confess "Bug - unexpected query $arg"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4477 | 0 | return $code->( $arg ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4478 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4479 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4480 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4481 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4482 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 4483 | 7 | ▶ | sub _spacetrack_opts { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_spacetrack_opts: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4484 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 4485 | 5 | 'json!' => 'Return data in JSON format', | |||||||||||||||||||||||||||||||||||||||||||||
| 4486 | 'format=s' => 'Specify retrieval format', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4487 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4488 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4489 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4490 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 4491 | 0 | ▶ | sub _spacetrack_catalog_version { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_spacetrack_catalog_version: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4492 | 0 | return $_[0]->getv( 'space_track_version' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4493 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4494 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4495 | 5 | ▶ | sub spacetrack { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spacetrack: called CC=12 SCAR=29.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4496 | 5 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4497 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4498 | 5 | my ( $opt, $catalog ) = _parse_args( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4499 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4500 | 5 | _retrieval_format( tle => $opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4501 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4502 | defined $catalog | ||||||||||||||||||||||||||||||||||||||||||||||
| 4503 | 5 | ▶ | and my $info = $catalogs{spacetrack}[2]{$catalog} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $catalog and my $info = $catalogs{"spacetrack"}[2]{$catalog}
MC/DC50%1/2
defined $catalog and my $info = $catalogs{"spacetrack"}[2]{$catalog}
defined $catalog
my $info = $catalogs{"spacetrack"}[2]{$catalog}
Truth table66%2/3
A and B
A= defined $catalogB= my $info = $catalogs{"spacetrack"}[2]{$catalog}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4504 | or return $self->_no_such_catalog( spacetrack => 2, $catalog ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4505 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4506 | defined $info->{deprecate} | ||||||||||||||||||||||||||||||||||||||||||||||
| 4507 | 4 | ▶ | and Carp::croak "Catalog '$catalog' is deprecated in favor of '$info->{deprecate}'"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4508 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4509 | 4 | ▶ | if ( defined $info->{favorite} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4510 | 1 | $self->_deprecation_notice( spacetrack => $info->{favorite} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4511 | 1 | return $self->favorite( $opt, $info->{favorite} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4512 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4513 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4514 | my %retrieve_opt = %{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 4515 | 3 | $self->_convert_retrieve_options_to_rest( $opt ) | |||||||||||||||||||||||||||||||||||||||||||||
| 4516 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4517 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4518 | $info->{tle} | ||||||||||||||||||||||||||||||||||||||||||||||
| 4519 | 3 | and @retrieve_opt{ keys %{ $info->{tle} } } = | |||||||||||||||||||||||||||||||||||||||||||||
| 4520 | 3 | ▶ | values %{ $info->{tle} }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4521 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4522 | 3 | my $rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 4523 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4524 | 3 | ▶ | if ( $info->{satcat} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4525 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4526 | 0 | my %oid; | |||||||||||||||||||||||||||||||||||||||||||||
| 4527 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4528 | 0 | foreach my $query ( _unpack_query( $info->{satcat} ) ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 4529 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4530 | 0 | $rslt = $self->spacetrack_query_v2( | |||||||||||||||||||||||||||||||||||||||||||||
| 4531 | basicspacedata => 'query', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4532 | class => 'satcat', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4533 | format => 'json', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4534 | predicates => 'NORAD_CAT_ID', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4535 | CURRENT => 'Y', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4536 | DECAY => 'null-val', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4537 | _sort_rest_arguments( $query ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 4538 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4539 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4540 | 0 | ▶ | $rslt->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4541 | or return $rslt; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4542 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4543 | 0 | foreach my $body ( @{ | |||||||||||||||||||||||||||||||||||||||||||||
| 4544 | 0 | $self->_get_json_object()->decode( $rslt->content() ) | |||||||||||||||||||||||||||||||||||||||||||||
| 4545 | } ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4546 | 0 | $oid{ $body->{NORAD_CAT_ID} + 0 } = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 4547 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4548 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4549 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4550 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4551 | $rslt = $self->retrieve( $opt, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4552 | 0 | sort { $a <=> $b } keys %oid ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4553 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4554 | 0 | ▶ | $rslt->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4555 | or return $rslt; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4556 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4557 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4558 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4559 | 3 | $rslt = $self->spacetrack_query_v2( | |||||||||||||||||||||||||||||||||||||||||||||
| 4560 | basicspacedata => 'query', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4561 | _sort_rest_arguments( \%retrieve_opt ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 4562 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4563 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4564 | 3 | ▶ | $rslt->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4565 | or return $rslt; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4566 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4567 | 1 | $self->_convert_content( $rslt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4568 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4569 | 1 | $self->_add_pragmata( $rslt, | |||||||||||||||||||||||||||||||||||||||||||||
| 4570 | 'spacetrack-type' => 'orbit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4571 | 'spacetrack-source' => 'spacetrack', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4572 | 'spacetrack-interface' => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4573 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4574 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4575 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4576 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4577 | 1 | return $rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 4578 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4579 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4580 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4581 | =for html <a name="spacetrack_query_v2"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 4582 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4583 | =item $resp = $st->spacetrack_query_v2( @path ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4584 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4585 | This method exposes the Space Track version 2 interface (a.k.a the REST | ||||||||||||||||||||||||||||||||||||||||||||||
| 4586 | interface). It has nothing to do with the (probably badly-named) | ||||||||||||||||||||||||||||||||||||||||||||||
| 4587 | C<spacetrack()> method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4588 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4589 | The arguments are the arguments to the REST interface. These will be | ||||||||||||||||||||||||||||||||||||||||||||||
| 4590 | URI-escaped, and a login will be performed if necessary. This method | ||||||||||||||||||||||||||||||||||||||||||||||
| 4591 | returns an C<HTTP::Response> object containing the results of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4592 | operation. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4593 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4594 | Except for the URI escaping of the arguments and the implicit login, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4595 | this method interfaces directly to Space Track. It is provided for those | ||||||||||||||||||||||||||||||||||||||||||||||
| 4596 | who want a way to experiment with the REST interface, or who wish to do | ||||||||||||||||||||||||||||||||||||||||||||||
| 4597 | something not covered by the higher-level methods. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4598 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4599 | For example, if you want the JSON version of the satellite box score | ||||||||||||||||||||||||||||||||||||||||||||||
| 4600 | (rather than the tab-delimited version provided by the C<box_score()> | ||||||||||||||||||||||||||||||||||||||||||||||
| 4601 | method) you will find the JSON in the response object of the following | ||||||||||||||||||||||||||||||||||||||||||||||
| 4602 | call: | ||||||||||||||||||||||||||||||||||||||||||||||
| 4603 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4604 | my $resp = $st->spacetrack_query_v2( qw{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 4605 | basicspacedata query class boxscore | ||||||||||||||||||||||||||||||||||||||||||||||
| 4606 | format json predicates all | ||||||||||||||||||||||||||||||||||||||||||||||
| 4607 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4608 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4609 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4610 | If this method is called directly from outside the C<Astro::SpaceTrack> | ||||||||||||||||||||||||||||||||||||||||||||||
| 4611 | name space, pragmata will be added to the results based on the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4612 | arguments, as follows: | ||||||||||||||||||||||||||||||||||||||||||||||
| 4613 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4614 | For C<< basicspacedata => 'modeldef' >> | ||||||||||||||||||||||||||||||||||||||||||||||
| 4615 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4616 | Pragma: spacetrack-type = modeldef | ||||||||||||||||||||||||||||||||||||||||||||||
| 4617 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 4618 | Pragma: spacetrack-interface = 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 4619 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4620 | For C<< basicspacedata => 'query' >> and C<< class => 'tle' >> or | ||||||||||||||||||||||||||||||||||||||||||||||
| 4621 | C<'tle_latest'>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4622 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4623 | Pragma: spacetrack-type = orbit | ||||||||||||||||||||||||||||||||||||||||||||||
| 4624 | Pragma: spacetrack-source = spacetrack | ||||||||||||||||||||||||||||||||||||||||||||||
| 4625 | Pragma: spacetrack-interface = 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 4626 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4627 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 4628 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4629 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4630 | 7 | ▶ | our $SPACETRACK_DELAY_SECONDS = $ENV{SPACETRACK_DELAY_SECONDS} || 3; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'SPACETRACK_DELAY_SECONDS'} || 3
MC/DC0%0/1
$ENV{'SPACETRACK_DELAY_SECONDS'} || 3
$ENV{'SPACETRACK_DELAY_SECONDS'}
Truth table50%1/2
A
A= $ENV{'SPACETRACK_DELAY_SECONDS'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4631 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4632 | 7 | my $spacetrack_delay_until; | |||||||||||||||||||||||||||||||||||||||||||||
| 4633 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4634 | 92 | ▶ | sub _spacetrack_delay { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_spacetrack_delay: called CC=5 SCAR=29.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4635 | 92 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4636 | 92 | ▶ | $SPACETRACK_DELAY_SECONDS | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4637 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4638 | 0 | ▶ | $self->{dump_headers} & DUMP_DRY_RUN | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4639 | and return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4640 | 0 | ▶ | if ( defined $spacetrack_delay_until ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4641 | 0 | my $now = _time(); | |||||||||||||||||||||||||||||||||||||||||||||
| 4642 | 0 | ▶ | $now < $spacetrack_delay_until | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4643 | and _sleep( $spacetrack_delay_until - $now ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4644 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4645 | 0 | $spacetrack_delay_until = _time() + $SPACETRACK_DELAY_SECONDS; | |||||||||||||||||||||||||||||||||||||||||||||
| 4646 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4647 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 4648 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4649 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4650 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4651 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4652 | 7 | my %tle_class = map { $_ => 1 } qw{ tle tle_latest gp gp_history }; | |||||||||||||||||||||||||||||||||||||||||||||
| 4653 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4654 | 92 | ▶ | sub spacetrack_query_v2 { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spacetrack_query_v2: called CC=11 SCAR=25.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4655 | 92 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4656 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4657 | # Space Track has announced that beginning September 22 2014 | ||||||||||||||||||||||||||||||||||||||||||||||
| 4658 | # they will begin limiting queries to 20 per minute. But they | ||||||||||||||||||||||||||||||||||||||||||||||
| 4659 | # seem to have jumped the gun, since I get failures August 19 | ||||||||||||||||||||||||||||||||||||||||||||||
| 4660 | # 2014 if I don't throttle. None of this applies, though, if | ||||||||||||||||||||||||||||||||||||||||||||||
| 4661 | # we're not actually executing the query. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4662 | 92 | $self->_spacetrack_delay(); | |||||||||||||||||||||||||||||||||||||||||||||
| 4663 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4664 | 92 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 4665 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4666 | # # Note that we need to add the comma to URI::Escape's RFC3986 list, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4667 | # # since Space Track does not decode it. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4668 | # my $url = join '/', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4669 | # $self->_make_space_track_base_url( 2 ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 4670 | # map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4671 | # URI::Escape::uri_escape( $_, '^A-Za-z0-9.,_~:-' ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 4672 | # } @args; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4673 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4674 | 92 | my $uri = URI->new( $self->_make_space_track_base_url( 2 ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4675 | 92 | $uri->path_segments( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4676 | # $url eq $uri->as_string() | ||||||||||||||||||||||||||||||||||||||||||||||
| 4677 | # or warn "'$url' ne '@{[ $uri->as_string() ]}'"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4678 | # $url = $uri->as_string(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4679 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4680 | 92 | ▶ | if ( my $resp = $self->_dump_request( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4681 | args => \@args, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4682 | method => 'GET', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4683 | url => $uri, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4684 | version => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4685 | ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4686 | 46 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 4687 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4688 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4689 | $self->_check_cookie_generic( 2 ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 4690 | 46 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4691 | 1 | my $resp = $self->login(); | |||||||||||||||||||||||||||||||||||||||||||||
| 4692 | 1 | ▶ | $resp->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4693 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4694 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4695 | ## warn "Debug - $url/$cgi"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4696 | # my $resp = $self->_get_agent()->get( $url ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4697 | 46 | my $resp = $self->_get_agent()->get( $uri ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4698 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4699 | 46 | ▶ | if ( $resp->is_success() ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4700 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4701 | 46 | ▶ | if ( $self->{pretty} && | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"pretty"} and _find_rest_arg_value(\@args, "format", "json") eq "json"
MC/DC0%0/2
$self->{"pretty"} and _find_rest_arg_value(\@args, "format", "json") eq "json"
$self->{"pretty"}
_find_rest_arg_value(\@args, "format", "json") eq "json"
Truth table33%1/3
A and B
A= $self->{"pretty"}B= _find_rest_arg_value(\@args, "format", "json") eq "json"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4702 | _find_rest_arg_value( \@args, format => 'json' ) eq 'json' | ||||||||||||||||||||||||||||||||||||||||||||||
| 4703 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4704 | 0 | my $json = $self->_get_json_object(); | |||||||||||||||||||||||||||||||||||||||||||||
| 4705 | 0 | $resp->content( $json->encode( $json->decode( | |||||||||||||||||||||||||||||||||||||||||||||
| 4706 | $resp->content() ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4707 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4708 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4709 | 46 | ▶ | if ( __PACKAGE__ ne caller ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4710 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4711 | 2 | my $kind = _find_rest_arg_value( \@args, | |||||||||||||||||||||||||||||||||||||||||||||
| 4712 | basicspacedata => '' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4713 | 2 | my $class = _find_rest_arg_value( \@args, | |||||||||||||||||||||||||||||||||||||||||||||
| 4714 | class => '' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4715 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4716 | 2 | ▶ | if ( 'modeldef' eq $kind ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4717 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4718 | 1 | $self->_add_pragmata( $resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 4719 | 'spacetrack-type' => 'modeldef', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4720 | 'spacetrack-source' => 'spacetrack', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4721 | 'spacetrack-interface' => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4722 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4723 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4724 | ▶ | } elsif ( 'query' eq $kind && $tle_class{$class} ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
"query" eq $kind and $tle_class{$class}
MC/DC0%0/2
"query" eq $kind and $tle_class{$class}
"query" eq $kind
$tle_class{$class}
Truth table33%1/3
A and B
A= "query" eq $kindB= $tle_class{$class}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4725 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4726 | 1 | $self->_add_pragmata( $resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 4727 | 'spacetrack-type' => 'orbit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4728 | 'spacetrack-source' => 'spacetrack', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4729 | 'spacetrack-interface' => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4730 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4731 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4732 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4733 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4734 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4735 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4736 | 46 | $self->__dump_response( $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4737 | 46 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 4738 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4739 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4740 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4741 | 7 | ▶ | sub _find_rest_arg_value { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_rest_arg_value: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4742 | 4 | my ( $args, $name, $default ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4743 | 4 | ▶ | for ( my $inx = $#$args - 1; $inx >= 0; $inx -= 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4744 | 8 | ▶ | $args->[$inx] eq $name | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4745 | and return $args->[$inx + 1]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4746 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4747 | 0 | return $default; | |||||||||||||||||||||||||||||||||||||||||||||
| 4748 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4749 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4750 | =for html <a name="update"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 4751 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4752 | =item $resp = $st->update( $file_name ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4753 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4754 | This method updates the named TLE file, which must be in JSON format. On | ||||||||||||||||||||||||||||||||||||||||||||||
| 4755 | a successful update, the content of the returned HTTP::Response object | ||||||||||||||||||||||||||||||||||||||||||||||
| 4756 | is the updated TLE data, in whatever format is desired. If any updates | ||||||||||||||||||||||||||||||||||||||||||||||
| 4757 | were in fact found, the file is rewritten. The rewritten JSON will be | ||||||||||||||||||||||||||||||||||||||||||||||
| 4758 | pretty if the C<pretty> attribute is true. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4759 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4760 | The file to be updated can be generated by using the C<-json> option on | ||||||||||||||||||||||||||||||||||||||||||||||
| 4761 | any of the methods that accesses Space Track data. For example, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4762 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4763 | # Assuming $ENV{SPACETRACK_USER} contains | ||||||||||||||||||||||||||||||||||||||||||||||
| 4764 | # username/password | ||||||||||||||||||||||||||||||||||||||||||||||
| 4765 | my $st = Astro::SpaceTrack->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 4766 | pretty => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4767 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4768 | my $rslt = $st->spacetrack( { json => 1 }, 'iridium' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4769 | $rslt->is_success() | ||||||||||||||||||||||||||||||||||||||||||||||
| 4770 | or die $rslt->status_line(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4771 | open my $fh, '>', 'iridium.json' | ||||||||||||||||||||||||||||||||||||||||||||||
| 4772 | or die "Failed to open file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4773 | print { $fh } $rslt->content(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4774 | close $fh; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4775 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4776 | The following is the equivalent example using the F<SpaceTrack> script: | ||||||||||||||||||||||||||||||||||||||||||||||
| 4777 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4778 | SpaceTrack> set pretty 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 4779 | SpaceTrack> spacetrack -json iridium >iridium.json | ||||||||||||||||||||||||||||||||||||||||||||||
| 4780 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4781 | This method reads the file to be updated, determines the highest C<FILE> | ||||||||||||||||||||||||||||||||||||||||||||||
| 4782 | value, and then requests the given OIDs, restricting the return to | ||||||||||||||||||||||||||||||||||||||||||||||
| 4783 | C<FILE> values greater than the highest found. If anything is returned, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4784 | the file is rewritten. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4785 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4786 | The following options may be specified: | ||||||||||||||||||||||||||||||||||||||||||||||
| 4787 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4788 | -json | ||||||||||||||||||||||||||||||||||||||||||||||
| 4789 | specifies the TLE be returned in JSON format | ||||||||||||||||||||||||||||||||||||||||||||||
| 4790 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4791 | Options may be specified either in command-line style (that is, as | ||||||||||||||||||||||||||||||||||||||||||||||
| 4792 | C<< spacetrack( '-json', ... ) >>) or as a hash reference (that is, as | ||||||||||||||||||||||||||||||||||||||||||||||
| 4793 | C<< spacetrack( { json => 1 }, ... ) >>). | ||||||||||||||||||||||||||||||||||||||||||||||
| 4794 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4795 | B<Note> that there is no way to specify the C<-rcs> or C<-effective> | ||||||||||||||||||||||||||||||||||||||||||||||
| 4796 | options. If the file being updated contains these values, they will be | ||||||||||||||||||||||||||||||||||||||||||||||
| 4797 | lost as the individual OIDs are updated. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4798 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4799 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 4800 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4801 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4802 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4803 | my %encode = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 4804 | 0 | ▶ | '3le' => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4805 | 0 | my ( undef, $data ) = @_; # JSON object unused | |||||||||||||||||||||||||||||||||||||||||||||
| 4806 | return join '', map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4807 | 0 | "$_->{OBJECT_NAME}\n$_->{TLE_LINE1}\n$_->{TLE_LINE2}\n" | |||||||||||||||||||||||||||||||||||||||||||||
| 4808 | 0 | } @{ $data }; | |||||||||||||||||||||||||||||||||||||||||||||
| 4809 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4810 | 0 | ▶ | json => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4811 | 0 | my ( $json, $data ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4812 | 0 | return $json->encode( $data ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4813 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4814 | 0 | ▶ | tle => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4815 | 0 | my ( undef, $data ) = @_; # JSON object unused | |||||||||||||||||||||||||||||||||||||||||||||
| 4816 | return join '', map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4817 | 0 | "$_->{TLE_LINE1}\n$_->{TLE_LINE2}\n" | |||||||||||||||||||||||||||||||||||||||||||||
| 4818 | 0 | } @{ $data }; | |||||||||||||||||||||||||||||||||||||||||||||
| 4819 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4820 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4821 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4822 | # Called dynamically | ||||||||||||||||||||||||||||||||||||||||||||||
| 4823 | 0 | ▶ | sub _update_opts { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_opts: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4824 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 4825 | 0 | _get_retrieve_options(), | |||||||||||||||||||||||||||||||||||||||||||||
| 4826 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4827 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4828 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4829 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4830 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4831 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4832 | 0 | my ( $opt, $fn ) = $self->_parse_retrieve_args( @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4833 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4834 | 0 | $opt = { %{ $opt } }; # Since we modify it. | |||||||||||||||||||||||||||||||||||||||||||||
| 4835 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4836 | delete $opt->{start_epoch} | ||||||||||||||||||||||||||||||||||||||||||||||
| 4837 | 0 | ▶ | and Carp::croak '-start_epoch not allowed'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4838 | delete $opt->{end_epoch} | ||||||||||||||||||||||||||||||||||||||||||||||
| 4839 | 0 | ▶ | and Carp::croak '-end_epoch not allowed'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4840 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4841 | 0 | my $json = $self->_get_json_object(); | |||||||||||||||||||||||||||||||||||||||||||||
| 4842 | 0 | my $data; | |||||||||||||||||||||||||||||||||||||||||||||
| 4843 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4844 | 0 | local $/ = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 4845 | 0 | ▶ | open my $fh, '<', $fn | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4846 | or Carp::croak "Unable to open $fn: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4847 | 0 | $data = $json->decode( <$fh> ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4848 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||
| 4849 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4850 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4851 | 0 | my $file = -1; | |||||||||||||||||||||||||||||||||||||||||||||
| 4852 | 0 | my @oids; | |||||||||||||||||||||||||||||||||||||||||||||
| 4853 | 0 | foreach my $datum ( @{ $data } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 4854 | 0 | push @oids, $datum->{NORAD_CAT_ID}; | |||||||||||||||||||||||||||||||||||||||||||||
| 4855 | my $ff = defined $datum->{_file_of_record} ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 4856 | delete $datum->{_file_of_record} : | ||||||||||||||||||||||||||||||||||||||||||||||
| 4857 | 0 | ▶ | $datum->{FILE}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4858 | 0 | ▶ | $ff > $file | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4859 | and $file = $ff; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4860 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4861 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4862 | defined $opt->{since_file} | ||||||||||||||||||||||||||||||||||||||||||||||
| 4863 | 0 | ▶ | or $opt->{since_file} = $file; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4864 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4865 | 0 | ▶ | my $format = delete $opt->{json} ? 'json' : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4866 | $self->getv( 'with_name' ) ? '3le' : 'tle'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4867 | 0 | $opt->{format} = 'json'; | |||||||||||||||||||||||||||||||||||||||||||||
| 4868 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4869 | 0 | my $resp = $self->retrieve( $opt, sort { $a <=> $b } @oids ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4870 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4871 | 0 | ▶ | if ( $resp->code() == HTTP_NOT_FOUND ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4872 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4873 | 0 | $resp->code( HTTP_OK ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4874 | 0 | $self->_add_pragmata( $resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 4875 | 'spacetrack-type' => 'orbit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4876 | 'spacetrack-source' => 'spacetrack', | ||||||||||||||||||||||||||||||||||||||||||||||
| 4877 | 'spacetrack-interface' => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4878 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4879 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4880 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4881 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4882 | 0 | ▶ | $resp->is_success() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4883 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4884 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4885 | 0 | my %merge = map { $_->{NORAD_CAT_ID} => $_ } @{ $data }; | |||||||||||||||||||||||||||||||||||||||||||||
| 4886 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4887 | 0 | foreach my $datum ( @{ $json->decode( $resp->content() ) } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 4888 | 0 | %{ $merge{$datum->{NORAD_CAT_ID}} } = %{ $datum }; | |||||||||||||||||||||||||||||||||||||||||||||
| 4889 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4890 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4891 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4892 | 0 | ▶ | open my $fh, '>', $fn | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4893 | or Carp::croak "Failed to open $fn: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4894 | 0 | print { $fh } $json->encode( $data ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4895 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||
| 4896 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4897 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4898 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4899 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4900 | 0 | $resp->content( $encode{$format}->( $json, $data ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4901 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4902 | 0 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 4903 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4904 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4905 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4906 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4907 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4908 | #### | ||||||||||||||||||||||||||||||||||||||||||||||
| 4909 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 4910 | # Private methods. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4911 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 4912 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4913 | # $self->_add_pragmata ($resp, $name => $value, ...); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4914 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 4915 | # This method adds pragma headers to the given HTTP::Response | ||||||||||||||||||||||||||||||||||||||||||||||
| 4916 | # object, of the form pragma => "$name = $value". The pragmata are | ||||||||||||||||||||||||||||||||||||||||||||||
| 4917 | # also cached in $self. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4918 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 4919 | # Pragmata names are normalized by converting them to lower case | ||||||||||||||||||||||||||||||||||||||||||||||
| 4920 | # and converting underscores to dashes. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4921 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4922 | 7 | ▶ | sub _add_pragmata { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_pragmata: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4923 | 134 | my ($self, $resp, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4924 | 134 | ▶ | while (@args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4925 | 301 | my ( $name, $value ) = splice @args, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 4926 | 301 | $name = lc $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 4927 | 301 | $name =~ s/ _ /-/smxg; | |||||||||||||||||||||||||||||||||||||||||||||
| 4928 | 301 | $self->{_pragmata}{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 4929 | 301 | $resp->push_header(pragma => "$name = $value"); | |||||||||||||||||||||||||||||||||||||||||||||
| 4930 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4931 | 134 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 4932 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4933 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4934 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 4935 | 7 | my %format_map = qw{ | |||||||||||||||||||||||||||||||||||||||||||||
| 4936 | 3le tle | ||||||||||||||||||||||||||||||||||||||||||||||
| 4937 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4938 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4939 | # $accumulator = _accumulator_for( $format, \%opt ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 4940 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 4941 | # This subroutine manufactires and returns an accumulator for the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4942 | # named format. The reference to the options hash is itself | ||||||||||||||||||||||||||||||||||||||||||||||
| 4943 | # optional. The supported options are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 4944 | # file => true if the data contains a FILE key and the caller | ||||||||||||||||||||||||||||||||||||||||||||||
| 4945 | # requests that a _file_of_record key be generated if | ||||||||||||||||||||||||||||||||||||||||||||||
| 4946 | # possible and appropriate. Individual accumulators are at | ||||||||||||||||||||||||||||||||||||||||||||||
| 4947 | # liberty to ignore this. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4948 | # pretty => true if the caller requests that the returned data be | ||||||||||||||||||||||||||||||||||||||||||||||
| 4949 | # nicely formatted. This normally comes from the 'pretty' | ||||||||||||||||||||||||||||||||||||||||||||||
| 4950 | # attribute. Individual accumulators are at liberty to | ||||||||||||||||||||||||||||||||||||||||||||||
| 4951 | # ignore this. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4952 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 4953 | # The return is a code reference. This reference is intended to be | ||||||||||||||||||||||||||||||||||||||||||||||
| 4954 | # called as | ||||||||||||||||||||||||||||||||||||||||||||||
| 4955 | # $accumulator->( $self, $resp ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 4956 | # for each successful HTTP response. After all responses have been | ||||||||||||||||||||||||||||||||||||||||||||||
| 4957 | # processed, the accumulated data are retrieved using | ||||||||||||||||||||||||||||||||||||||||||||||
| 4958 | # ( $content, $data ) = $accumulator( $self ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 4959 | # The first return is the text representation of the accumulated | ||||||||||||||||||||||||||||||||||||||||||||||
| 4960 | # data. The second is the decoded data, and is returned at the | ||||||||||||||||||||||||||||||||||||||||||||||
| 4961 | # accumulator's option. In scalar context only $content is returned. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4962 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4963 | 80 | ▶ | sub _accumulator_for { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accumulator_for: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4964 | 80 | my ( $format, $opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4965 | 80 | ▶ | my $name = $format_map{$format} || $format; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$format_map{$format} || $format
MC/DC0%0/2
$format_map{$format} || $format
$format_map{$format}
$format
Truth table66%2/3
A || B
A= $format_map{$format}B= $format
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4966 | 80 | ▶ | my $accumulator = __PACKAGE__->can( "_accumulate_${name}_data" ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
__PACKAGE__->can("_accumulate_${name}_data") || \&Astro::SpaceTrack::_accumulate_unknown_data
MC/DC0%0/1
__PACKAGE__->can("_accumulate_${name}_data") || \&Astro::SpaceTrack::_accumulate_unknown_data
__PACKAGE__->can("_accumulate_${name}_data")
Truth table50%1/2
A
A= __PACKAGE__->can("_accumulate_${name}_data")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4967 | || \&_accumulate_unknown_data; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4968 | my $returner = __PACKAGE__->can( "_accumulate_${name}_return" ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 4969 | 19 | ▶ | || sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4970 | 19 | my ( undef, $context ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4971 | 19 | return $context->{data}; | |||||||||||||||||||||||||||||||||||||||||||||
| 4972 | 80 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
__PACKAGE__->can("_accumulate_${name}_return") || sub {
my(undef, $context) = @_;
return $context->{'data'};
}
MC/DC0%0/2
__PACKAGE__->can("_accumulate_${name}_return") || sub {
my(undef, $context) = @_;
return $context->{'data'};
}
__PACKAGE__->can("_accumulate_${name}_return")
sub {
my(undef, $context) = @_;
return $context->{'data'};
}
Truth table66%2/3
A || B
A= __PACKAGE__->can("_accumulate_${name}_return")B= sub {
my(undef, $context) = @_;
return $context->{'data'};
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4973 | 80 | ▶ | my $context = { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt || {}
MC/DC100%1/1
$opt || {}
$opt
Truth table100%2/2
A
A= $opt
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4974 | format => $format, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4975 | opt => $opt || {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 4976 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4977 | 100 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4978 | 100 | my ( $self, $resp ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 4979 | 100 | ▶ | defined $resp | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4980 | or return $returner->( $self, $context ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4981 | 51 | my $content = $resp->content(); | |||||||||||||||||||||||||||||||||||||||||||||
| 4982 | 51 | ▶ | defined $content | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $content and $content ne ""
MC/DC0%0/2
defined $content and $content ne ""
defined $content
$content ne ""
Truth table33%1/3
A and B
A= defined $contentB= $content ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4983 | and $content ne '' | ||||||||||||||||||||||||||||||||||||||||||||||
| 4984 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4985 | 51 | my $data = $accumulator->( $self, $content, $context ); | |||||||||||||||||||||||||||||||||||||||||||||
| 4986 | $context->{opt}{file} | ||||||||||||||||||||||||||||||||||||||||||||||
| 4987 | 51 | ▶ | and $data | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$context->{"opt"}{"file"} and $data
MC/DC100%2/2
$context->{"opt"}{"file"} and $data
$context->{"opt"}{"file"}
$data
Truth table100%3/3
A and B
A= $context->{"opt"}{"file"}B= $data
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4988 | and _accumulate_file_of_record( $self, $context, $data ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 4989 | 51 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 4990 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4991 | 80 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 4992 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4993 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 4994 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4995 | 7 | ▶ | sub _accumulate_file_of_record { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accumulate_file_of_record: called CC=5 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4996 | 1 | my ( undef, $context, $data ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 4997 | 1 | ▶ | if ( defined $context->{file} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4998 | 0 | foreach my $datum ( @{ $data } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 4999 | defined $datum->{FILE} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5000 | and $datum->{FILE} > $context->{file} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5001 | 0 | ▶ | and $datum->{_file_of_record} = $context->{file}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $datum->{"FILE"} and $datum->{"FILE"} > $context->{"file"}
MC/DC0%0/2
defined $datum->{"FILE"} and $datum->{"FILE"} > $context->{"file"}
defined $datum->{"FILE"}
$datum->{"FILE"} > $context->{"file"}
Truth table0%0/3
A and B
A= defined $datum->{"FILE"}B= $datum->{"FILE"} > $context->{"file"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5002 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5003 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5004 | $context->{file} = List::Util::max( -1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5005 | 1 | map { $_->{FILE} } | |||||||||||||||||||||||||||||||||||||||||||||
| 5006 | 1 | grep { defined $_->{FILE} } | |||||||||||||||||||||||||||||||||||||||||||||
| 5007 | 1 | @{ $data } | |||||||||||||||||||||||||||||||||||||||||||||
| 5008 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5009 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5010 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5011 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5012 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5013 | # The data accumulators. The conventions which must be followed are | ||||||||||||||||||||||||||||||||||||||||||||||
| 5014 | # that, given a format named 'fmt': | ||||||||||||||||||||||||||||||||||||||||||||||
| 5015 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 5016 | # 1) There MUST be an accumulator named _accumulate_fmt_data(). Its | ||||||||||||||||||||||||||||||||||||||||||||||
| 5017 | # arguments are the invocant, the content of the return, and the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5018 | # context hash. It must accumulate data in $context->{data}, in any | ||||||||||||||||||||||||||||||||||||||||||||||
| 5019 | # format it likes. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5020 | # 2) If _accumulate_fmt_data() decodes the data, it SHOULD return a | ||||||||||||||||||||||||||||||||||||||||||||||
| 5021 | # reference to the decoded array. Otherwise it MUST return nothing. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5022 | # 3) There MAY be a returner named _accumulate_fmt_return(). If it | ||||||||||||||||||||||||||||||||||||||||||||||
| 5023 | # exists its arguments are the invocant and the context hash. It MUST | ||||||||||||||||||||||||||||||||||||||||||||||
| 5024 | # return a valid representation of the accumulated data in the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5025 | # desired format. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5026 | # 4) If _accumulate_fmt_return() does not exist, the return will be the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5027 | # contents of $context->{data}, which MUST have been maintained by | ||||||||||||||||||||||||||||||||||||||||||||||
| 5028 | # _accumulate_fmt_data() as a valid representation of the data in the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5029 | # desired format. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5030 | # 5) Note that if _accumulate_fmt_return() exists, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5031 | # _accumulate_fmt_data need not maintain $context->{data} as a valid | ||||||||||||||||||||||||||||||||||||||||||||||
| 5032 | # representation of the accumulated data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5033 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5034 | # Accessed via __PACKAGE__->can( "accumulate_${name}_data" ) in | ||||||||||||||||||||||||||||||||||||||||||||||
| 5035 | # _accumulator_for(), above | ||||||||||||||||||||||||||||||||||||||||||||||
| 5036 | 0 | ▶ | sub _accumulate_csv_data { ## no critic (ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accumulate_csv_data: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5037 | 0 | my ( undef, $content, $context ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 5038 | 0 | ▶ | if ( defined $context->{data} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5039 | 0 | $context->{data} =~ s{ (?<! \n ) \z }{\n}smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5040 | 0 | $content =~ s{ .* \n }{}smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5041 | 0 | $context->{data} .= $content; | |||||||||||||||||||||||||||||||||||||||||||||
| 5042 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5043 | 0 | $context->{data} = $content; | |||||||||||||||||||||||||||||||||||||||||||||
| 5044 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5045 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5046 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5047 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5048 | # Accessed via __PACKAGE__->can( "accumulate_${name}_data" ) in | ||||||||||||||||||||||||||||||||||||||||||||||
| 5049 | # _accumulator_for(), above | ||||||||||||||||||||||||||||||||||||||||||||||
| 5050 | 0 | ▶ | sub _accumulate_html_data { ## no critic (ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accumulate_html_data: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5051 | 0 | my ( undef, $content, $context ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 5052 | 0 | ▶ | if ( defined $context->{data} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5053 | 0 | $context->{data} =~ s{ \s* </tbody> \s* </table> \s* \z }{}smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5054 | 0 | $content =~ s{ .* <tbody> \s* }{}smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5055 | 0 | $context->{data} .= $content; | |||||||||||||||||||||||||||||||||||||||||||||
| 5056 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5057 | 0 | $context->{data} = $content; | |||||||||||||||||||||||||||||||||||||||||||||
| 5058 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5059 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5060 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5061 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5062 | # Accessed via __PACKAGE__->can( "accumulate_${name}_data" ) in | ||||||||||||||||||||||||||||||||||||||||||||||
| 5063 | # _accumulator_for(), above | ||||||||||||||||||||||||||||||||||||||||||||||
| 5064 | 31 | ▶ | sub _accumulate_json_data { ## no critic (ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accumulate_json_data: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5065 | 31 | my ( $self, $content, $context ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5066 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5067 | my $json = $context->{json} ||= $self->_get_json_object( | ||||||||||||||||||||||||||||||||||||||||||||||
| 5068 | pretty => $context->{opt}{pretty}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5069 | 31 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$context->{"json"} ||= $self->_get_json_object("pretty", $context->{"opt"}{"pretty"})
MC/DC0%0/2
$context->{"json"} ||= $self->_get_json_object("pretty", $context->{"opt"}{"pretty"})
$context->{"json"}
$self->_get_json_object("pretty", $context->{"opt"}{"pretty"})
Truth table66%2/3
A ||= B
A= $context->{"json"}B= $self->_get_json_object("pretty", $context->{"opt"}{"pretty"})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5070 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5071 | 31 | my $data = $json->decode( $content ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5072 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5073 | 31 | ▶ | ARRAY_REF eq ref $data | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5074 | or $data = [ $data ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5075 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5076 | 31 | ▶ | @{ $data } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5077 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5078 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5079 | 30 | ▶ | if ( $context->{data} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5080 | 1 | push @{ $context->{data} }, @{ $data }; | |||||||||||||||||||||||||||||||||||||||||||||
| 5081 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5082 | 29 | $context->{data} = $data; | |||||||||||||||||||||||||||||||||||||||||||||
| 5083 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5084 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5085 | 30 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||
| 5086 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5087 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5088 | # Accessed via __PACKAGE__->can( "accumulate_${name}_return" ) in | ||||||||||||||||||||||||||||||||||||||||||||||
| 5089 | # _accumulator_for(), above | ||||||||||||||||||||||||||||||||||||||||||||||
| 5090 | 30 | ▶ | sub _accumulate_json_return { ## no critic (ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accumulate_json_return: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5091 | 30 | my ( $self, $context ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5092 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5093 | my $json = $context->{json} ||= $self->_get_json_object( | ||||||||||||||||||||||||||||||||||||||||||||||
| 5094 | pretty => $context->{opt}{pretty}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5095 | 30 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$context->{"json"} ||= $self->_get_json_object("pretty", $context->{"opt"}{"pretty"})
MC/DC0%0/2
$context->{"json"} ||= $self->_get_json_object("pretty", $context->{"opt"}{"pretty"})
$context->{"json"}
$self->_get_json_object("pretty", $context->{"opt"}{"pretty"})
Truth table33%1/3
A ||= B
A= $context->{"json"}B= $self->_get_json_object("pretty", $context->{"opt"}{"pretty"})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5096 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5097 | 30 | ▶ | $context->{data} ||= []; # In case we did not find anything. | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$context->{"data"} ||= []
MC/DC100%1/1
$context->{"data"} ||= []
$context->{"data"}
Truth table100%2/2
A
A= $context->{"data"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5098 | return wantarray | ||||||||||||||||||||||||||||||||||||||||||||||
| 5099 | ? ( $json->encode( $context->{data} ), $context->{data} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 5100 | 30 | ▶ | : $json->encode( $context->{data} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5101 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5103 | 0 | ▶ | sub _accumulate_unknown_data { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accumulate_unknown_data: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5104 | 0 | my ( undef, $content, $context ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 5105 | defined $context->{data} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5106 | 0 | ▶ | and Carp::croak "Unable to accumulate $context->{format} data"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5107 | 0 | $context->{data} = $content; | |||||||||||||||||||||||||||||||||||||||||||||
| 5108 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5109 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5111 | # Accessed via __PACKAGE__->can( "accumulate_${name}_data" ) in | ||||||||||||||||||||||||||||||||||||||||||||||
| 5112 | # _accumulator_for(), above | ||||||||||||||||||||||||||||||||||||||||||||||
| 5113 | 20 | ▶ | sub _accumulate_tle_data { ## no critic (ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accumulate_tle_data: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5114 | 20 | my ( undef, $content, $context ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 5115 | 20 | $context->{data} .= $content; | |||||||||||||||||||||||||||||||||||||||||||||
| 5116 | 20 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5117 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5119 | # Accessed via __PACKAGE__->can( "accumulate_${name}_data" ) in | ||||||||||||||||||||||||||||||||||||||||||||||
| 5120 | # _accumulator_for(), above | ||||||||||||||||||||||||||||||||||||||||||||||
| 5121 | 0 | ▶ | sub _accumulate_xml_data { ## no critic (ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accumulate_xml_data: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5122 | 0 | my ( undef, $content, $context ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5123 | 0 | ▶ | if ( defined $context->{data} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5124 | 0 | $context->{data} =~ s{ \s* </xml> \s* \z }{}smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5125 | 0 | $content =~ s{ .* <xml> \s* }{}smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5126 | 0 | $context->{data} .= $content; | |||||||||||||||||||||||||||||||||||||||||||||
| 5127 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5128 | 0 | $context->{data} = $content; | |||||||||||||||||||||||||||||||||||||||||||||
| 5129 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5130 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5131 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5133 | # _check_cookie_generic looks for our session cookie. If it is found, it | ||||||||||||||||||||||||||||||||||||||||||||||
| 5134 | # returns true if it thinks the cookie is valid, and false otherwise. If | ||||||||||||||||||||||||||||||||||||||||||||||
| 5135 | # it is not found, it returns false. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5137 | 2 | ▶ | sub _record_cookie_generic { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_record_cookie_generic: called CC=10 SCAR=27.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5138 | 2 | my ( $self, $version ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5139 | defined $version | ||||||||||||||||||||||||||||||||||||||||||||||
| 5140 | 2 | ▶ | or $version = $self->{space_track_version}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5141 | 2 | my $interface_info = $self->{_space_track_interface}[$version]; | |||||||||||||||||||||||||||||||||||||||||||||
| 5142 | 2 | my $cookie_name = $interface_info->{cookie_name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 5143 | 2 | my $domain = $interface_info->{domain_space_track}; | |||||||||||||||||||||||||||||||||||||||||||||
| 5144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5145 | 2 | my ( $cookie, $expires ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5146 | 2 | ▶ | $self->_get_agent()->cookie_jar->scan( sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5147 | 2 | ▶ | $self->{dump_headers} & DUMP_COOKIE | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5148 | and $self->_dump_cookie( "_record_cookie_generic:\n", @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5149 | 2 | ▶ | $_[4] eq $domain | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5150 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5151 | 2 | ▶ | $_[3] eq SESSION_PATH | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5152 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5153 | 2 | ▶ | $_[1] eq $cookie_name | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5154 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5155 | 2 | ( $cookie, $expires ) = @_[2, 8]; | |||||||||||||||||||||||||||||||||||||||||||||
| 5156 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5157 | 2 | } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5158 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5159 | # I don't get an expiration time back from the version 2 interface. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5160 | # But the docs say the cookie is only good for about two hours, so | ||||||||||||||||||||||||||||||||||||||||||||||
| 5161 | # to be on the safe side I fudge in an hour. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5162 | 2 | ▶ | $version == 2 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$version == 2 and not defined $expires
MC/DC0%0/2
$version == 2 and not defined $expires
$version == 2
not defined $expires
Truth table33%1/3
A and not(B)
A= $version == 2B= not defined $expires
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5163 | and not defined $expires | ||||||||||||||||||||||||||||||||||||||||||||||
| 5164 | and $expires = time + 3600; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5166 | 2 | ▶ | if ( defined $cookie ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5167 | 2 | $interface_info->{session_cookie} = $cookie; | |||||||||||||||||||||||||||||||||||||||||||||
| 5168 | 2 | ▶ | $self->{dump_headers} & DUMP_TRACE | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5169 | and warn "Session cookie: $cookie\n"; ## no critic (RequireCarping) | ||||||||||||||||||||||||||||||||||||||||||||||
| 5170 | 2 | ▶ | if ( exists $interface_info->{cookie_expires} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5171 | 2 | $interface_info->{cookie_expires} = $expires; | |||||||||||||||||||||||||||||||||||||||||||||
| 5172 | 2 | ▶ | $self->{dump_headers} & DUMP_TRACE | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5173 | and warn 'Cookie expiration: ', | ||||||||||||||||||||||||||||||||||||||||||||||
| 5174 | POSIX::strftime( '%d-%b-%Y %H:%M:%S', localtime $expires ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 5175 | " ($expires)\n"; ## no critic (RequireCarping) | ||||||||||||||||||||||||||||||||||||||||||||||
| 5176 | 2 | return $expires > time; | |||||||||||||||||||||||||||||||||||||||||||||
| 5177 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5178 | 0 | ▶ | return $interface_info->{session_cookie} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5179 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5180 | 0 | ▶ | $self->{dump_headers} & DUMP_TRACE | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5181 | and warn "Session cookie not found\n"; ## no critic (RequireCarping) | ||||||||||||||||||||||||||||||||||||||||||||||
| 5182 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5183 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5184 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5186 | 46 | ▶ | sub _check_cookie_generic { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_cookie_generic: called CC=4 SCAR=15.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5187 | 46 | my ( $self, $version ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5188 | defined $version | ||||||||||||||||||||||||||||||||||||||||||||||
| 5189 | 46 | ▶ | or $version = $self->{space_track_version}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5190 | 46 | my $interface_info = $self->{_space_track_interface}[$version]; | |||||||||||||||||||||||||||||||||||||||||||||
| 5191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5192 | 46 | ▶ | if ( exists $interface_info->{cookie_expires} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5193 | return defined $interface_info->{cookie_expires} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5194 | 46 | ▶ | && $interface_info->{cookie_expires} > time; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $interface_info->{'cookie_expires'} && $interface_info->{'cookie_expires'} > time
MC/DC50%1/2
defined $interface_info->{'cookie_expires'} && $interface_info->{'cookie_expires'} > time
defined $interface_info->{'cookie_expires'}
$interface_info->{'cookie_expires'} > time
Truth table66%2/3
A && B
A= defined $interface_info->{'cookie_expires'}B= $interface_info->{'cookie_expires'} > time
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5195 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5196 | 0 | return defined $interface_info->{session_cookie}; | |||||||||||||||||||||||||||||||||||||||||||||
| 5197 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5198 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5199 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5200 | # _convert_content converts the content of an HTTP::Response | ||||||||||||||||||||||||||||||||||||||||||||||
| 5201 | # from crlf-delimited to lf-delimited. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5203 | { # Begin local symbol block | ||||||||||||||||||||||||||||||||||||||||||||||
| 5204 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5205 | 7 | ▶ | my $lookfor = $^O eq 'MacOS' ? qr{ \012|\015+ }smx : qr{ \r \n }smx; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5206 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5207 | 26 | ▶ | sub _convert_content { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_content: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5208 | 26 | my ( undef, @args ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 5209 | 26 | local $/ = undef; # Slurp mode. | |||||||||||||||||||||||||||||||||||||||||||||
| 5210 | 26 | foreach my $resp (@args) { | |||||||||||||||||||||||||||||||||||||||||||||
| 5211 | 26 | my $buffer = $resp->content; | |||||||||||||||||||||||||||||||||||||||||||||
| 5212 | # If we request a non-existent Space Track catalog number, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5213 | # we get 200 OK but the unzipped content is undefined. We | ||||||||||||||||||||||||||||||||||||||||||||||
| 5214 | # catch this before we get this far, but the buffer check is | ||||||||||||||||||||||||||||||||||||||||||||||
| 5215 | # left in in case something else leaks through. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5216 | 26 | ▶ | defined $buffer or $buffer = ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5217 | 26 | $buffer =~ s/$lookfor/\n/smxgo; | |||||||||||||||||||||||||||||||||||||||||||||
| 5218 | 26 | ▶ | 1 while ($buffer =~ s/ \A \n+ //smx); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5219 | 26 | $buffer =~ s/ \s+ \n /\n/smxg; | |||||||||||||||||||||||||||||||||||||||||||||
| 5220 | 26 | ▶ | $buffer =~ m/ \n \z /smx or $buffer .= "\n"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5221 | 26 | $resp->content ($buffer); | |||||||||||||||||||||||||||||||||||||||||||||
| 5222 | 26 | $resp->header ( | |||||||||||||||||||||||||||||||||||||||||||||
| 5223 | 'content-length' => length ($buffer), | ||||||||||||||||||||||||||||||||||||||||||||||
| 5224 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5225 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5226 | 26 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5227 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5228 | } # End local symbol block. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5230 | # $self->_deprecation_notice( $method, $argument ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5231 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 5232 | # This method centralizes deprecation. Deprecation is driven of | ||||||||||||||||||||||||||||||||||||||||||||||
| 5233 | # the %deprecate hash. Values are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 5234 | # false - no warning | ||||||||||||||||||||||||||||||||||||||||||||||
| 5235 | # 1 - warn on first use | ||||||||||||||||||||||||||||||||||||||||||||||
| 5236 | # 2 - warn on each use | ||||||||||||||||||||||||||||||||||||||||||||||
| 5237 | # 3 - die on each use. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5238 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5239 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5240 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5241 | 7 | ▶ | use constant _MASTER_IRIDIUM_DEPRECATION_LEVEL => 3; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5242 | 7 | ▶ | use constant _MASTER_FAVORITE_DEPRECATION_LEVEL => 3; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5244 | 7 | my %deprecate = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 5245 | celestrak => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5246 | # sts => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5247 | # '--descending' => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5248 | # '--end_epoch' => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5249 | # '--last5' => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5250 | # '--sort' => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5251 | # '--start_epoch' => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5252 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5253 | amsat => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5254 | attribute => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5255 | # direct => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5256 | url_iridium_status_kelso => _MASTER_IRIDIUM_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5257 | url_iridium_status_mccants => _MASTER_IRIDIUM_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5258 | url_iridium_status_sladen => _MASTER_IRIDIUM_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5259 | iridium_status_format => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5260 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5261 | iridium_status => _MASTER_IRIDIUM_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5262 | iridium_status_format => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5263 | kelso => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5264 | mccants => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5265 | sladen => _MASTER_IRIDIUM_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5266 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5267 | option => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5268 | last5 => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5269 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5270 | # mccants => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5271 | # mcnames => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5272 | # quicksat => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5273 | # vsnames => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5274 | # }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5275 | BODY_STATUS_IS_OPERATIONAL => _MASTER_IRIDIUM_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5276 | BODY_STATUS_IS_SPARE => _MASTER_IRIDIUM_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5277 | BODY_STATUS_IS_TUMBLING => _MASTER_IRIDIUM_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5278 | BODY_STATUS_IS_DECAYED => _MASTER_IRIDIUM_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5279 | spacetrack => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5280 | navigation => _MASTER_FAVORITE_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5281 | weather => _MASTER_FAVORITE_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5282 | amateur => _MASTER_FAVORITE_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5283 | visible => _MASTER_FAVORITE_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5284 | special => _MASTER_FAVORITE_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5285 | bright_geosynchronous => _MASTER_FAVORITE_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5286 | human_spaceflight => _MASTER_FAVORITE_DEPRECATION_LEVEL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5287 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5288 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5289 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5290 | 73 | ▶ | sub _deprecation_notice { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deprecation_notice: called CC=10 SCAR=34.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5291 | 73 | my ( undef, $method, $argument ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 5292 | 73 | ▶ | defined $method | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5293 | or ( $method = ( caller 1 )[3] ) =~ s/ .* :: //smx; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5294 | 73 | ▶ | my $level = $deprecate{$method} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5295 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5296 | 71 | my $desc = $method; | |||||||||||||||||||||||||||||||||||||||||||||
| 5297 | 71 | ▶ | if ( ref $level ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5298 | 71 | ▶ | defined $argument or Carp::confess( 'Bug - $argument undefined' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5299 | 71 | ▶ | $level = $level->{$argument} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5300 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5301 | 0 | $desc = "$method $argument"; | |||||||||||||||||||||||||||||||||||||||||||||
| 5302 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5303 | 0 | ▶ | $level >= 3 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5304 | and Carp::croak "$desc is retracted"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5305 | 0 | ▶ | warnings::enabled( 'deprecated' ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5306 | and Carp::carp "$desc is deprecated"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5307 | 0 | ▶ | 1 == $level | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5308 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5309 | 0 | ▶ | if ( ref $deprecate{$method} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5310 | 0 | $deprecate{$method}{$argument} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 5311 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5312 | 0 | $deprecate{$method} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 5313 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5314 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5315 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5316 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5317 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5318 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5319 | # _dump_cookie is intended to be called from inside the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5320 | # HTTP::Cookie->scan method. The first argument is prefix text | ||||||||||||||||||||||||||||||||||||||||||||||
| 5321 | # for the dump, and the subsequent arguments are the arguments | ||||||||||||||||||||||||||||||||||||||||||||||
| 5322 | # passed to the scan method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5323 | # It dumps the contents of the cookie to STDERR via a warn (). | ||||||||||||||||||||||||||||||||||||||||||||||
| 5324 | # A typical session cookie looks like this: | ||||||||||||||||||||||||||||||||||||||||||||||
| 5325 | # version => 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 5326 | # key => 'spacetrack_session' | ||||||||||||||||||||||||||||||||||||||||||||||
| 5327 | # val => whatever | ||||||||||||||||||||||||||||||||||||||||||||||
| 5328 | # path => '/' | ||||||||||||||||||||||||||||||||||||||||||||||
| 5329 | # domain => 'www.space-track.org' | ||||||||||||||||||||||||||||||||||||||||||||||
| 5330 | # port => undef | ||||||||||||||||||||||||||||||||||||||||||||||
| 5331 | # path_spec => 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 5332 | # secure => undef | ||||||||||||||||||||||||||||||||||||||||||||||
| 5333 | # expires => undef | ||||||||||||||||||||||||||||||||||||||||||||||
| 5334 | # discard => 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 5335 | # hash => {} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5336 | # The response to the login, though, has an actual expiration | ||||||||||||||||||||||||||||||||||||||||||||||
| 5337 | # time, which we take cognisance of. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5338 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5339 | { # begin local symbol block | ||||||||||||||||||||||||||||||||||||||||||||||
| 5340 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5341 | 7 | my @names = qw{version key val path domain port path_spec secure | |||||||||||||||||||||||||||||||||||||||||||||
| 5342 | expires discard hash}; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5343 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5344 | 0 | ▶ | sub _dump_cookie { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dump_cookie: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5345 | 0 | my ( $self, $prefix, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5346 | 0 | my $json = $self->_get_json_object( pretty => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5347 | 0 | ▶ | $prefix and warn $prefix; ## no critic (RequireCarping) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5348 | 0 | ▶ | for (my $inx = 0; $inx < @names; $inx++) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5349 | 0 | warn " $names[$inx] => ", $json->encode( $args[$inx] ); ## no critic (RequireCarping) | |||||||||||||||||||||||||||||||||||||||||||||
| 5350 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5351 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5352 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5353 | } # end local symbol block | ||||||||||||||||||||||||||||||||||||||||||||||
| 5354 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5355 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5356 | # __dump_response dumps the headers of the passed-in response | ||||||||||||||||||||||||||||||||||||||||||||||
| 5357 | # object. The hook is used for capturing responses to use when | ||||||||||||||||||||||||||||||||||||||||||||||
| 5358 | # mocking LWP::UserAgent, and is UNSUPPORTED, and subject to | ||||||||||||||||||||||||||||||||||||||||||||||
| 5359 | # change or retraction without notice. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5360 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5361 | 7 | ▶ | sub __dump_response { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__dump_response: called CC=8 SCAR=38.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5362 | 108 | my ( $self, $resp, $message ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5364 | 108 | ▶ | if ( $self->{dump_headers} & DUMP_RESPONSE ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5365 | 0 | my $content = $resp->content(); | |||||||||||||||||||||||||||||||||||||||||||||
| 5366 | 0 | ▶ | if ( $self->{dump_headers} & DUMP_TRUNCATED | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"dump_headers"} & 32 and 61 < length $content
MC/DC0%0/2
$self->{"dump_headers"} & 32 and 61 < length $content
$self->{"dump_headers"} & 32
61 < length $content
Truth table0%0/3
A and B
A= $self->{"dump_headers"} & 32B= 61 < length $content
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5367 | && 61 < length $content ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5368 | 0 | $content = substr( $content, 0, 61 ) . '...'; | |||||||||||||||||||||||||||||||||||||||||||||
| 5369 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5370 | 0 | my @data = ( $resp->code(), $resp->message(), [], $content ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5371 | 0 | foreach my $name ( $resp->headers()->header_field_names() ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 5372 | 0 | my @val = $resp->header( $name ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5373 | 0 | ▶ | push @{ $data[2] }, $name, @val > 1 ? \@val : $val[0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5374 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5375 | 0 | ▶ | if ( my $rqst = $resp->request() ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5376 | 0 | push @data, { | |||||||||||||||||||||||||||||||||||||||||||||
| 5377 | method => $rqst->method(), | ||||||||||||||||||||||||||||||||||||||||||||||
| 5378 | uri => '' . $rqst->uri(), # Force stringification | ||||||||||||||||||||||||||||||||||||||||||||||
| 5379 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5380 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5381 | 0 | my $encoded = $self->_get_json_object( pretty => 1 )->encode( | |||||||||||||||||||||||||||||||||||||||||||||
| 5382 | \@data ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5383 | 0 | ▶ | defined $message | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5384 | or $message = 'Response object'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5385 | 0 | $message =~ s/ \s+ \z //smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5386 | 0 | warn "$message:\n$encoded"; | |||||||||||||||||||||||||||||||||||||||||||||
| 5387 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5388 | 108 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5389 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5390 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5391 | # _dump_request dumps the request if desired. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5392 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 5393 | # If the dump_request attribute has the DUMP_REQUEST bit set, this | ||||||||||||||||||||||||||||||||||||||||||||||
| 5394 | # routine dumps the request. If the DUMP_DRY_RUN bit is set, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5395 | # the dump is returned in the content of an HTTP::Response object, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5396 | # with the response code set to HTTP_I_AM_A_TEAPOT. Otherwise the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5397 | # request is dumped to STDERR. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5398 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 5399 | # If any of the conditions fails, this module simply returns. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5400 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5401 | 106 | ▶ | sub _dump_request { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dump_request: called CC=7 SCAR=21.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5402 | 106 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5403 | 106 | ▶ | $self->{dump_headers} & DUMP_REQUEST | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5404 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5405 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5406 | 46 | my $message = delete $args{message}; | |||||||||||||||||||||||||||||||||||||||||||||
| 5407 | 46 | ▶ | defined $message | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5408 | or $message = 'Request object'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5409 | 46 | $message =~ s/ \s* \z /:\n/smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5410 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5411 | 46 | ▶ | my $json = $self->_get_json_object( pretty => 1 ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5412 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5413 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5414 | 46 | foreach my $key ( keys %args ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 5415 | 184 | ▶ | CODE_REF eq ref $args{$key} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5416 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5417 | 0 | $args{$key} = $args{$key}->( \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5418 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5419 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5420 | 46 | ▶ | $self->{dump_headers} & DUMP_DRY_RUN | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5421 | and return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 5422 | HTTP_I_AM_A_TEAPOT, undef, undef, $json->encode( [ \%args ] ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 5423 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5424 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5425 | 0 | warn $message, $json->encode( \%args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5426 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5427 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5428 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5429 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5430 | 79 | ▶ | sub _get_json_object { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_json_object: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5431 | 79 | my ( $self, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5432 | defined $arg{pretty} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5433 | 79 | ▶ | or $arg{pretty} = $self->{pretty}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5434 | 79 | my $json = JSON->new()->utf8()->convert_blessed(); | |||||||||||||||||||||||||||||||||||||||||||||
| 5435 | $arg{pretty} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5436 | 79 | ▶ | and $json->pretty()->canonical(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5437 | 79 | return $json; | |||||||||||||||||||||||||||||||||||||||||||||
| 5438 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5439 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5440 | # my @oids = $self->_expand_oid_list( @args ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5441 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 5442 | # This subroutine expands the input into a list of OIDs. Commas are | ||||||||||||||||||||||||||||||||||||||||||||||
| 5443 | # recognized as separating an argument into multiple specifications. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5444 | # Dashes are recognized as range operators, which are expanded. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 5445 | # result is returned. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5446 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5447 | 43 | ▶ | sub _expand_oid_list { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_oid_list: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5448 | 43 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5449 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5450 | 43 | my @rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 5451 | 43 | foreach my $arg ( map { split qr{ , | \s+ }smx, $_ } @args ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 5452 | 208 | ▶ | if ( my ( $lo, $hi ) = $arg =~ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5453 | m/ \A \s* ( \d+ ) \s* - \s* ( \d+ ) \s* \z /smx | ||||||||||||||||||||||||||||||||||||||||||||||
| 5454 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5455 | 1 | ▶ | ( $lo, $hi ) = $self->_check_range( $lo, $hi ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5456 | and push @rslt, $lo .. $hi; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5457 | } elsif ( $arg =~ m/ \A \s* ( \d+ ) \s* \z /smx ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5458 | 207 | push @rslt, $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 5459 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5460 | # TODO -- ignore? die? what? | ||||||||||||||||||||||||||||||||||||||||||||||
| 5461 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5462 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5463 | 43 | return @rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 5464 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5465 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5466 | # Take as input a reference to one of the legal options arrays, and | ||||||||||||||||||||||||||||||||||||||||||||||
| 5467 | # extract the equivalent keys. The return is suitable for assigning to a | ||||||||||||||||||||||||||||||||||||||||||||||
| 5468 | # hash used to test the keys; that is, it is ( key0 => 1, key1 => 1, ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 5469 | # ). | ||||||||||||||||||||||||||||||||||||||||||||||
| 5470 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5471 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5472 | 7 | my $strip = qr{ [=:|!+] .* }smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5473 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5474 | 25 | ▶ | sub _extract_keys { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_keys: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5475 | 25 | my ( $lgl_opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5476 | 25 | ▶ | if ( ARRAY_REF eq ref $lgl_opts ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5477 | 25 | my $len = @{ $lgl_opts }; | |||||||||||||||||||||||||||||||||||||||||||||
| 5478 | 25 | my @rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 5479 | 25 | ▶ | for ( my $inx = 0; $inx < $len; $inx += 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5480 | 192 | ( my $key = $lgl_opts->[$inx] ) =~ s/ $strip //smxo; | |||||||||||||||||||||||||||||||||||||||||||||
| 5481 | 192 | push @rslt, $key, 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 5482 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5483 | 25 | return @rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 5484 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5485 | 0 | $lgl_opts =~ s/ $strip //smxo; | |||||||||||||||||||||||||||||||||||||||||||||
| 5486 | 0 | return $lgl_opts; | |||||||||||||||||||||||||||||||||||||||||||||
| 5487 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5488 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5489 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5490 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5491 | # The following are data transform routines for _search_rest(). | ||||||||||||||||||||||||||||||||||||||||||||||
| 5492 | # The arguments are the datum and the class for which it is being | ||||||||||||||||||||||||||||||||||||||||||||||
| 5493 | # formatted. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5494 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5495 | # Parse an international launch id, and format it for a Space-Track REST | ||||||||||||||||||||||||||||||||||||||||||||||
| 5496 | # query. The parsing is done by _parse_international_id(). The | ||||||||||||||||||||||||||||||||||||||||||||||
| 5497 | # formatting prefixes the 'contains' wildcard '~~' unless year, sequence | ||||||||||||||||||||||||||||||||||||||||||||||
| 5498 | # and part are all present. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5499 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5500 | 7 | ▶ | sub _format_international_id_rest { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_format_international_id_rest: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5501 | 14 | my ( $intl_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5502 | 14 | my @parts = _parse_international_id( $intl_id ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5503 | 14 | ▶ | @parts >= 3 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5504 | and return sprintf '%04d-%03d%s', @parts; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5505 | 10 | ▶ | @parts >= 2 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5506 | and return sprintf '~~%04d-%03d', @parts; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5507 | 1 | return sprintf '~~%04d-', $parts[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 5508 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5509 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5510 | # Parse a launch date, and format it for a Space-Track REST query. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 5511 | # parsing is done by _parse_launch_date(). The formatting prefixes the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5512 | # 'contains' wildcard '~~' unless year, month, and day are all present. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5513 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5514 | 14 | ▶ | sub _format_launch_date_rest { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_format_launch_date_rest: called CC=4 SCAR=18.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5515 | 14 | my ( $date ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5516 | 14 | ▶ | my @parts = _parse_launch_date( $date ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5517 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5518 | 14 | ▶ | @parts >= 3 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5519 | and return sprintf '%04d-%02d-%02d', @parts; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5520 | 0 | ▶ | @parts >= 2 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5521 | and return sprintf '~~%04d-%02d', @parts; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5522 | 0 | return sprintf '~~%04d', $parts[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 5523 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5524 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5525 | # Note: If we have a bad cookie, we get a success status, with | ||||||||||||||||||||||||||||||||||||||||||||||
| 5526 | # the text | ||||||||||||||||||||||||||||||||||||||||||||||
| 5527 | # <?xml version="1.0" encoding="iso-8859-1"?> | ||||||||||||||||||||||||||||||||||||||||||||||
| 5528 | # <!DOCTYPE html | ||||||||||||||||||||||||||||||||||||||||||||||
| 5529 | # PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||||||||||||||||||||||||||||||||||||||||||||||
| 5530 | # "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||||||||||||||||||||||||||||||||||||||||||||||
| 5531 | # <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"><head><title>Space-Track</title> | ||||||||||||||||||||||||||||||||||||||||||||||
| 5532 | # </head><body> | ||||||||||||||||||||||||||||||||||||||||||||||
| 5533 | # <body bgcolor='#fffacd' text='#191970' link='#3333e6'> | ||||||||||||||||||||||||||||||||||||||||||||||
| 5534 | # <div align='center'><img src='http://www.space-track.org/icons/spacetrack_logo3.jpg' width=640 height=128 align='top' border=0></div> | ||||||||||||||||||||||||||||||||||||||||||||||
| 5535 | # <h2>Error, Corrupted session cookie<br> | ||||||||||||||||||||||||||||||||||||||||||||||
| 5536 | # Please <A HREF='login.pl'>LOGIN</A> again.<br> | ||||||||||||||||||||||||||||||||||||||||||||||
| 5537 | # </h2> | ||||||||||||||||||||||||||||||||||||||||||||||
| 5538 | # </body></html> | ||||||||||||||||||||||||||||||||||||||||||||||
| 5539 | # If this happens, it would be good to retry the login. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5540 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5541 | 56 | ▶ | sub _get_agent { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_agent: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5542 | 56 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5543 | $self->{agent} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5544 | 56 | ▶ | and return $self->{agent}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5545 | 4 | my $agent = $self->{agent} = LWP::UserAgent->new( | |||||||||||||||||||||||||||||||||||||||||||||
| 5546 | ssl_opts => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5547 | verify_hostname => $self->getv( 'verify_hostname' ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 5548 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5549 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5550 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5551 | 4 | $agent->env_proxy(); | |||||||||||||||||||||||||||||||||||||||||||||
| 5552 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5553 | 4 | ▶ | $agent->cookie_jar() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5554 | or $agent->cookie_jar( {} ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5555 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5556 | 4 | return $agent; | |||||||||||||||||||||||||||||||||||||||||||||
| 5557 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5558 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5559 | # $resp = $self->_get_from_net( name => value ... ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 5560 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 5561 | # This private method retrieves a URL and returns the response object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5562 | # The optional name/value pairs are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 5563 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 5564 | # catalog => catalog_name | ||||||||||||||||||||||||||||||||||||||||||||||
| 5565 | # If this exists, it is the name of the catalog to retrieve. An | ||||||||||||||||||||||||||||||||||||||||||||||
| 5566 | # error is returned if it is not defined, or if the catalog does | ||||||||||||||||||||||||||||||||||||||||||||||
| 5567 | # not exist. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5568 | # file => cache_file_name | ||||||||||||||||||||||||||||||||||||||||||||||
| 5569 | # If this is defined, the data are returned only if it has been | ||||||||||||||||||||||||||||||||||||||||||||||
| 5570 | # modified since the modification date of the file. If the data | ||||||||||||||||||||||||||||||||||||||||||||||
| 5571 | # have been modified, the cache file is refreshed; otherwise the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5572 | # response is loaded from the cache file. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5573 | # method => method_name | ||||||||||||||||||||||||||||||||||||||||||||||
| 5574 | # If this is defined, it is the name of the method doing the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5575 | # catalog lookup. This is unused unless 'catalog' is defined, and | ||||||||||||||||||||||||||||||||||||||||||||||
| 5576 | # defaults to the name of the calling method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5577 | # post_process => code reference | ||||||||||||||||||||||||||||||||||||||||||||||
| 5578 | # If the network operation succeeded and this is defined, it is | ||||||||||||||||||||||||||||||||||||||||||||||
| 5579 | # called and passed the invocant, the HTTP::Response object, and | ||||||||||||||||||||||||||||||||||||||||||||||
| 5580 | # a reference to the catalog information hash (or to an empty hash | ||||||||||||||||||||||||||||||||||||||||||||||
| 5581 | # if 'url' was specified). The HTTP::Response object returned | ||||||||||||||||||||||||||||||||||||||||||||||
| 5582 | # (which may or may not be the one passed in) is the basis for any | ||||||||||||||||||||||||||||||||||||||||||||||
| 5583 | # further processing. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5584 | # spacetrack_source => spacetrack_source | ||||||||||||||||||||||||||||||||||||||||||||||
| 5585 | # If this is defined, the corresponding-named pragma is set. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 5586 | # default comes from the same-named key in the catalog info if that | ||||||||||||||||||||||||||||||||||||||||||||||
| 5587 | # is defined, or the 'method' argument (as defaulted). | ||||||||||||||||||||||||||||||||||||||||||||||
| 5588 | # spacetrack_type => spacetrack_type | ||||||||||||||||||||||||||||||||||||||||||||||
| 5589 | # If this is defined, the corresponding-named pragma is set. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5590 | # url => URL | ||||||||||||||||||||||||||||||||||||||||||||||
| 5591 | # If this is defined, it is the URL of the data to retrieve. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5592 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 5593 | # Either 'catalog' or 'url' MUST be specified. If 'url' is defined, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5594 | # 'catalog' is ignored. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5595 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5596 | 7 | ▶ | sub _get_from_net { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_from_net: called CC=26 SCAR=46.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5597 | 7 | my ( $self, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5598 | 7 | delete $self->{_pragmata}; | |||||||||||||||||||||||||||||||||||||||||||||
| 5599 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5600 | 7 | ▶ | my $method = defined $arg{method} ? $arg{method} : ( caller 1)[3]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5601 | 7 | $method =~ s/ .* :: //smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5602 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5603 | 7 | my $url; | |||||||||||||||||||||||||||||||||||||||||||||
| 5604 | my $info; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5605 | 7 | ▶ | if ( defined $arg{url} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5606 | 4 | $url = $arg{url}; | |||||||||||||||||||||||||||||||||||||||||||||
| 5607 | 4 | $info = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 5608 | } elsif ( exists $arg{catalog} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5609 | defined $arg{catalog} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5610 | and $catalogs{$method} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5611 | and $info = $catalogs{$method}{$arg{catalog}} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5612 | 3 | ▶ | or return $self->_no_such_catalog( $method, $arg{catalog} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $arg{"catalog"} and $catalogs{$method} and $info = $catalogs{$method}{$arg{"catalog"}}
defined $arg{"catalog"} and $catalogs{$method}
MC/DC33%1/3
defined $arg{"catalog"} and $catalogs{$method} and $info = $catalogs{$method}{$arg{"catalog"}}
defined $arg{"catalog"}
$catalogs{$method}
$info = $catalogs{$method}{$arg{"catalog"}}
Truth table50%2/4
A and B and C
A= defined $arg{"catalog"}B= $catalogs{$method}C= $info = $catalogs{$method}{$arg{"catalog"}}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5613 | 2 | $self->_deprecation_notice( $method => $arg{catalog} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5614 | $url = $info->{url} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5615 | 2 | ▶ | or Carp::confess "Bug - No url defined for $method( '$arg{catalog}' )"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5616 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5617 | 0 | Carp::confess q<Bug - neither 'url' nor 'catalog' specified>; | |||||||||||||||||||||||||||||||||||||||||||||
| 5618 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5619 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5620 | 6 | ▶ | if ( my $resp = $self->_dump_request( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5621 | 21 | ▶ | args => { map { $_ => CODE_REF eq ref $arg{$_} ? 'sub { ... }' : $arg{$_} } keys %arg }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5622 | method => 'GET', | ||||||||||||||||||||||||||||||||||||||||||||||
| 5623 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5624 | version => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5625 | ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5626 | 0 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 5627 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5628 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5629 | 6 | my $agent = $self->_get_agent(); | |||||||||||||||||||||||||||||||||||||||||||||
| 5630 | 6 | my $rqst = HTTP::Request->new( GET => $url ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5631 | 6 | my $file_time; | |||||||||||||||||||||||||||||||||||||||||||||
| 5632 | 6 | ▶ | if ( defined $arg{file} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5633 | 0 | ▶ | if ( my @stat = stat $arg{file} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5634 | 0 | $file_time = HTTP::Date::time2str( $stat[9] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5635 | 0 | $rqst->header( if_modified_since => $file_time ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5636 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5637 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5638 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5639 | 6 | my $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 5640 | $resp = $self->_dump_request( | ||||||||||||||||||||||||||||||||||||||||||||||
| 5641 | 0 | ▶ | arg => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5642 | 0 | my %sanitary = %arg; | |||||||||||||||||||||||||||||||||||||||||||||
| 5643 | 0 | foreach my $key ( qw{ post_process } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 5644 | delete $sanitary{$key} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5645 | 0 | ▶ | and $sanitary{$key} = CODE_REF; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5646 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5647 | 0 | return \%sanitary; | |||||||||||||||||||||||||||||||||||||||||||||
| 5648 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5649 | message => '_get_from_net() request object', | ||||||||||||||||||||||||||||||||||||||||||||||
| 5650 | method => 'GET', | ||||||||||||||||||||||||||||||||||||||||||||||
| 5651 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5652 | 0 | ▶ | hdrs => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5653 | 0 | my %rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 5654 | 0 | foreach my $name ( $rqst->header_field_names() ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 5655 | 0 | my @v = $rqst->header( $name ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5656 | 0 | ▶ | $rslt{$name} = @v == 1 ? $v[0] : \@v; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5657 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5658 | 0 | return \%rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 5659 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5660 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 5661 | 6 | ▶ | and return $resp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5662 | 6 | $resp = $agent->request( $rqst ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5663 | 6 | $self->__dump_response( | |||||||||||||||||||||||||||||||||||||||||||||
| 5664 | $resp, '_get_from_net() initial response object' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5665 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5666 | 6 | ▶ | if ( $resp->code() == HTTP_NOT_MODIFIED ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5667 | defined $arg{file} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5668 | 0 | ▶ | or Carp::confess q{Programming Error - argument 'file' not defined}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5669 | 0 | local $/ = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 5670 | open my $fh, '<', $arg{file} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5671 | 0 | ▶ | or return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5672 | HTTP_INTERNAL_SERVER_ERROR, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5673 | "Unable to read $arg{file}: $!" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5674 | 0 | $resp->content( scalar <$fh> ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5675 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||
| 5676 | 0 | $resp->code( HTTP_OK ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5677 | 0 | ▶ | defined $file_time | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5678 | and $resp->header( last_modified => $file_time ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5679 | 0 | $arg{spacetrack_cache_hit} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 5680 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5681 | $resp->is_success() | ||||||||||||||||||||||||||||||||||||||||||||||
| 5682 | and defined $arg{post_process} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5683 | 6 | ▶ | and $resp = $arg{post_process}->( $self, $resp, $info ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$resp->is_success and defined $arg{"post_process"}
MC/DC0%0/2
$resp->is_success and defined $arg{"post_process"}
$resp->is_success
defined $arg{"post_process"}
Truth table33%1/3
A and B
A= $resp->is_successB= defined $arg{"post_process"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5684 | 6 | ▶ | $resp->is_success() # $resp may be a different object now. | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5685 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5686 | 5 | $self->_convert_content( $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5687 | 5 | ▶ | if ( defined $arg{file} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5688 | open my $fh, '>', $arg{file} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5689 | 0 | ▶ | or return HTTP::Response->new( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5690 | HTTP_INTERNAL_SERVER_ERROR, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5691 | "Unable to write $arg{file}: $!" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5692 | 0 | print { $fh } $resp->content(); | |||||||||||||||||||||||||||||||||||||||||||||
| 5693 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||
| 5694 | 0 | $arg{spacetrack_cache_hit} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 5695 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5696 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5697 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5698 | defined $arg{spacetrack_source} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5699 | or $arg{spacetrack_source} = | ||||||||||||||||||||||||||||||||||||||||||||||
| 5700 | defined $info->{spacetrack_source} ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 5701 | $info->{spacetrack_source} : | ||||||||||||||||||||||||||||||||||||||||||||||
| 5702 | 5 | ▶ | $method; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5703 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5704 | $self->_add_pragmata( $resp, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5705 | map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5706 | 5 | defined $arg{$_} ? ( $_ => $arg{$_} ) : | |||||||||||||||||||||||||||||||||||||||||||||
| 5707 | 15 | ▶ | defined $info->{$_} ? ( $_ => $info->{$_} ) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5708 | () | ||||||||||||||||||||||||||||||||||||||||||||||
| 5709 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5710 | qw{ spacetrack_type spacetrack_source spacetrack_cache_hit } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5711 | 5 | $self->__dump_response( $resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 5712 | '_get_from_net() final response object' ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5713 | 5 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 5714 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5715 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5716 | # _get_space_track_domain() returns the domain name portion of the Space | ||||||||||||||||||||||||||||||||||||||||||||||
| 5717 | # Track URL from the appropriate attribute. The argument is the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5718 | # interface version number, which defaults to the value of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5719 | # space_track_version attribute. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5720 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5721 | 96 | ▶ | sub _get_space_track_domain { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_space_track_domain: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5722 | 96 | my ( $self, $version ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5723 | defined $version | ||||||||||||||||||||||||||||||||||||||||||||||
| 5724 | 96 | ▶ | or $version = $self->{space_track_version}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5725 | 96 | return $self->{_space_track_interface}[$version]{domain_space_track}; | |||||||||||||||||||||||||||||||||||||||||||||
| 5726 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5727 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5728 | # __get_loader() retrieves a loader. A code reference to it is returned. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5729 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 5730 | # NOTE WELL: This subroutine is for the benefit of | ||||||||||||||||||||||||||||||||||||||||||||||
| 5731 | # t/spacetrack_request.t, and is called by that code. The leading double | ||||||||||||||||||||||||||||||||||||||||||||||
| 5732 | # underscore is to flag it to Perl::Critic as package private rather | ||||||||||||||||||||||||||||||||||||||||||||||
| 5733 | # than module private. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5734 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5735 | 1 | ▶ | sub __get_loader { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__get_loader: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5736 | ## my ( $invocant, %arg ) = @_; # Arguments unused | ||||||||||||||||||||||||||||||||||||||||||||||
| 5737 | 1 | my $json = JSON->new()->utf8( 1 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5738 | 46 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5739 | 46 | return $json->decode( $_[0] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5740 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5741 | 1 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 5742 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5743 | # _handle_observing_list takes as input any number of arguments. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5744 | # each is split on newlines, and lines beginning with a five-digit | ||||||||||||||||||||||||||||||||||||||||||||||
| 5745 | # number (with leading spaces allowed) are taken to specify the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5746 | # catalog number (first five characters) and common name (the rest) | ||||||||||||||||||||||||||||||||||||||||||||||
| 5747 | # of an object. The resultant catalog numbers are run through the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5748 | # retrieve () method. If called in scalar context, the return is | ||||||||||||||||||||||||||||||||||||||||||||||
| 5749 | # the resultant HTTP::Response object. In list context, the first | ||||||||||||||||||||||||||||||||||||||||||||||
| 5750 | # return is the HTTP::Response object, and the second is a reference | ||||||||||||||||||||||||||||||||||||||||||||||
| 5751 | # to a list of list references, each lower-level reference containing | ||||||||||||||||||||||||||||||||||||||||||||||
| 5752 | # catalog number and name. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5753 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5754 | 1 | ▶ | sub _handle_observing_list { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_observing_list: called CC=9 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5755 | 1 | my ( $self, $opt, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5756 | 1 | my (@catnum, @data); | |||||||||||||||||||||||||||||||||||||||||||||
| 5757 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5758 | # Do not _parse_retrieve_args() here; we expect our caller to handle | ||||||||||||||||||||||||||||||||||||||||||||||
| 5759 | # this. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5760 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5761 | 1 | foreach (map {split qr{ \n }smx, $_} @args) { | |||||||||||||||||||||||||||||||||||||||||||||
| 5762 | 1 | s/ \s+ \z //smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5763 | 1 | ▶ | my ( $id ) = m/ \A ( [\s\d]{5} ) /smx or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5764 | 1 | ▶ | $id =~ m/ \A \s* \d+ \z /smx or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5765 | 1 | my $name = substr $_, 5; | |||||||||||||||||||||||||||||||||||||||||||||
| 5766 | 1 | $name =~ s/ \A \s+ //smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5767 | 1 | push @catnum, $id; | |||||||||||||||||||||||||||||||||||||||||||||
| 5768 | 1 | push @data, [ $id, $name ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 5769 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5770 | 1 | my $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 5771 | 1 | ▶ | if ( $opt->{observing_list} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5772 | $resp = HTTP::Response->new( HTTP_OK, undef, undef, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5773 | 0 | ▶ | join '', map { m/ \n \z /smx ? $_ : "$_\n" } @args ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5774 | 0 | my $source = ( caller 1 )[3]; | |||||||||||||||||||||||||||||||||||||||||||||
| 5775 | 0 | $source =~ s/ .* :: //smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5776 | 0 | $self->_add_pragmata( $resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 5777 | 'spacetrack-type' => 'observing-list', | ||||||||||||||||||||||||||||||||||||||||||||||
| 5778 | 'spacetrack-source' => $source, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5779 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5780 | 0 | $self->__dump_response( $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5781 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5782 | 0 | $resp = $self->retrieve( $opt, sort {$a <=> $b} @catnum ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5783 | 1 | ▶ | if ( $resp->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5784 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5785 | 1 | ▶ | unless ( $self->{_pragmata} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5786 | 0 | $self->_add_pragmata( $resp, | |||||||||||||||||||||||||||||||||||||||||||||
| 5787 | 'spacetrack-type' => 'orbit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 5788 | 'spacetrack-source' => 'spacetrack', | ||||||||||||||||||||||||||||||||||||||||||||||
| 5789 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5790 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5791 | 1 | $self->__dump_response( $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5792 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5793 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5794 | 1 | ▶ | return wantarray ? ($resp, \@data) : $resp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5795 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5796 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5797 | # _instance takes a variable and a class, and returns true if the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5798 | # variable is blessed into the class. It returns false for | ||||||||||||||||||||||||||||||||||||||||||||||
| 5799 | # variables that are not references. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5800 | 1 | ▶ | sub _instance { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_instance: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5801 | 1 | my ( $object, $class ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5802 | 1 | ▶ | ref $object or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5803 | 1 | ▶ | Scalar::Util::blessed( $object ) or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5804 | 1 | return $object->isa( $class ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5805 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5806 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5807 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5808 | # _make_space_track_base_url() makes the a base Space Track URL. You can | ||||||||||||||||||||||||||||||||||||||||||||||
| 5809 | # pass the interface version number (1 or 2) as an argument -- it | ||||||||||||||||||||||||||||||||||||||||||||||
| 5810 | # defaults to the value of the space_track_version attribute. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5811 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5812 | 96 | ▶ | sub _make_space_track_base_url { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_space_track_base_url: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5813 | 96 | my ( $self, $version ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5814 | 96 | return $self->{scheme_space_track} . '://' . | |||||||||||||||||||||||||||||||||||||||||||||
| 5815 | $self->_get_space_track_domain( $version ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5816 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5817 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5818 | # _mung_login_status() takes as its argument an HTTP::Response object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5819 | # If the code is 500 and the message suggests a certificate problem, add | ||||||||||||||||||||||||||||||||||||||||||||||
| 5820 | # the suggestion that the user set verify_hostname false. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5821 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5822 | 0 | ▶ | sub _mung_login_status { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mung_login_status: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5823 | 0 | my ( $resp ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5824 | # 500 Can't connect to www.space-track.org:443 (certificate verify failed) | ||||||||||||||||||||||||||||||||||||||||||||||
| 5825 | 0 | ▶ | $resp->code() == HTTP_INTERNAL_SERVER_ERROR | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5826 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5827 | 0 | ▶ | ( my $msg = $resp->message() ) =~ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5828 | s{ ( [(] \Qcertificate verify failed\E ) [)]} | ||||||||||||||||||||||||||||||||||||||||||||||
| 5829 | {$1; try setting the verify_hostname attribute false)}smx | ||||||||||||||||||||||||||||||||||||||||||||||
| 5830 | or return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5831 | 0 | $resp->message( $msg ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5832 | 0 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 5833 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5834 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5835 | # _mutate_attrib takes the name of an attribute and the new value | ||||||||||||||||||||||||||||||||||||||||||||||
| 5836 | # for the attribute, and does what its name says. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5837 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5838 | # We supress Perl::Critic because we're a one-liner. CAVEAT: we MUST | ||||||||||||||||||||||||||||||||||||||||||||||
| 5839 | # not modify the contents of @_. Modifying @_ itself is fine. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5840 | 14 | ▶ | sub _mutate_attrib { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mutate_attrib: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5841 | 14 | $_[0]->_deprecation_notice( attribute => $_[1] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5842 | 14 | return ($_[0]{$_[1]} = $_[2]); | |||||||||||||||||||||||||||||||||||||||||||||
| 5843 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5844 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5845 | 22 | ▶ | sub _mutate_dump_headers { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mutate_dump_headers: called CC=3 SCAR=18.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5846 | 22 | my ( $self, $name, $value, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5847 | 22 | ▶ | if ( $value =~ m/ \A --? /smx ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5848 | 0 | $value = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 5849 | 0 | my $go = Getopt::Long::Parser->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 5850 | 0 | $go->configure( qw{ require_order } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5851 | $go->getoptionsfromarray( | ||||||||||||||||||||||||||||||||||||||||||||||
| 5852 | $args, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5853 | 0 | ▶ | map {; "$_!" => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5854 | 0 | ▶ | $_[1] and do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5855 | 0 | my $method = "DUMP_\U$_[0]"; | |||||||||||||||||||||||||||||||||||||||||||||
| 5856 | 0 | $value |= $self->$method(); | |||||||||||||||||||||||||||||||||||||||||||||
| 5857 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5858 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5859 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5860 | 0 | } @dump_options | |||||||||||||||||||||||||||||||||||||||||||||
| 5861 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5862 | 0 | push @{ $args }, $value; # Since caller pops it. | |||||||||||||||||||||||||||||||||||||||||||||
| 5863 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5864 | 22 | ▶ | $value =~ m/ \A 0 (?: [0-7]+ | x [[:xdigit:]]+ ) \z /smx | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5865 | and $value = oct $value; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5866 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5867 | 22 | return ( $self->{$name} = $value ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5868 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5869 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5870 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5871 | my %id_file_name = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 5872 | 0 | ▶ | MSWin32 => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5873 | my $home = $ENV{HOME} || $ENV{USERPROFILE} || join '', | ||||||||||||||||||||||||||||||||||||||||||||||
| 5874 | 0 | ▶ | $ENV{HOMEDRIVE}, $ENV{HOMEPATH}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$ENV{'HOME'} || $ENV{'USERPROFILE'} || join('', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'})
$ENV{"HOME"} or $ENV{"USERPROFILE"}
MC/DC0%0/3
$ENV{'HOME'} || $ENV{'USERPROFILE'} || join('', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'})
$ENV{"HOME"}
$ENV{"USERPROFILE"}
join('', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'})
Truth table0%0/4
A or B || C
A= $ENV{"HOME"}B= $ENV{"USERPROFILE"}C= join('', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5875 | 0 | return "$home\\spacetrack.id"; | |||||||||||||||||||||||||||||||||||||||||||||
| 5876 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5877 | 0 | ▶ | VMS => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5878 | 0 | ▶ | my $home = $ENV{HOME} || 'sys$login'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'HOME'} || 'sys$login'
MC/DC0%0/1
$ENV{'HOME'} || 'sys$login'
$ENV{'HOME'}
Truth table0%0/2
A
A= $ENV{'HOME'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5879 | 0 | return "$home:spacetrack.id"; | |||||||||||||||||||||||||||||||||||||||||||||
| 5880 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 5881 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5882 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5883 | 0 | ▶ | sub __identity_file_name { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__identity_file_name: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5884 | 0 | ▶ | my $id_file = ( $id_file_name{$^O} || sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5885 | 0 | return join '/', $ENV{HOME}, '.spacetrack-identity' } | |||||||||||||||||||||||||||||||||||||||||||||
| 5886 | 0 | ▶ | )->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$id_file_name{$^O} || sub {
return join('/', $ENV{'HOME'}, '.spacetrack-identity');
}
MC/DC0%0/2
$id_file_name{$^O} || sub {
return join('/', $ENV{'HOME'}, '.spacetrack-identity');
}
$id_file_name{$^O}
sub {
return join('/', $ENV{'HOME'}, '.spacetrack-identity');
}
Truth table0%0/3
A || B
A= $id_file_name{$^O}B= sub {
return join('/', $ENV{'HOME'}, '.spacetrack-identity');
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5887 | 0 | my $gpg_file = "$id_file.gpg"; | |||||||||||||||||||||||||||||||||||||||||||||
| 5888 | 0 | ▶ | -e $gpg_file | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5889 | and return $gpg_file; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5890 | 0 | return $id_file; | |||||||||||||||||||||||||||||||||||||||||||||
| 5891 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5892 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5893 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5894 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5895 | # This basically duplicates the logic in Config::Identity | ||||||||||||||||||||||||||||||||||||||||||||||
| 5896 | 7 | ▶ | sub __identity_file_is_encrypted { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__identity_file_is_encrypted: not called CC=3 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5897 | 0 | my $fn = __identity_file_name(); | |||||||||||||||||||||||||||||||||||||||||||||
| 5898 | 0 | ▶ | -B $fn | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5899 | and return 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5900 | 0 | ▶ | open my $fh, '<:encoding(utf-8)', $fn | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5901 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5902 | 0 | local $/ = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 5903 | 0 | my $content = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||
| 5904 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||
| 5905 | 0 | return $content =~ m/ \Q----BEGIN PGP MESSAGE----\E /smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 5906 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5907 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5908 | 14 | ▶ | sub _mutate_identity { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mutate_identity: called CC=4 SCAR=17.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5909 | 14 | my ( $self, $name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5910 | defined $value | ||||||||||||||||||||||||||||||||||||||||||||||
| 5911 | 14 | ▶ | or $value = $ENV{SPACETRACK_IDENTITY}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5912 | 14 | ▶ | if ( $value and my $identity = __spacetrack_identity() ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$value and my $identity = __spacetrack_identity()
MC/DC0%0/2
$value and my $identity = __spacetrack_identity()
$value
my $identity = __spacetrack_identity()
Truth table33%1/3
A and B
A= $valueB= my $identity = __spacetrack_identity()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5913 | 0 | $self->set( %{ $identity } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5914 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5915 | 14 | return ( $self->{$name} = $value ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5916 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5917 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5918 | =for html <a name="flush_identity_cache"></a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 5919 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5920 | =item Astro::SpaceTrack->flush_identity_cache(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5921 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5922 | The identity file is normally read only once, and the data cached. This | ||||||||||||||||||||||||||||||||||||||||||||||
| 5923 | static method flushes the cache to force the identity data to be reread. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5924 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5925 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 5926 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5927 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5928 | 7 | my $identity; | |||||||||||||||||||||||||||||||||||||||||||||
| 5929 | 7 | my $loaded; | |||||||||||||||||||||||||||||||||||||||||||||
| 5930 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5931 | 0 | ▶ | sub flush_identity_cache { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flush_identity_cache: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5932 | 0 | $identity = $loaded = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 5933 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 5934 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5935 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5936 | 0 | ▶ | sub __spacetrack_identity { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__spacetrack_identity: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5937 | 0 | ▶ | $loaded | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5938 | and return $identity; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5939 | 0 | $loaded = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 5940 | 0 | my $fn = __identity_file_name(); | |||||||||||||||||||||||||||||||||||||||||||||
| 5941 | 0 | ▶ | -f $fn | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5942 | or return $identity; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5943 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5944 | 0 | local $@ = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 5945 | 0 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5946 | 0 | require Config::Identity; | |||||||||||||||||||||||||||||||||||||||||||||
| 5947 | 0 | $identity = { Config::Identity->load( $fn ) }; | |||||||||||||||||||||||||||||||||||||||||||||
| 5948 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 5949 | } or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5950 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5951 | 0 | foreach my $key ( qw{ username password } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 5952 | 0 | ▶ | exists $identity->{$key} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5953 | or Carp::croak "Identity file omits $key"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5954 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5955 | 0 | ▶ | scalar keys %{ $identity } > 2 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5956 | and Carp::croak 'Identity file defines keys besides username and password'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5957 | 0 | return $identity; | |||||||||||||||||||||||||||||||||||||||||||||
| 5958 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5959 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5960 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5961 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 5962 | 7 | my %need_logout = map { $_ => 1 } qw{ domain_space_track }; | |||||||||||||||||||||||||||||||||||||||||||||
| 5963 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5964 | 0 | ▶ | sub _mutate_spacetrack_interface { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mutate_spacetrack_interface: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5965 | 0 | my ( $self, $name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5966 | 0 | my $version = $self->{space_track_version}; | |||||||||||||||||||||||||||||||||||||||||||||
| 5967 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5968 | my $spacetrack_interface_info = | ||||||||||||||||||||||||||||||||||||||||||||||
| 5969 | 0 | $self->{_space_track_interface}[$version]; | |||||||||||||||||||||||||||||||||||||||||||||
| 5970 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5971 | 0 | ▶ | exists $spacetrack_interface_info->{$name} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5972 | or Carp::croak "Can not set $name for interface version $version"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5973 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5974 | 0 | ▶ | $need_logout{$name} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5975 | and $self->logout(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 5976 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5977 | 0 | return ( $spacetrack_interface_info->{$name} = $value ); | |||||||||||||||||||||||||||||||||||||||||||||
| 5978 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5979 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5980 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5981 | 7 | ▶ | sub _access_spacetrack_interface { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_access_spacetrack_interface: not called CC=2 SCAR=15.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5982 | 0 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 5983 | 0 | my $version = $self->{space_track_version}; | |||||||||||||||||||||||||||||||||||||||||||||
| 5984 | my $spacetrack_interface_info = | ||||||||||||||||||||||||||||||||||||||||||||||
| 5985 | 0 | $self->{_space_track_interface}[$version]; | |||||||||||||||||||||||||||||||||||||||||||||
| 5986 | 0 | ▶ | exists $spacetrack_interface_info->{$name} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5987 | or Carp::croak "Can not get $name for interface version $version"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5988 | 0 | return $spacetrack_interface_info->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 5989 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 5990 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5991 | # _mutate_authen clears the session cookie and then sets the | ||||||||||||||||||||||||||||||||||||||||||||||
| 5992 | # desired attribute | ||||||||||||||||||||||||||||||||||||||||||||||
| 5993 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5994 | # This clears the session cookie and cookie expiration, then co-routines | ||||||||||||||||||||||||||||||||||||||||||||||
| 5995 | # off to _mutate attrib. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5996 | 4 | ▶ | sub _mutate_authen { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mutate_authen: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5997 | 4 | $_[0]->logout(); | |||||||||||||||||||||||||||||||||||||||||||||
| 5998 | 4 | goto &_mutate_attrib; | |||||||||||||||||||||||||||||||||||||||||||||
| 5999 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6000 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6001 | # This subroutine just does some argument checking and then co-routines | ||||||||||||||||||||||||||||||||||||||||||||||
| 6002 | # off to _mutate_attrib. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6003 | 0 | ▶ | sub _mutate_iridium_status_format { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mutate_iridium_status_format: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6004 | Carp::croak "Error - Illegal status format '$_[2]'" | ||||||||||||||||||||||||||||||||||||||||||||||
| 6005 | 0 | ▶ | unless $catalogs{iridium_status}{$_[2]}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6006 | 0 | $_[0]->_deprecation_notice( iridium_status_format => $_[2] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6007 | 0 | goto &_mutate_attrib; | |||||||||||||||||||||||||||||||||||||||||||||
| 6008 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6009 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6010 | # _mutate_number croaks if the value to be set is not numeric. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6011 | # Otherwise it sets the value. Only unsigned integers pass. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6012 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6013 | # This subroutine just does some argument checking and then co-routines | ||||||||||||||||||||||||||||||||||||||||||||||
| 6014 | # off to _mutate_attrib. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6015 | 0 | ▶ | sub _mutate_number { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mutate_number: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6016 | 0 | ▶ | $_[2] =~ m/ \D /smx and Carp::croak <<"EOD"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6017 | Attribute $_[1] must be set to a numeric value. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6018 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 6019 | 0 | goto &_mutate_attrib; | |||||||||||||||||||||||||||||||||||||||||||||
| 6020 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6021 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6022 | # _mutate_space_track_version() mutates the version of the interface | ||||||||||||||||||||||||||||||||||||||||||||||
| 6023 | # used to retrieve data from Space Track. Valid values are 1 and 2, with | ||||||||||||||||||||||||||||||||||||||||||||||
| 6024 | # any false value causing the default to be set. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6025 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6026 | 2 | ▶ | sub _mutate_space_track_version { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mutate_space_track_version: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6027 | 2 | my ( $self, $name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6028 | 2 | ▶ | $value | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6029 | or $value = DEFAULT_SPACE_TRACK_VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6030 | $value =~ m/ \A \d+ \z /smx | ||||||||||||||||||||||||||||||||||||||||||||||
| 6031 | 2 | ▶ | and $self->{_space_track_interface}[$value] | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$value =~ / \A \d+ \z /msx and $self->{"_space_track_interface"}[$value]
MC/DC0%0/2
$value =~ / \A \d+ \z /msx and $self->{"_space_track_interface"}[$value]
$value =~ / \A \d+ \z /msx
$self->{"_space_track_interface"}[$value]
Truth table33%1/3
A and B
A= $value =~ / \A \d+ \z /msxB= $self->{"_space_track_interface"}[$value]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6032 | or Carp::croak "Invalid Space Track version $value"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6033 | ## $self->_deprecation_notice( $name => $value ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6034 | 2 | ▶ | $value == 1 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6035 | and Carp::croak 'The version 1 SpaceTrack interface stopped working July 16 2013 at 18:00 UT'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6036 | 2 | return ( $self->{$name} = $value ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6037 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6038 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6039 | # _mutate_verify_hostname mutates the verify_hostname attribute. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6040 | # Since the value of this gets fed to LWP::UserAgent->new() to | ||||||||||||||||||||||||||||||||||||||||||||||
| 6041 | # instantiate the {agent} attribute, we delete that attribute | ||||||||||||||||||||||||||||||||||||||||||||||
| 6042 | # before changing the value, relying on $self->_get_agent() to | ||||||||||||||||||||||||||||||||||||||||||||||
| 6043 | # instantiate it appropriately if needed -- and on any code that | ||||||||||||||||||||||||||||||||||||||||||||||
| 6044 | # uses the agent to go through this private method to get it. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6045 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6046 | 1 | ▶ | sub _mutate_verify_hostname { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mutate_verify_hostname: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6047 | 1 | delete $_[0]->{agent}; | |||||||||||||||||||||||||||||||||||||||||||||
| 6048 | 1 | goto &_mutate_attrib; | |||||||||||||||||||||||||||||||||||||||||||||
| 6049 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6050 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6051 | # _no_such_catalog takes as arguments a source and catalog name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6052 | # and returns the appropriate HTTP::Response object based on the | ||||||||||||||||||||||||||||||||||||||||||||||
| 6053 | # current verbosity setting. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6054 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6055 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6056 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6057 | 7 | my %no_such_name = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 6058 | celestrak => 'CelesTrak', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6059 | spacetrack => 'Space Track', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6060 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6061 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6062 | 3 | ▶ | sub _no_such_catalog { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_no_such_catalog: called CC=9 SCAR=24.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6063 | 3 | my ( $self, $source, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6064 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6065 | 3 | ▶ | my $info = $catalogs{$source} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6066 | or Carp::confess "Bug - No such source as '$source'"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6067 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6068 | 3 | ▶ | if ( ARRAY_REF eq ref $info ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6069 | 1 | my $inx = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||
| 6070 | 1 | ▶ | $info = $info->[$inx] | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6071 | or Carp::confess "Bug - Illegal index $inx ", | ||||||||||||||||||||||||||||||||||||||||||||||
| 6072 | "for '$source'"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6073 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6074 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6075 | 3 | my ( $catalog, $note ) = @args; | |||||||||||||||||||||||||||||||||||||||||||||
| 6076 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6077 | 3 | ▶ | my $name = $no_such_name{$source} || $source; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$no_such_name{$source} || $source
MC/DC0%0/2
$no_such_name{$source} || $source
$no_such_name{$source}
$source
Truth table66%2/3
A || B
A= $no_such_name{$source}B= $source
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6078 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6079 | my $lead = defined $catalog ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 6080 | 3 | ▶ | $info->{$catalog} ? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6081 | "$name '$catalog' missing" : | ||||||||||||||||||||||||||||||||||||||||||||||
| 6082 | "$name '$catalog' not found" : | ||||||||||||||||||||||||||||||||||||||||||||||
| 6083 | "$name item not defined"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6084 | 3 | ▶ | $lead .= defined $note ? " ($note)." : '.'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6085 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6086 | return HTTP::Response->new (HTTP_NOT_FOUND, "$lead\n") | ||||||||||||||||||||||||||||||||||||||||||||||
| 6087 | 3 | ▶ | unless $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6088 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6089 | 0 | my $resp = $self->names ($source); | |||||||||||||||||||||||||||||||||||||||||||||
| 6090 | 0 | return HTTP::Response->new (HTTP_NOT_FOUND, | |||||||||||||||||||||||||||||||||||||||||||||
| 6091 | join '', "$lead Try one of:\n", $resp->content, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6092 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6093 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6094 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6095 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6096 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6097 | # _parse_args parses options off an argument list. The first | ||||||||||||||||||||||||||||||||||||||||||||||
| 6098 | # argument must be a list reference of options to be parsed. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6099 | # This list is pairs of values, the first being the Getopt::Long | ||||||||||||||||||||||||||||||||||||||||||||||
| 6100 | # specification for the option, and the second being a description | ||||||||||||||||||||||||||||||||||||||||||||||
| 6101 | # of the option suitable for help text. Subsequent arguments are | ||||||||||||||||||||||||||||||||||||||||||||||
| 6102 | # the arguments list to be parsed. It returns a reference to a | ||||||||||||||||||||||||||||||||||||||||||||||
| 6103 | # hash containing the options, followed by any remaining | ||||||||||||||||||||||||||||||||||||||||||||||
| 6104 | # non-option arguments. If the first argument after the list | ||||||||||||||||||||||||||||||||||||||||||||||
| 6105 | # reference is a hash reference, it simply returns. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6107 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6108 | 7 | my $go = Getopt::Long::Parser->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 6109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6110 | 99 | ▶ | sub _parse_args { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_args: called CC=9 SCAR=22.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6111 | 99 | my ( $lgl_opts, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6112 | 99 | ▶ | unless ( ARRAY_REF eq ref $lgl_opts ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6113 | 14 | unshift @args, $lgl_opts; | |||||||||||||||||||||||||||||||||||||||||||||
| 6114 | 14 | ( my $caller = ( caller 1 )[3] ) =~ s/ ( .* ) :: //smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 6115 | 14 | my $pkg = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 6116 | 14 | ▶ | my $code = $pkg->can( "_${caller}_opts" ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6117 | or Carp::confess "Bug - _${caller}_opts not found"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6118 | 14 | $lgl_opts = $code->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 6119 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6120 | 99 | my $opt; | |||||||||||||||||||||||||||||||||||||||||||||
| 6121 | 99 | ▶ | if ( HASH_REF eq ref $args[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6122 | 18 | $opt = { %{ shift @args } }; # Poor man's clone. | |||||||||||||||||||||||||||||||||||||||||||||
| 6123 | # Validation is new, so I insert a hack to turn it off if need | ||||||||||||||||||||||||||||||||||||||||||||||
| 6124 | # be. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6125 | 18 | ▶ | unless ( $ENV{SPACETRACK_SKIP_OPTION_HASH_VALIDATION} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6126 | 18 | my %lgl = _extract_keys( $lgl_opts ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6127 | 18 | my @bad; | |||||||||||||||||||||||||||||||||||||||||||||
| 6128 | 18 | foreach my $key ( keys %{ $opt } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6129 | 47 | ▶ | $lgl{$key} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6130 | or push @bad, $key; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6131 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6132 | @bad | ||||||||||||||||||||||||||||||||||||||||||||||
| 6133 | and _parse_args_failure( | ||||||||||||||||||||||||||||||||||||||||||||||
| 6134 | carp => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6135 | name => \@bad, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6136 | 0 | ▶ | legal => { @{ $lgl_opts } }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6137 | suffix => <<'EOD', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6139 | You cam suppress this warning by setting environment variable | ||||||||||||||||||||||||||||||||||||||||||||||
| 6140 | SPACETRACK_SKIP_OPTION_HASH_VALIDATION to a value Perl understands as | ||||||||||||||||||||||||||||||||||||||||||||||
| 6141 | true (say, like 1), but this should be considered a stopgap while you | ||||||||||||||||||||||||||||||||||||||||||||||
| 6142 | fix the calling code, or have it fixed, since my plan is to make this | ||||||||||||||||||||||||||||||||||||||||||||||
| 6143 | fatal. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6144 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 6145 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6146 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6147 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6148 | 81 | $opt = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 6149 | 81 | my %lgl = @{ $lgl_opts }; | |||||||||||||||||||||||||||||||||||||||||||||
| 6150 | 81 | ▶ | $go->getoptionsfromarray( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6151 | \@args, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6152 | $opt, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6153 | keys %lgl, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6154 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 6155 | or _parse_args_failure( legal => \%lgl ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6156 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6157 | 99 | return ( $opt, @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6158 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6159 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6160 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6161 | 7 | ▶ | sub _parse_args_failure { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_args_failure: not called CC=10 SCAR=46.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6162 | 0 | my %arg = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6163 | 0 | ▶ | my $msg = $arg{carp} ? 'Warning - ' : 'Error - '; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6164 | 0 | ▶ | if ( defined $arg{name} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6165 | my @names = ( ARRAY_REF eq ref $arg{name} ) ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 6166 | 0 | @{ $arg{name} } : | |||||||||||||||||||||||||||||||||||||||||||||
| 6167 | 0 | ▶ | $arg{name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6168 | @names | ||||||||||||||||||||||||||||||||||||||||||||||
| 6169 | 0 | ▶ | or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6170 | 0 | ▶ | my $opt = @names > 1 ? 'Options' : 'Option'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6171 | 0 | my $txt = join ', ', map { "-$_" } sort @names; | |||||||||||||||||||||||||||||||||||||||||||||
| 6172 | 0 | $msg .= "$opt $txt illegal.\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 6173 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6174 | 0 | ▶ | if ( defined $arg{legal} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6175 | 0 | $msg .= "Legal options are\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 6176 | 0 | foreach my $opt ( sort keys %{ $arg{legal} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6177 | 0 | my $desc = $arg{legal}{$opt}; | |||||||||||||||||||||||||||||||||||||||||||||
| 6178 | 0 | $opt = _extract_keys( $opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6179 | 0 | $msg .= " -$opt - $desc\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 6180 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6181 | 0 | $msg .= <<"EOD"; | |||||||||||||||||||||||||||||||||||||||||||||
| 6182 | with dates being either Perl times, or numeric year-month-day, with any | ||||||||||||||||||||||||||||||||||||||||||||||
| 6183 | non-numeric character valid as punctuation. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6184 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 6185 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6186 | defined $arg{suffix} | ||||||||||||||||||||||||||||||||||||||||||||||
| 6187 | 0 | ▶ | and $msg .= $arg{suffix}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6188 | $arg{carp} | ||||||||||||||||||||||||||||||||||||||||||||||
| 6189 | 0 | ▶ | or Carp::croak $msg; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6190 | 0 | Carp::carp $msg; | |||||||||||||||||||||||||||||||||||||||||||||
| 6191 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 6192 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6194 | # Parse an international launch ID in the form yyyy-sssp or yysssp. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6195 | # In the yyyy-sssp form, the year can be two digits (in which case 57-99 | ||||||||||||||||||||||||||||||||||||||||||||||
| 6196 | # are 1957-1999 and 00-56 are 2000-2056) and the dash can be any | ||||||||||||||||||||||||||||||||||||||||||||||
| 6197 | # non-alpha, non-digit, non-space character. In either case, trailing | ||||||||||||||||||||||||||||||||||||||||||||||
| 6198 | # fields are optional. If provided, the part ('p') can be multiple | ||||||||||||||||||||||||||||||||||||||||||||||
| 6199 | # alphabetic characters. Only fields actually specified will be | ||||||||||||||||||||||||||||||||||||||||||||||
| 6200 | # returned. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6202 | 14 | ▶ | sub _parse_international_id { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_international_id: called CC=7 SCAR=20.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6203 | 14 | my ( $intl_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6204 | 14 | my ( $year, $launch, $part ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6206 | 14 | ▶ | if ( $intl_id =~ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6207 | m< \A ( \d+ ) [^[:alpha:][:digit:]\s] | ||||||||||||||||||||||||||||||||||||||||||||||
| 6208 | (?: ( \d{1,3} ) ( [[:alpha:]]* ) )? \z >smx | ||||||||||||||||||||||||||||||||||||||||||||||
| 6209 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6210 | 0 | ( $year, $launch, $part ) = ( $1, $2, $3 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6211 | } elsif ( $intl_id =~ | ||||||||||||||||||||||||||||||||||||||||||||||
| 6212 | m< \A ( \d\d ) (?: ( \d{3} ) ( [[:alpha:]]* ) )? >smx | ||||||||||||||||||||||||||||||||||||||||||||||
| 6213 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6214 | 14 | ( $year, $launch, $part ) = ( $1, $2, $3 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6215 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6216 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 6217 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6218 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6219 | 14 | ▶ | $year += $year < 57 ? 2000 : $year < 100 ? 1900 : 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6220 | 14 | my @parts = ( $year ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6221 | 14 | ▶ | $launch | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6222 | or return @parts; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6223 | 13 | push @parts, $launch; | |||||||||||||||||||||||||||||||||||||||||||||
| 6224 | 13 | ▶ | $part | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6225 | and push @parts, uc $part; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6226 | 13 | return @parts; | |||||||||||||||||||||||||||||||||||||||||||||
| 6227 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6228 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6229 | # Parse a date in the form yyyy-mm-dd, with either two- or four-digit | ||||||||||||||||||||||||||||||||||||||||||||||
| 6230 | # year, and month and day optional. The year is normalized to four | ||||||||||||||||||||||||||||||||||||||||||||||
| 6231 | # digits using the NORAD pivot date of 57 -- that is, 57-99 represent | ||||||||||||||||||||||||||||||||||||||||||||||
| 6232 | # 1957-1999, and 00-56 represent 2000-2056. The month and day are | ||||||||||||||||||||||||||||||||||||||||||||||
| 6233 | # optional. Only fields actually specified will be returned. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6234 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6235 | 14 | ▶ | sub _parse_launch_date { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_launch_date: called CC=6 SCAR=19.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6236 | 14 | my ( $date ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6237 | 14 | ▶ | my ( $year, $month, $day ) = | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6238 | $date =~ m/ \A (\d+) (?:\D+ (\d+) (?: \D+ (\d+) )? )? /smx | ||||||||||||||||||||||||||||||||||||||||||||||
| 6239 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6240 | 14 | ▶ | $year += $year < 57 ? 2000 : $year < 100 ? 1900 : 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6241 | 14 | my @parts = ( $year ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6242 | 14 | ▶ | defined $month | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6243 | or return @parts; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6244 | 14 | push @parts, $month; | |||||||||||||||||||||||||||||||||||||||||||||
| 6245 | 14 | ▶ | defined $day and push @parts, $day; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6246 | 14 | return @parts; | |||||||||||||||||||||||||||||||||||||||||||||
| 6247 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6249 | # _parse_retrieve_args parses the retrieve() options off its | ||||||||||||||||||||||||||||||||||||||||||||||
| 6250 | # arguments, prefixes a reference to the resultant options hash to | ||||||||||||||||||||||||||||||||||||||||||||||
| 6251 | # the remaining arguments, and returns the resultant list. If the | ||||||||||||||||||||||||||||||||||||||||||||||
| 6252 | # first argument is a list reference, it is taken as extra | ||||||||||||||||||||||||||||||||||||||||||||||
| 6253 | # options, and removed from the argument list. If the next | ||||||||||||||||||||||||||||||||||||||||||||||
| 6254 | # argument after the list reference (if any) is a hash reference, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6255 | # it simply returns its argument list, under the assumption that | ||||||||||||||||||||||||||||||||||||||||||||||
| 6256 | # it has already been called. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6257 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6258 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6259 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6260 | my @legal_retrieve_options = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 6261 | 7 | @{ CLASSIC_RETRIEVE_OPTIONS() }, | |||||||||||||||||||||||||||||||||||||||||||||
| 6262 | # Space Track Version 2 interface options | ||||||||||||||||||||||||||||||||||||||||||||||
| 6263 | 'since_file=i' | ||||||||||||||||||||||||||||||||||||||||||||||
| 6264 | => '(Return only results added after the given file number)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6265 | 'json!' => '(Return TLEs in JSON format)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6266 | 'format=s' => 'Specify data format' | ||||||||||||||||||||||||||||||||||||||||||||||
| 6267 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6268 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6269 | 0 | ▶ | sub _get_retrieve_options { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_retrieve_options: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6270 | 0 | return @legal_retrieve_options; | |||||||||||||||||||||||||||||||||||||||||||||
| 6271 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6273 | 82 | ▶ | sub _parse_retrieve_args { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_retrieve_args: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6274 | 82 | my ( undef, @args ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 6275 | 82 | ▶ | my $extra_options = ARRAY_REF eq ref $args[0] ? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6276 | shift @args : | ||||||||||||||||||||||||||||||||||||||||||||||
| 6277 | undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6278 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6279 | ( my $opt, @args ) = _parse_args( | ||||||||||||||||||||||||||||||||||||||||||||||
| 6280 | ( $extra_options ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 6281 | 82 | ▶ | [ @legal_retrieve_options, @{ $extra_options } ] : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6282 | \@legal_retrieve_options ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 6283 | @args ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6284 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6285 | 82 | ▶ | $opt->{sort} ||= _validate_sort( $opt->{sort} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opt->{"sort"} ||= _validate_sort($opt->{"sort"})
MC/DC0%0/2
$opt->{"sort"} ||= _validate_sort($opt->{"sort"})
$opt->{"sort"}
_validate_sort($opt->{"sort"})
Truth table66%2/3
A ||= B
A= $opt->{"sort"}B= _validate_sort($opt->{"sort"})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6286 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6287 | 82 | _retrieval_format( undef, $opt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6288 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6289 | 82 | return ( $opt, @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6290 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6291 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6293 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6294 | 7 | my @usual_formats = map { $_ => 1 } qw{ xml json html csv }; | |||||||||||||||||||||||||||||||||||||||||||||
| 6295 | my $legacy_formats = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6296 | default => 'legacy', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6297 | 7 | valid => { @usual_formats, map { $_ => 1 } qw{ legacy } }, | |||||||||||||||||||||||||||||||||||||||||||||
| 6298 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6299 | my $tle_formats = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6300 | default => 'legacy', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6301 | 7 | valid => { @usual_formats, map { $_ => 1 } qw{ tle 3le legacy } }, | |||||||||||||||||||||||||||||||||||||||||||||
| 6302 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6303 | 7 | my %format = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 6304 | box_score => $legacy_formats, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6305 | country_names => $legacy_formats, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6306 | launch_sites => $legacy_formats, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6307 | satcat => $legacy_formats, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6308 | tle => $tle_formats, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6309 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6311 | 91 | ▶ | sub _retrieval_format { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_retrieval_format: called CC=13 SCAR=26.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6312 | 91 | my ( $table, $opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6313 | defined $table | ||||||||||||||||||||||||||||||||||||||||||||||
| 6314 | 91 | ▶ | or $table = defined $opt->{tle} ? $opt->{tle} ? 'tle' : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6315 | 'satcat' : 'tle'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6316 | $opt->{json} | ||||||||||||||||||||||||||||||||||||||||||||||
| 6317 | and defined $opt->{format} | ||||||||||||||||||||||||||||||||||||||||||||||
| 6318 | 91 | ▶ | and $opt->{format} ne 'json' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$opt->{"json"} and defined $opt->{"format"} and $opt->{"format"} ne "json"
$opt->{"json"} and defined $opt->{"format"}
MC/DC0%0/3
$opt->{"json"} and defined $opt->{"format"} and $opt->{"format"} ne "json"
$opt->{"json"}
defined $opt->{"format"}
$opt->{"format"} ne "json"
Truth table75%3/4
A and B and C
A= $opt->{"json"}B= defined $opt->{"format"}C= $opt->{"format"} ne "json"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6319 | and Carp::croak 'Inconsistent retrieval format specification'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6320 | 91 | ▶ | $format{$table} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6321 | or Carp::confess "Bug - $table not supported"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6322 | defined $opt->{format} | ||||||||||||||||||||||||||||||||||||||||||||||
| 6323 | or $opt->{format} = $opt->{json} ? 'json' : | ||||||||||||||||||||||||||||||||||||||||||||||
| 6324 | 91 | ▶ | $format{$table}{default}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6325 | exists $opt->{json} | ||||||||||||||||||||||||||||||||||||||||||||||
| 6326 | 91 | ▶ | or $opt->{json} = 'json' eq $opt->{format}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6327 | $format{$table}{valid}{ $opt->{format} } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6328 | 91 | ▶ | or Carp::croak "Invalid $table retrieval format '$opt->{format}'"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6329 | 91 | ▶ | return $opt->{format} eq 'legacy' ? 'json' : $opt->{format}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6330 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6331 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6332 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6333 | # my $sort = _validate_sort( $sort ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6334 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 6335 | # Validate and canonicalize the value of the -sort option. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6336 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6337 | 7 | my %valid = map { $_ => 1 } qw{ catnum epoch }; | |||||||||||||||||||||||||||||||||||||||||||||
| 6338 | 65 | ▶ | sub _validate_sort { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_sort: called CC=3 SCAR=17.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6339 | 65 | my ( $sort ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6340 | 65 | ▶ | defined $sort | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6341 | or return 'catnum'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6342 | 0 | $sort = lc $sort; | |||||||||||||||||||||||||||||||||||||||||||||
| 6343 | 0 | ▶ | $valid{$sort} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6344 | or Carp::croak "Illegal sort '$sort'"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6345 | 0 | return $sort; | |||||||||||||||||||||||||||||||||||||||||||||
| 6346 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6347 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6348 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6349 | # $opt = _parse_retrieve_dates ($opt); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6351 | # This subroutine looks for keys start_epoch and end_epoch in the | ||||||||||||||||||||||||||||||||||||||||||||||
| 6352 | # given option hash, parses them as YYYY-MM-DD (where the letters | ||||||||||||||||||||||||||||||||||||||||||||||
| 6353 | # are digits and the dashes are any non-digit punctuation), and | ||||||||||||||||||||||||||||||||||||||||||||||
| 6354 | # replaces those keys' values with a reference to a list | ||||||||||||||||||||||||||||||||||||||||||||||
| 6355 | # containing the output of timegm() for the given time. If only | ||||||||||||||||||||||||||||||||||||||||||||||
| 6356 | # one epoch is provided, the other is defaulted to provide a | ||||||||||||||||||||||||||||||||||||||||||||||
| 6357 | # one-day date range. If the syntax is invalid, we croak. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6358 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 6359 | # The return is the same hash reference that was passed in. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6360 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6361 | 7 | ▶ | sub _parse_retrieve_dates { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_retrieve_dates: called CC=16 SCAR=28.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6362 | 31 | my ( $opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6364 | 31 | my $found; | |||||||||||||||||||||||||||||||||||||||||||||
| 6365 | 31 | foreach my $key ( qw{ end_epoch start_epoch } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6366 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6367 | 62 | ▶ | next unless $opt->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6368 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6369 | 5 | ▶ | if ( $opt->{$key} =~ m/ \D /smx ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6370 | 5 | my $str = $opt->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||
| 6371 | 5 | ▶ | $str =~ m< \A | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6372 | ( \d+ ) \D+ ( \d+ ) \D+ ( \d+ ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 6373 | (?: \D+ ( \d+ ) (?: \D+ ( \d+ ) (?: \D+ ( \d+ ) )? )? )? | ||||||||||||||||||||||||||||||||||||||||||||||
| 6374 | \z >smx | ||||||||||||||||||||||||||||||||||||||||||||||
| 6375 | or Carp::croak "Error - Illegal date '$str'"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6376 | 5 | my @time = ( $6, $5, $4, $3, $2, $1 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6377 | 5 | foreach ( @time ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6378 | 30 | ▶ | defined $_ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6379 | or $_ = 0; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6380 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6381 | 5 | ▶ | if ( $time[5] > 1900 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6382 | 5 | $time[5] -= 1900; | |||||||||||||||||||||||||||||||||||||||||||||
| 6383 | } elsif ( $time[5] < 57 ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6384 | 0 | $time[5] += 100; | |||||||||||||||||||||||||||||||||||||||||||||
| 6385 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6386 | 5 | $time[4] -= 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 6387 | 5 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6388 | 5 | $opt->{$key} = Time::Local::timegm( @time ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6389 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 6390 | } or Carp::croak "Error - Illegal date '$str'"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6391 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6392 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6393 | 5 | $found++; | |||||||||||||||||||||||||||||||||||||||||||||
| 6394 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6395 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6396 | 31 | ▶ | if ( $found ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6397 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6398 | 4 | ▶ | if ( $found == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6399 | 3 | ▶ | $opt->{start_epoch} ||= $opt->{end_epoch} - 86400; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opt->{"start_epoch"} ||= $opt->{"end_epoch"} - 86400
MC/DC0%0/2
$opt->{"start_epoch"} ||= $opt->{"end_epoch"} - 86400
$opt->{"start_epoch"}
$opt->{"end_epoch"} - 86400
Truth table66%2/3
A ||= B
A= $opt->{"start_epoch"}B= $opt->{"end_epoch"} - 86400
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6400 | 3 | ▶ | $opt->{end_epoch} ||= $opt->{start_epoch} + 86400; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opt->{"end_epoch"} ||= $opt->{"start_epoch"} + 86400
MC/DC0%0/2
$opt->{"end_epoch"} ||= $opt->{"start_epoch"} + 86400
$opt->{"end_epoch"}
$opt->{"start_epoch"} + 86400
Truth table66%2/3
A ||= B
A= $opt->{"end_epoch"}B= $opt->{"start_epoch"} + 86400
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6401 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6402 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6403 | 4 | ▶ | $opt->{start_epoch} <= $opt->{end_epoch} or Carp::croak <<'EOD'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6404 | Error - End epoch must not be before start epoch. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6405 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 6406 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6407 | 4 | foreach my $key ( qw{ start_epoch end_epoch } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6408 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6409 | 8 | my @time = reverse( ( gmtime $opt->{$key} )[ 0 .. 5 ] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6410 | 8 | $time[0] += 1900; | |||||||||||||||||||||||||||||||||||||||||||||
| 6411 | 8 | $time[1] += 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 6412 | 8 | $opt->{"_$key"} = \@time; | |||||||||||||||||||||||||||||||||||||||||||||
| 6413 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6414 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6415 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6416 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6417 | 31 | return $opt; | |||||||||||||||||||||||||||||||||||||||||||||
| 6418 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6419 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6420 | # _parse_search_args parses the search_*() options off its | ||||||||||||||||||||||||||||||||||||||||||||||
| 6421 | # arguments, prefixes a reference to the resultant options | ||||||||||||||||||||||||||||||||||||||||||||||
| 6422 | # hash to the remaining arguments, and returns the resultant | ||||||||||||||||||||||||||||||||||||||||||||||
| 6423 | # list. If the first argument is a hash reference, it validates | ||||||||||||||||||||||||||||||||||||||||||||||
| 6424 | # that the hash contains only legal options. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6425 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6426 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6427 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6428 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6429 | 7 | my %status_query = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 6430 | onorbit => 'null-val', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6431 | decayed => '<>null-val', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6432 | all => '', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6433 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6434 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6435 | 7 | my %include_map = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 6436 | payload => 'PAYLOAD', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6437 | rocket => 'ROCKET BODY', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6438 | debris => 'DEBRIS', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6439 | unknown => 'UNKNOWN', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6440 | tba => 'TBA', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6441 | other => 'OTHER', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6442 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6443 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6444 | 50 | ▶ | sub _convert_search_options_to_rest { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_search_options_to_rest: called CC=13 SCAR=25.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6445 | 50 | my ( undef, $opt ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 6446 | 50 | my %rest; | |||||||||||||||||||||||||||||||||||||||||||||
| 6447 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6448 | 50 | ▶ | if ( defined $opt->{status} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6449 | defined ( my $query = $status_query{$opt->{status}} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 6450 | 50 | ▶ | or Carp::croak "Unknown status '$opt->{status}'"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6451 | $query | ||||||||||||||||||||||||||||||||||||||||||||||
| 6452 | 50 | ▶ | and $rest{DECAY} = $query; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6453 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6454 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6455 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6456 | 50 | my %incl; | |||||||||||||||||||||||||||||||||||||||||||||
| 6457 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6458 | 50 | ▶ | if ( $opt->{exclude} && @{ $opt->{exclude} } ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opt->{"exclude"} and @{$opt->{"exclude"};}
MC/DC50%1/2
$opt->{"exclude"} and @{$opt->{"exclude"};}
$opt->{"exclude"}
@{$opt->{"exclude"};}
Truth table66%2/3
A and B
A= $opt->{"exclude"}B= @{$opt->{"exclude"};}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6459 | 12 | %incl = map { $_ => 1 } keys %include_map; | |||||||||||||||||||||||||||||||||||||||||||||
| 6460 | 12 | foreach ( @{ $opt->{exclude} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6461 | 18 | ▶ | $include_map{$_} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6462 | or Carp::croak "Unknown exclusion '$_'"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6463 | 18 | delete $incl{$_}; | |||||||||||||||||||||||||||||||||||||||||||||
| 6464 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6465 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6466 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6467 | 50 | ▶ | if ( $opt->{include} && @{ $opt->{include} } ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opt->{"include"} and @{$opt->{"include"};}
MC/DC50%1/2
$opt->{"include"} and @{$opt->{"include"};}
$opt->{"include"}
@{$opt->{"include"};}
Truth table66%2/3
A and B
A= $opt->{"include"}B= @{$opt->{"include"};}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6468 | 1 | foreach ( @{ $opt->{include} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6469 | 1 | ▶ | $include_map{$_} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6470 | or Carp::croak "Unknown inclusion '$_'"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6471 | 1 | $incl{$_} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 6472 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6473 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6474 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6475 | keys %incl | ||||||||||||||||||||||||||||||||||||||||||||||
| 6476 | and $rest{OBJECT_TYPE} = join ',', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6477 | 50 | ▶ | map { $include_map{$_} } sort keys %incl; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6478 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6479 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6480 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6481 | 50 | return \%rest; | |||||||||||||||||||||||||||||||||||||||||||||
| 6482 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6483 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6484 | 7 | my @legal_search_args = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 6485 | 'rcs!' => '(ignored and deprecated)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6486 | 'tle!' => '(return TLE data from search (defaults true))', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6487 | 'status=s' => q{('onorbit', 'decayed', or 'all')}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6488 | 'exclude=s@' => q{('payload', 'debris', 'rocket', ... )}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6489 | 'include=s@' => q{('payload', 'debris', 'rocket', ... )}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6490 | 'comment!' => '(include comment in satcat data)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 6491 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6492 | 7 | my %legal_search_status = map {$_ => 1} qw{onorbit decayed all}; | |||||||||||||||||||||||||||||||||||||||||||||
| 6493 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6494 | 0 | ▶ | sub _get_search_options { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_search_options: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6495 | 0 | return \@legal_search_args; | |||||||||||||||||||||||||||||||||||||||||||||
| 6496 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6497 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6498 | 50 | ▶ | sub _parse_search_args { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_search_args: called CC=9 SCAR=22.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6499 | 50 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6500 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6501 | 50 | ▶ | my $extra = ARRAY_REF eq ref $args[0] ? shift @args : []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6502 | @args = $self->_parse_retrieve_args( | ||||||||||||||||||||||||||||||||||||||||||||||
| 6503 | 50 | [ @legal_search_args, @{ $extra } ], @args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6504 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6505 | 50 | my $opt = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 6506 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6507 | 50 | ▶ | $opt->{status} ||= 'onorbit'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt->{"status"} ||= "onorbit"
MC/DC100%1/1
$opt->{"status"} ||= "onorbit"
$opt->{"status"}
Truth table100%2/2
A
A= $opt->{"status"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6508 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6509 | 50 | ▶ | $legal_search_status{$opt->{status}} or Carp::croak <<"EOD"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6510 | Error - Illegal status '$opt->{status}'. You must specify one of | ||||||||||||||||||||||||||||||||||||||||||||||
| 6511 | 0 | @{[join ', ', map {"'$_'"} sort keys %legal_search_status]} | |||||||||||||||||||||||||||||||||||||||||||||
| 6512 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 6513 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6514 | 50 | foreach my $key ( qw{ exclude include } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6515 | 100 | ▶ | $opt->{$key} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt->{$key} ||= []
MC/DC100%1/1
$opt->{$key} ||= []
$opt->{$key}
Truth table100%2/2
A
A= $opt->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6516 | 100 | $opt->{$key} = [ map { split ',', $_ } @{ $opt->{$key} } ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 6517 | 100 | foreach ( @{ $opt->{$key} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6518 | 19 | ▶ | $include_map{$_} or Carp::croak <<"EOD"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6519 | Error - Illegal -$key value '$_'. You must specify one or more of | ||||||||||||||||||||||||||||||||||||||||||||||
| 6520 | 0 | @{[join ', ', map {"'$_'"} sort keys %include_map]} | |||||||||||||||||||||||||||||||||||||||||||||
| 6521 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 6522 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6523 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6524 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6525 | defined $opt->{tle} | ||||||||||||||||||||||||||||||||||||||||||||||
| 6526 | 50 | ▶ | or $opt->{tle} = 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6527 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6528 | 50 | return @args; | |||||||||||||||||||||||||||||||||||||||||||||
| 6529 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6530 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6531 | 7 | my %search_opts = _extract_keys( \@legal_search_args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6532 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6533 | # _remove_search_options | ||||||||||||||||||||||||||||||||||||||||||||||
| 6534 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 6535 | # Shallow clone the argument hash, remove any search arguments from | ||||||||||||||||||||||||||||||||||||||||||||||
| 6536 | # it, and return a reference to the clone. Used for sanitizing the | ||||||||||||||||||||||||||||||||||||||||||||||
| 6537 | # options for a search before passing them to retrieve() to actually | ||||||||||||||||||||||||||||||||||||||||||||||
| 6538 | # get the TLEs. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6539 | 14 | ▶ | sub _remove_search_options { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remove_search_options: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6540 | 14 | my ( $opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6541 | 14 | my %rslt = %{ $opt }; | |||||||||||||||||||||||||||||||||||||||||||||
| 6542 | 14 | delete @rslt{ keys %search_opts }; | |||||||||||||||||||||||||||||||||||||||||||||
| 6543 | 14 | return \%rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 6544 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6545 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6546 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6547 | # @keys = _sort_rest_arguments( \%rest_args ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6548 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 6549 | # This subroutine sorts the argument names in the desired order. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6550 | # A better way to do this may be to use Unicode::Collate, which | ||||||||||||||||||||||||||||||||||||||||||||||
| 6551 | # has been core since 5.7.3. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6552 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6553 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6554 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6555 | 7 | my %special = map { $_ => 1 } qw{ basicspacedata extendedspacedata }; | |||||||||||||||||||||||||||||||||||||||||||||
| 6556 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6557 | 86 | ▶ | sub _sort_rest_arguments { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sort_rest_arguments: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6558 | 86 | my ( $rest_args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6559 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6560 | 86 | ▶ | HASH_REF eq ref $rest_args | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6561 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6562 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6563 | 86 | my @rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 6564 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6565 | 86 | foreach my $key ( keys %special ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6566 | @rslt | ||||||||||||||||||||||||||||||||||||||||||||||
| 6567 | 172 | ▶ | and Carp::croak "You may not specify both '$rslt[0]' and '$key'"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6568 | defined $rest_args->{$key} | ||||||||||||||||||||||||||||||||||||||||||||||
| 6569 | 172 | ▶ | and push @rslt, $key, $rest_args->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6570 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6571 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6572 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6573 | 521 | push @rslt, map { ( $_->[0], $rest_args->{$_->[0]} ) } | |||||||||||||||||||||||||||||||||||||||||||||
| 6574 | 866 | sort { $a->[1] cmp $b->[1] } | |||||||||||||||||||||||||||||||||||||||||||||
| 6575 | # Oh, for 5.14 and tr///r | ||||||||||||||||||||||||||||||||||||||||||||||
| 6576 | 521 | map { [ $_, _swap_upper_and_lower( $_ ) ] } | |||||||||||||||||||||||||||||||||||||||||||||
| 6577 | 521 | grep { ! $special{$_} } | |||||||||||||||||||||||||||||||||||||||||||||
| 6578 | 86 | keys %{ $rest_args }; | |||||||||||||||||||||||||||||||||||||||||||||
| 6579 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6580 | 86 | return @rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 6581 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6582 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6583 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6584 | 7 | ▶ | sub _spacetrack_v2_response_is_empty { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_spacetrack_v2_response_is_empty: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6585 | 0 | my ( $resp ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6586 | 0 | return $resp->content() =~ m/ \A \s* (?: [[] \s* []] )? \s* \z /smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 6587 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6588 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6589 | 0 | ▶ | sub __readline_completer { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__readline_completer: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6590 | 0 | my ( $app, $text, $line, $start ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6591 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6592 | 0 | ▶ | $start | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6593 | or return $app->_readline_complete_command( $text ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6594 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6595 | 0 | my ( $cmd, @cmd_line ) = split $readline_word_break_re, $line, -1; | |||||||||||||||||||||||||||||||||||||||||||||
| 6596 | 0 | $cmd = _verb_alias( $cmd ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6597 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6598 | 0 | local $COMPLETION_APP = $app; | |||||||||||||||||||||||||||||||||||||||||||||
| 6599 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6600 | 0 | ▶ | if ( my $code = $app->can( "_readline_complete_command_$cmd" ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6601 | 0 | return $code->( $app, $text, $line, $start, \@cmd_line ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6602 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6603 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6604 | 0 | ▶ | if ( $text =~ m/ \A - /smx and my $code = $app->can( "_${cmd}_opts") ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$text =~ / \A - /msx and my $code = $app->can("_${cmd}_opts")
MC/DC0%0/2
$text =~ / \A - /msx and my $code = $app->can("_${cmd}_opts")
$text =~ / \A - /msx
my $code = $app->can("_${cmd}_opts")
Truth table0%0/3
A and B
A= $text =~ / \A - /msxB= my $code = $app->can("_${cmd}_opts")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6605 | 0 | return _readline_complete_options( $code, $text ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6606 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6607 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6608 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6609 | 0 | ▶ | $catalogs{$cmd} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6610 | and return $app->_readline_complete_catalog( $text, $cmd ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6611 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6612 | 0 | my @files = File::Glob::bsd_glob( "$text*" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6613 | 0 | ▶ | if ( 1 == @files ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6614 | 0 | ▶ | $files[0] .= -d $files[0] ? '/' : ' '; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6615 | } elsif ( $readline::var_CompleteAddsuffix ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6616 | 0 | foreach ( @files ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6617 | 0 | ▶ | if ( -l $_ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6618 | 0 | $_ .= '@'; | |||||||||||||||||||||||||||||||||||||||||||||
| 6619 | } elsif ( -d $_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6620 | 0 | $_ .= '/'; | |||||||||||||||||||||||||||||||||||||||||||||
| 6621 | } elsif ( -x _) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6622 | 0 | $_ .= '*'; | |||||||||||||||||||||||||||||||||||||||||||||
| 6623 | ▶ | } elsif ( -S _ || -p _ ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
-S _ or -p _
MC/DC0%0/2
-S _ or -p _
-S _
-p _
Truth table0%0/3
A or B
A= -S _B= -p _
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6624 | 0 | $_ .= '='; | |||||||||||||||||||||||||||||||||||||||||||||
| 6625 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6626 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6627 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6628 | 0 | $readline::rl_completer_terminator_character = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 6629 | 0 | return @files; | |||||||||||||||||||||||||||||||||||||||||||||
| 6630 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6631 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6632 | 0 | ▶ | sub _readline_complete_catalog { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readline_complete_catalog: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6633 | 0 | my ( $app, $text, $cat ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6634 | 0 | my $this_cat = $catalogs{$cat}; | |||||||||||||||||||||||||||||||||||||||||||||
| 6635 | 0 | ▶ | if ( ARRAY_REF eq ref $this_cat ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6636 | 0 | ▶ | my $code = $app->can( "_${cat}_catalog_version" ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6637 | or Carp::confess "Bug - _${cat}_catalog_version() not found"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6638 | 0 | $this_cat = $this_cat->[ $code->( $app ) ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 6639 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6640 | defined $text | ||||||||||||||||||||||||||||||||||||||||||||||
| 6641 | and $text ne '' | ||||||||||||||||||||||||||||||||||||||||||||||
| 6642 | 0 | ▶ | or return( sort keys %{ $this_cat } ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $text and $text ne ""
MC/DC0%0/2
defined $text and $text ne ""
defined $text
$text ne ""
Truth table0%0/3
A and B
A= defined $textB= $text ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6643 | 0 | my $re = qr/ \A \Q$text\E /smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 6644 | 0 | return ( grep { $_ =~ $re } sort keys %{ $this_cat } ) | |||||||||||||||||||||||||||||||||||||||||||||
| 6645 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6646 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6647 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6648 | 7 | my @builtins; | |||||||||||||||||||||||||||||||||||||||||||||
| 6649 | 7 | my %disallow = map { $_ => 1 } qw{ | |||||||||||||||||||||||||||||||||||||||||||||
| 6650 | can getv import isa new | ||||||||||||||||||||||||||||||||||||||||||||||
| 6651 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6652 | 0 | ▶ | sub _readline_complete_command { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readline_complete_command: not called CC=10 SCAR=44.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6653 | 0 | my ( $app, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6654 | 0 | ▶ | unless ( @builtins ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6655 | 0 | push @builtins, qw{ bye exit show }; | |||||||||||||||||||||||||||||||||||||||||||||
| 6656 | 0 | ▶ | my $stash = ( ref $app || $app ) . '::'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $app || $app
MC/DC0%0/2
ref $app || $app
ref $app
$app
Truth table0%0/3
A || B
A= ref $appB= $app
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6657 | 7 | ▶ | no strict qw{ refs }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6658 | 0 | foreach my $sym ( keys %$stash ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6659 | 0 | ▶ | $sym =~ m/ \A _ /smx | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6660 | and next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6661 | 0 | ▶ | $sym =~ m/ [[:upper:]] /smx | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6662 | and next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6663 | 0 | ▶ | $disallow{$sym} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6664 | and next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6665 | 0 | ▶ | $app->can( $sym ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6666 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6667 | 0 | push @builtins, $sym; | |||||||||||||||||||||||||||||||||||||||||||||
| 6668 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6669 | 0 | @builtins = sort @builtins; | |||||||||||||||||||||||||||||||||||||||||||||
| 6670 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6671 | 0 | my $match = qr< \A \Q$text\E >smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 6672 | 0 | my @rslt = grep { $_ =~ $match } @builtins; | |||||||||||||||||||||||||||||||||||||||||||||
| 6673 | 0 | ▶ | 1 == @rslt | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
1 == @rslt and $rslt[0] =~ / \W \z /msx
MC/DC0%0/2
1 == @rslt and $rslt[0] =~ / \W \z /msx
1 == @rslt
$rslt[0] =~ / \W \z /msx
Truth table0%0/3
A and B
A= 1 == @rsltB= $rslt[0] =~ / \W \z /msx
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6674 | and $rslt[0] =~ m/ \W \z /smx | ||||||||||||||||||||||||||||||||||||||||||||||
| 6675 | and $readline::rl_completer_terminator_character = ''; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6676 | 0 | return ( sort @rslt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6677 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6678 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6679 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6680 | 7 | ▶ | sub _readline_complete_options { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readline_complete_options: not called CC=5 SCAR=33.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6681 | 0 | my ( $code, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6682 | 0 | ▶ | $text =~ m/ \A ( --? ) ( .* ) /smx | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6683 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6684 | # my ( $prefix, $match ) = ( $1, $2 ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6685 | 0 | my $match = $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 6686 | 0 | my %lgl = @{ $code->() }; | |||||||||||||||||||||||||||||||||||||||||||||
| 6687 | 0 | my $re = qr< \A \Q$match\E >smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 6688 | 0 | my @rslt; | |||||||||||||||||||||||||||||||||||||||||||||
| 6689 | 0 | foreach ( keys %lgl ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6690 | 0 | my $type = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 6691 | 0 | ▶ | ( my $o = $_ ) =~ s/ ( [!=?] ) .* //smx | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6692 | and $type = $1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6693 | 0 | my @names = split qr< \| >smx, $o; | |||||||||||||||||||||||||||||||||||||||||||||
| 6694 | $type eq q<!> | ||||||||||||||||||||||||||||||||||||||||||||||
| 6695 | 0 | ▶ | and push @names, map { "no-$_" } @names; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6696 | 0 | push @rslt, map { "--$_" } grep { $_ =~ $re } @names; | |||||||||||||||||||||||||||||||||||||||||||||
| 6697 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6698 | 0 | return ( sort @rslt ); | |||||||||||||||||||||||||||||||||||||||||||||
| 6699 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6700 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6701 | 8 | ▶ | sub _rest_date { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rest_date: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6702 | 8 | my ( $time ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6703 | 8 | return sprintf '%04d-%02d-%02d %02d:%02d:%02d', @{ $time }; | |||||||||||||||||||||||||||||||||||||||||||||
| 6704 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6705 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6706 | # $swapped = _swap_upper_and_lower( $original ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6707 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 6708 | # This subroutine swapps upper and lower case in its argument, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6709 | # using the transliteration operator. It should be used only by | ||||||||||||||||||||||||||||||||||||||||||||||
| 6710 | # _sort_rest_arguments(). This can go away in favor of tr///r when | ||||||||||||||||||||||||||||||||||||||||||||||
| 6711 | # (if!) the minimum version becomes 5.14. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6712 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6713 | 521 | ▶ | sub _swap_upper_and_lower { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_swap_upper_and_lower: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6714 | 521 | my ( $arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6715 | 521 | $arg =~ tr/A-Za-z/a-zA-Z/; | |||||||||||||||||||||||||||||||||||||||||||||
| 6716 | 521 | return $arg; | |||||||||||||||||||||||||||||||||||||||||||||
| 6717 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6718 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6719 | # _source takes a filename, and returns the contents of the file | ||||||||||||||||||||||||||||||||||||||||||||||
| 6720 | # as a list. It dies if anything goes wrong. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6721 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6722 | 0 | ▶ | sub _source { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_source: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6723 | 0 | my ( undef, $fn ) = @_; # Invocant unused | |||||||||||||||||||||||||||||||||||||||||||||
| 6724 | 0 | ▶ | wantarray or die <<'EOD'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6725 | Error - _source () called in scalar or no context. This is a bug. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6726 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 6727 | 0 | ▶ | defined $fn or die <<'EOD'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6728 | Error - No source file name specified. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6729 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 6730 | 0 | ▶ | my $fh = IO::File->new ($fn, '<') or die <<"EOD"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6731 | Error - Failed to open source file '$fn'. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6732 | $! | ||||||||||||||||||||||||||||||||||||||||||||||
| 6733 | EOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 6734 | 0 | return <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||
| 6735 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6736 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6737 | # my $string = _stringify_oid_list( $opt, @oids ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6738 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 6739 | # This subroutine sorts the @oids array, and stringifies it by | ||||||||||||||||||||||||||||||||||||||||||||||
| 6740 | # eliminating duplicates, combining any consecutive runs of OIDs into | ||||||||||||||||||||||||||||||||||||||||||||||
| 6741 | # ranges, and joining the result with commas. The string is returned. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6742 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 6743 | # The $opt is a reference to a hash that specifies punctuation in the | ||||||||||||||||||||||||||||||||||||||||||||||
| 6744 | # stringified result. The keys used are | ||||||||||||||||||||||||||||||||||||||||||||||
| 6745 | # separator -- The string used to separate OID specifications. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 6746 | # default is ','. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6747 | # range_operator -- The string used to specify a range. If omitted, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6748 | # ranges will not be constructed. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6749 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 6750 | # Note that ranges containing only two OIDs (e.g. 5-6) will be expanded | ||||||||||||||||||||||||||||||||||||||||||||||
| 6751 | # as "5,6", not "5-6" (presuming $range_operator is '-'). | ||||||||||||||||||||||||||||||||||||||||||||||
| 6752 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6753 | 44 | ▶ | sub _stringify_oid_list { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stringify_oid_list: called CC=12 SCAR=25.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6754 | 44 | my ( $opt, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6755 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6756 | 44 | my @rslt = ( -99 ); # Prime the pump | |||||||||||||||||||||||||||||||||||||||||||||
| 6757 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6758 | @args | ||||||||||||||||||||||||||||||||||||||||||||||
| 6759 | 44 | ▶ | or return @args; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6760 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6761 | 44 | ▶ | my $separator = defined $opt->{separator} ? $opt->{separator} : ','; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6762 | 44 | my $range_operator = $opt->{range_operator}; | |||||||||||||||||||||||||||||||||||||||||||||
| 6763 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6764 | 44 | ▶ | if ( defined $range_operator ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6765 | 44 | foreach my $arg ( sort { $a <=> $b } @args ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6766 | 210 | ▶ | if ( ARRAY_REF eq ref $rslt[-1] ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6767 | 151 | ▶ | if ( $arg == $rslt[-1][1] + 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6768 | 147 | $rslt[-1][1] = $arg; | |||||||||||||||||||||||||||||||||||||||||||||
| 6769 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6770 | 4 | ▶ | $arg > $rslt[-1][1] | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6771 | and push @rslt, $arg; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6772 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6773 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6774 | 59 | ▶ | if ( $arg == $rslt[-1] + 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6775 | 11 | $rslt[-1] = [ $rslt[-1], $arg ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 6776 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6777 | 48 | ▶ | $arg > $rslt[-1] | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6778 | and push @rslt, $arg; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6779 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6780 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6781 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6782 | 44 | shift @rslt; # Drop the pump priming. | |||||||||||||||||||||||||||||||||||||||||||||
| 6783 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6784 | return join( $separator, | ||||||||||||||||||||||||||||||||||||||||||||||
| 6785 | 44 | map { ref $_ ? | |||||||||||||||||||||||||||||||||||||||||||||
| 6786 | $_->[1] > $_->[0] + 1 ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 6787 | "$_->[0]$range_operator$_->[1]" : | ||||||||||||||||||||||||||||||||||||||||||||||
| 6788 | 52 | ▶ | @{ $_ } : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6789 | $_ | ||||||||||||||||||||||||||||||||||||||||||||||
| 6790 | } @rslt | ||||||||||||||||||||||||||||||||||||||||||||||
| 6791 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 6792 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6793 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6794 | 0 | return join $separator, sort { $a <=> $b } @args; | |||||||||||||||||||||||||||||||||||||||||||||
| 6795 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6796 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6797 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6798 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6799 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||
| 6800 | 7 | require Time::HiRes; | |||||||||||||||||||||||||||||||||||||||||||||
| 6801 | 7 | *_sleep = \&Time::HiRes::sleep; | |||||||||||||||||||||||||||||||||||||||||||||
| 6802 | 7 | *_time = \&Time::HiRes::time; | |||||||||||||||||||||||||||||||||||||||||||||
| 6803 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 6804 | 7 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6805 | 0 | ▶ | *_sleep = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6806 | 0 | return sleep $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 6807 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 6808 | 0 | ▶ | *_time = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6809 | 0 | return time; | |||||||||||||||||||||||||||||||||||||||||||||
| 6810 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 6811 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6812 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6813 | # _trim replaces undefined arguments with '', trims all arguments | ||||||||||||||||||||||||||||||||||||||||||||||
| 6814 | # front and back, and returns the modified arguments. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6815 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6816 | 3 | ▶ | sub _trim { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trim: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6817 | 3 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 6818 | 3 | foreach ( @args ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 6819 | 3 | ▶ | defined $_ or $_ = ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6820 | 3 | s/ \A \s+ //smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 6821 | 3 | s/ \s+ \z //smx; | |||||||||||||||||||||||||||||||||||||||||||||
| 6822 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6823 | 3 | return @args; | |||||||||||||||||||||||||||||||||||||||||||||
| 6824 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 6825 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6826 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 6827 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6828 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||