lib/Weather/GHCN/Options.pm

filter: Statementstmt 65.2% 193 / 296 Branchbran 31.6% 35 / 120 (5 uncoverable) Conditioncond 18.0% 9 / 50 MC/DCmcdc 6.0% 2 / 33 Subroutinesub 75.0% 24 / 32 Podpod 100% 17 / 17 totaltotal 51.6% 280 / 548 (5 uncoverable) CC 90 SCAR 56.7
CC
90
Cov
52%
validate
1015.0
initialize
72.0
options_as_string
72.0
CRAP 290.9
« lib/Weather/GHCN/App/Fetch.pm ↑ Summary lib/Weather/GHCN/StationTable.pm »
1 # Weather::GHCN::Options.pm - class for GHCN options
2
3 ## no critic (Documentation::RequirePodAtEnd)
4
5 =head1 NAME
6
7 Weather::GHCN::Options - create and manage option lists/objects used by GHCN modules and scripts
8  
9 =head1 VERSION
10  
11 version v0.0.011
12
13 =head1 SYNOPSIS
14
15 use Weather::GHCN::Options;
16
17
18 =head1 DESCRIPTION
19
20 The B<Weather::GHCN::Options> module provides a class and methods that are
21 used within GHCN modules or from application scripts that use GHCN
22 modules to create and manage options that determine the behaviour of
23 GHCN methods.
24
25 The module is primarily for use by module Weather::GHCN::StationTable.
26
27 =cut
28
29 # these are needed because perlcritic fails to detect that Object::Pad handles these things
30 ## no critic [ValuesAndExpressions::ProhibitVersionStrings]
31 ## no critic [TestingAndDebugging::RequireUseWarnings]
32
33 6 ▶use v5.18; # minimum for Object::Pad
Subroutine BEGIN: called CC=1 SCAR=0.0
34 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 6 ▶use Object::Pad 0.66 qw( :experimental(init_expr) );
Subroutine BEGIN: called CC=1 SCAR=0.0
36
37 package Weather::GHCN::Options;
38 class Weather::GHCN::Options;
39
40 6 our $VERSION = 'v0.0.011';
41
42 6 ▶use Carp qw(carp croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
43 6 ▶use Const::Fast;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 6 ▶use Hash::Wrap {-lvalue => 1, -defined => 1, -as => '_wrap_hash'};
Subroutine BEGIN: called CC=1 SCAR=0.0
45 6 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 6 ▶use Text::Abbrev;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 6 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 6 ▶use Weather::GHCN::CountryCodes qw( search_country );
Subroutine BEGIN: called CC=1 SCAR=0.0
49 6 ▶use Weather::GHCN::Common qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
50 6 ▶use YAML::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
51
52 ######################################################################
53 # Constants
54 ######################################################################
55
56 6 const my $TRUE => 1; # perl's usual TRUE
57 6 const my $FALSE => not $TRUE; # a dual-var consisting of '' and 0
58 6 const my $SPACE => q( );
59 6 const my $EMPTY => q();
60 6 const my $DASH => q(-);
61 6 const my $BAR => q(|);
62 6 const my $BANG => q(!);
63 6 const my $NEWLINE => qq(\n);
64
65 6 const my $DEFAULT_PROFILE_FILE => '~/.ghcn_fetch.yaml';
66 6 const my $ALIAS_NAME_RE => qr{ \A [_]?[[:lower:]]+ \Z }xms;
67 6 const my @REPORT_TYPE_LIST => qw(detail daily monthly yearly url curl kml stn id);
68
69 =head1 METHODS
70
71 =head2 new
72
73 Create a new Options object.
74
75 =cut
76
77 ######################################################################
78 # Set up the default Tk::Getopt option table, which we will use for
79 # both Tk::Getopt and to derive an options list of Getopt::Long
80 # for when Tk::Getopt is not installed.
81 ######################################################################
82
83 ## no critic [ValuesAndExpressions::ProhibitMagicNumbers]
84 ## no critic [ValuesAndExpressions::ProhibitNoisyQuotes]
85 ## no critic [ValuesAndExpressions::ProhibitEmptyQuotes]
86
87 6 my $Tk_opt_table = [
88 'Basic options',
89 ['location', '=s', undef, label => 'Filter stations by their location name (regex)'],
90 ['state', '=s', undef, label => 'Filter stations by state or province',
91 alias => ['province'] ],
92 ['country', '=s', undef, label => 'Filter station by the country they are in'],
93 ['gsn', '!', undef, label => 'Include only GSN reference stations'],
94 ['', '', '-'],
95 ['report', '=s', '',
96 label => 'Type of report',
97 strict => 1,
98 choices => [
99 [ 'station list', '' ],
100 [ 'yearly summary', 'yearly' ],
101 [ 'monthly summary', 'monthly' ],
102 [ 'daily summary', 'daily' ],
103 [ 'detail level', 'detail' ],
104 [ 'station KML', 'kml' ],
105 [ 'station url list', 'url' ],
106 [ 'station curl list', 'curl' ],
107 [ 'station list only', 'stn' ],
108 ]
109 ],
110 ['', '', '-'],
111 ['dataonly', '!', undef, label => 'Only print the data table'],
112 ['performance', '!', undef, label => 'Report performance statistics'],
113 ['verbose', '!', undef, label => 'Print information messages'],
114
115 'Date filters',
116 ['range', '=s', undef, label => 'Filter selected station data by year range'],
117 ['active', '=s', undef, label => 'Filter stations by their active year range'],
118 ['partial', '!', undef, label => 'Allow stations only active for part of the active range'],
119 ['quality', '=i', 90, label => 'Quality threshold (percent as an integer)'],
120 ['', '','-'],
121 ['fday', '=s', undef, label => 'Filter output to include a specific day'],
122 ['fmonth', '=s', undef, label => 'Filter output to include a specific month'],
123
124 'GIS filters',
125 ['gps', '=s', undef, label => 'Filter stations by latitude and longitude',
126 help => 'Enter decimal latitude and longitude'],
127 ['radius', '=i', 50, label => 'Radius to search for stations near coordinates'],
128
129
130 'Analysis Options',
131 ['anomalies', '!', undef, label => 'Provide calculated anomalies in the output'],
132 ['baseline', '=s', '1971-2000',
133 label => 'Baseline year range'],
134 ['precip', '!', undef, label => 'Include precipitation stats in the results'],
135 ['tavg', '!', undef, label => 'Include TAVG in the results'],
136 ['nogaps', '!', undef, label => 'Emit extra rows for missing months or days'],
137
138 'Other Options',
139 ['kmlcolor', '=s', 'red', label => 'Color to use for KML placemarks' ],
140 ['profile', '=s', $DEFAULT_PROFILE_FILE,
141 label => 'Profile file location (for option preloading)'], #, nogui => 1],
142 ['cachedir', '=s', undef, label => 'Directory for cached files'],
143 ['refresh', '=s', 'yearly',
144 help => 'Refresh yearly, (default), never, always, or if N days old (N > 1)',
145 label => 'Cache refresh option',
146 choices => [ 'yearly', 'always', 'never', '<N days old>' ],
147 ],
148 ];
149
150 ## use critic [ValuesAndExpressions::ProhibitMagicNumbers]
151 ## use critic [ValuesAndExpressions::ProhibitNoisyQuotes]
152 ## use critic [ValuesAndExpressions::ProhibitEmptyQuotes]
153
154 #####################################################################
155 # Class fields
156 ######################################################################
157
158 0 ▶field $_opt_href :mutator; # a hashref of merged options (with default values applied))
Subroutine opt_href: not called CC=1 SCAR=2.6
Pod documented
159 0 ▶field $_opt_obj :mutator; # a Hash::Wrap object derived from $_opt_href
Subroutine opt_obj: not called CC=1 SCAR=2.6
Pod documented
160 0 ▶field $_profile_href :mutator; # a hash containing profile file options
Subroutine profile_href: not called CC=1 SCAR=2.6
Pod documented
161 6 field $_tk_opt_aref; # the Tk:Getopt array that defines all GHCN options
162
163 =head1 FIELD ACCESSORS
164
165 Writeable (mutator) access is provided for some fields primarily so
166 an Options object can be tested independantly from StationTable.
167 In general, an Options object is set by the StationTable set_options
168 method and should not be modified directly by the consuming application
169 using these mutators.
170
171 =over 4
172
173 =item opt_href
174
175 This writable field is set by StationTable->set_options and is a
176 hashref of user options merged with default values.
177
178 For programmatic access to option values, use of B<opt_obj> is
179 preferred to prevent mispellings. (See B<opt_obj>.)
180
181 =item opt_obj
182
183 This writable field is set by StationTable->set_options and is a
184 Hash::Wrap object composed from the B<opt_href> hashref field. It
185 provides accessor field methods for user options (merged with default
186 values).
187
188 Using this object, rather than B<opt_href>, for access to option
189 values is safer programming choice as any misspelling of an option
190 name will result in a run time error. In contrast, mispelling a hash
191 key will simply result in an undef being returned.
192
193 =item profile_href
194
195 This writable field is set by StationTable->set_options and contains
196 the profile options it was given.
197
198 =back
199
200 =cut
201
202 ######################################################################
203 =head1 CLASS METHODS
204
205 The following class methods are supported. Class Options uses
206 Object::Perl, so these class methods (specified using the :common
207 method attribute) should be accessed using -> not :: because ->
208 will shift off the $class argument and :: won't.
209
210 =head2 get_tk_options_table
211
212 Returns: @tk_opttable or \@tk_opttable
213
214 Provides access to the predefined TK::Getopt options list that define
215 the Getopt::Long arguments supported by class StationTable for user
216 options.
217
218 The table is a list of lists and strings. The strings define
219 sections that Tk::Getopt renders as panels or tabs in the GUI it
220 constructs. The lists contain option names and types (in Getopt::Long
221 style) as well as default values, aliases, and labels to be displayed
222 in the GUI, choices for multi-select options, and other extensions.
223 See Tk::Getopt OPTTABLE ARGUMENTS for details.
224
225 =cut
226
227 3 ▶method get_tk_options_table :common () {
Subroutine get_tk_options_table: called CC=2 SCAR=7.0
Pod documented
228 3 ▶ return wantarray ? ( $Tk_opt_table->@* ) : $Tk_opt_table;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 3 0 3
229 6 }
230
231 =head2 get_getopt_list
232
233 Returns: @options or \@options
234
235 In scalar context, return a list reference to a translation of the
236 TK::Getopt options list into the simpler list used by Getopt::Long.
237 This gives application authors a choice between using Tk::Getopt and
238 the non-GUI and more traditional Getopt::Long.
239
240 In list context, this method returns a Getopt::Long-style list
241 options.
242
243 Typically, this method would be called prior to Getopt::Long in order
244 to obtain an options list for using the StationTable class; e.g.
245
246 my %opt;
247 my @options = ( Weather::GHCN::Options->get_getopt_list() );
248 GetOptions( \%opt, @options);
249
250 =cut
251
252 4 ▶method get_getopt_list :common () {
Subroutine get_getopt_list: called CC=13 SCAR=26.1
Pod documented
253 ## no critic [ProhibitDoubleSigils]
254 4 my @options_text;
255 my @options_list;
256 4 my @options;
257
258 # According to https://metacpan.org/pod/Tk::Getopt -opttable
259 # should be a reference to an array containing all options.
260 # Elements of this array may be strings, which indicate the
261 # beginning of a new group, or array references describing the
262 # options. The first element of this array is the name of the
263 # option, the second is the type (=s for string, =i for integer,
264 # ! for boolean, =f for float etc., see Getopt::Long) for a
265 # detailed list. The third element is optional and contains the
266 # default value (otherwise the default is undefined).
267 # Further elements are optional too and describe more attributes. For a
268 # complete list of these attributes refer to "OPTTABLE ARGUMENTS".
269
270 4 foreach my $row ( $Tk_opt_table->@* ) {
271 132 ▶ next if ref $row ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $row ne "ARRAY" 20 112 132
272
273 # pick off the first three values, then slurp the rest
274 112 my ($opt_kw, $opt_type, $default, @other) = $row->@*;
275 # skip the group dividers
276 112 ▶ next if not $opt_kw;
Branch: 1 branch
BranchTrueFalseTotal
unless $opt_kw 12 100 112
277
278 100 my %h;
279 100 ▶ while (my $item = shift @other) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $item = shift @other) 124 100 224
280 124 ▶ if (ref $item eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item eq 'HASH') { } 0 124 124
281 0 ▶ while (my ($k,$v) = each $item->%*) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$item) 0 0 0
282 0 $h{$k} = $v;
283 }
284 } else {
285 124 my $value = shift @other;
286 124 $h{$item} = $value;
287 }
288 }
289
290 100 ▶ my $label = $h{'label'} // $SPACE;
Condition33%1/3
$h{"label"} // $SPACE
l!l&&r!l&&!r
10000
MC/DC0%0/2
$h{"label"} // $SPACE
$h{"label"} $SPACE
Truth table33%1/3
A // B
A= $h{"label"}B= $SPACE
ABresult
1X1
011
000
291 100 ▶ my $alias_aref = $h{'alias'} // [];
Condition100%2/2
$h{"alias"} // []
l!l
496
MC/DC100%1/1
$h{"alias"} // []
$h{"alias"}
Truth table100%2/2
A
A= $h{"alias"}
Aresult
11
00
292 100 my $opt_kw_with_aliases = join $BAR, $opt_kw, $alias_aref->@*;
293
294 100 push @options_list, $opt_kw_with_aliases . $opt_type;
295 100 push @options, [$opt_kw_with_aliases, $opt_type, $label];
296 }
297
298 # calculate the width of the option spec column so the labels,
299 # which we print as comment in the text output, will line up
300
301 4 my $colwidth = 0;
302 4 foreach my $opt_aref (@options) {
303 100 my ($opt_kw_with_aliases, $opt_type, $label) = $opt_aref->@*;
304 100 my $len = length( q(') . $opt_kw_with_aliases . $opt_type . q(', ) );
305 100 ▶ $colwidth = $len if $len > $colwidth;
Branch: 1 branch
BranchTrueFalseTotal
if $len > $colwidth 8 92 100
306 }
307
308 4 my $fmt = sprintf '%%-%ds', $colwidth;
309
310 4 foreach my $opt_aref (@options) {
311 100 my ($opt_kw_with_aliases, $opt_type, $label) = $opt_aref->@*;
312 100 my $kw = sprintf $fmt, q(') . $opt_kw_with_aliases . $opt_type . q(',);
313 100 push @options_text, $kw . '# ' . $label;
314 }
315
316 4 ▶ return wantarray ? ( @options_list ) : join $NEWLINE, sort @options_text;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 4 0 4
317 6 }
318
319
320 =head2 get_option_choices ( $option )
321
322 Returns: \%choices
323
324 Find all the options which have a multiple choice response, and return
325 a hash keyed on the option name and with a values consisting
326 of a hash of the valid responses as value/label pairs.
327
328 =cut
329
330 5 ▶method get_option_choices :common () {
Subroutine get_option_choices: called CC=12 SCAR=25.7
Pod documented
331 5 my %choices;
332
333 5 foreach my $row ( $Tk_opt_table->@* ) {
334 165 ▶ next if ref $row ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $row ne "ARRAY" 25 140 165
335
336 # pick off the first three values, then slurp the rest
337 140 my ($opt_kw, $opt_type, $default, @others) = $row->@*;
338 # skip the group dividers
339 140 ▶ next if not $opt_kw;
Branch: 1 branch
BranchTrueFalseTotal
unless $opt_kw 15 125 140
340
341 125 my $href;
342 125 ▶ if (@others and ref $others[0] eq 'HASH' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@others and ref $others[0] eq 'HASH') { } 0 125 125
elsif (@others % 2 == 0) { } 125 0 125
Condition33%1/3
@others and ref $others[0] eq "HASH"
!ll&&!rl&&r
01250
MC/DC0%0/2
@others and ref $others[0] eq "HASH"
@others ref $others[0] eq "HASH"
Truth table33%1/3
A and B
A= @othersB= ref $others[0] eq "HASH"
ABresult
0X0
100
111
343 0 $href = $others[0];
344 } elsif (@others % 2 == 0) {
345 125 $href = { @others };
346 } else {
347 0 croak "*E* unable to parse opttable: @others";
348 }
349
350 125 my %hv;
351 125 ▶ if ( $href->{'choices'} and ref $href->{'choices'} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($href->{"choices"} and ref $href->{"choices"} eq "ARRAY") 10 115 125
Condition66%2/3
$href->{"choices"} and ref $href->{"choices"} eq "ARRAY"
!ll&&!rl&&r
115010
MC/DC50%1/2
$href->{"choices"} and ref $href->{"choices"} eq "ARRAY"
$href->{"choices"} ref $href->{"choices"} eq "ARRAY"
Truth table66%2/3
A and B
A= $href->{"choices"}B= ref $href->{"choices"} eq "ARRAY"
ABresult
0X0
100
111
352 10 foreach my $slot ( $href->{'choices'}->@* ) {
353 65 ▶ if (ref $slot eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $slot eq 'ARRAY') { } 45 20 65
elsif (ref $slot eq $EMPTY) { } 20 0 20
354 45 $hv{ $slot->[1] } = $slot->[0];
355 }
356 elsif (ref $slot eq $EMPTY) {
357 20 $hv{ $slot } = $TRUE;
358 }
359 }
360 10 $choices{$opt_kw} = \%hv;
361 }
362 }
363
364 5 return \%choices;
365 6 }
366
367 =head2 get_option_defaults
368
369 Returns: \%defaults
370
371 Returns the option defaults, obtained from the same predefined list
372 of lists/strings returned by get_tk_options_table.
373
374 =cut
375
376 5 ▶method get_option_defaults :common () {
Subroutine get_option_defaults: called CC=4 SCAR=13.9
Pod documented
377
378 1 my %defaults = ();
379 1 foreach my $slot ($Tk_opt_table->@*) {
380 33 ▶ next if ref $slot ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $slot ne "ARRAY" 5 28 33
381 28 my $key = $slot->[0];
382 28 ▶ next if not $key;
Branch: 1 branch
BranchTrueFalseTotal
unless $key 3 25 28
383 25 my $default_value = $slot->[2];
384 25 $defaults{$key} = $default_value;
385 }
386
387 1 return \%defaults;
388 6 }
389
390 =head2 get_profile_filespec ($filespec='')
391
392 Returns the filespec for the user profile file. If the optional
393 $filespec argument is null or an empty string, then the default
394 profile is returned. If a $filespec argument is provided, it can
395 contain '~' (to represent the user HOME directory) and that will be
396 converted to an absolute path.
397
398 =cut
399
400 6 ▶method get_profile_filespec :common ($filespec=$EMPTY) {
Subroutine get_profile_filespec: called CC=3 SCAR=11.0
Pod documented
401 # an EMPTY arg will default to ~/.ghcn_fetch.yaml
402 6 ▶ $filespec ||= $DEFAULT_PROFILE_FILE;
Condition66%2/3
$filespec ||= $DEFAULT_PROFILE_FILE
l!l&&r!l&&!r
330
MC/DC0%0/2
$filespec ||= $DEFAULT_PROFILE_FILE
$filespec $DEFAULT_PROFILE_FILE
Truth table66%2/3
A ||= B
A= $filespecB= $DEFAULT_PROFILE_FILE
ABresult
1X1
011
000
403 # Path::Tiny::path will replace ~ or ~username with the corresponding path
404 6 return path($filespec)->absolute->stringify;
405 6 }
406
407 =head2 get_profile_options ($profile='')
408
409 Return a hashref containing the options and aliases defined in the
410 the user profile file. If called with undef, returns a ref to an
411 empty hash. If called with an empty string, it reads from the default
412 profile file '~/.ghcn_fetch.yaml'.
413
414 =cut
415
416 5 ▶method get_profile_options :common ($profile=$EMPTY) {
Subroutine get_profile_options: called CC=5 SCAR=16.4
Pod documented
417
418 #debug# use DDP;
419 #debug# use Log::Dispatch;
420 #debug# my $log = Log::Dispatch->new(
421 #debug# outputs => [
422 #debug# [ 'File', min_level => 'debug', filename => 'c:/sandbox/log.log' ],
423 #debug# [ 'Screen', min_level => 'debug' ],
424 #debug#
425 #debug# ]
426 #debug# );
427
428 5 my $profile_href = {};
429
430 # passing undef will result in an empty config
431 5 ▶ return $profile_href if not defined $profile;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $profile 1 4 5
432
433 # #debug# use FindBin;
434 # #debug# open my $fh, '>>', 'c:/sandbox/log.log' or die;
435 # #debug# $log->debug( 'program ' . $0 );
436 # #debug# $log->debug( 'caller ' . join(' | ', caller) );
437 # #debug# $log->debug( 'received profile_file: ' . $_profile );
438
439 4 my $profile_filespec = Weather::GHCN::Options->get_profile_filespec($profile);
440
441 4 my $yaml_struct;
442 4 my $msg = $EMPTY;
443
444 # uncoverable branch false
445 4 ▶ if (-e $profile_filespec) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $profile_filespec) { } 3 1 4
446 # uncoverable branch false
447 3 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
448 3 $yaml_struct = YAML::Tiny->read($profile_filespec);
449 0 ▶ } catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
450 0 $msg = '*W* no cache or aliases: failed reading YAML in ' . $profile_filespec;
451 0 carp $msg;
452 }
453 3 } else {
454 1 return $profile_href;
455 }
456
457 3 ▶ $profile_href = $yaml_struct->[0]
Branch: 1 branch
BranchTrueFalseTotal
if $yaml_struct 3 0 3
458 if $yaml_struct;
459
460 #debug# $log->( 'yaml_struct length = ' . length $yaml_struct );
461 #debug# $log->( "\n" );
462 #debug# $log->( 'profile_filespec: ' . $profile_filespec );
463 #debug# $log->( 'carp ' . $msg );
464 #debug# $log->( 'FindBin::Bin ' . $FindBin::Bin );
465 #debug# $log->( "\n");
466 #debug# $log->( 'profile_href ' . np($profile_href) );
467 #debug# $log->( "\n" );
468 #debug# $log->( "================" );
469 #debug# $log->( "\n" );
470 #debug# close $fh;
471
472 3 return $profile_href;
473 6 }
474
475
476 =head2 valid_report_type ($rt, \@opttable)
477
478 This function is used to validate the report type. Valid values are
479 defined in the built-in Tk options table, which can be obtained by
480 calling:
481
482 my @opttable = ( Weather::GHCN::Options->get_tk_options_table() );
483
484 =cut
485
486 2 ▶method valid_report_type :common ($rt, $opttable_aref) {
Subroutine valid_report_type: called CC=1 SCAR=0.0
Pod documented
487 2 my $choices_href = Weather::GHCN::Options->get_option_choices;
488 2 return $choices_href->{'report'}->{ lc $rt };
489 6 }
490
491 =head2 deabbrev_report_type ($rt)
492
493 The report types supported by the -report option can be abbrevated,
494 so long as the abbrevation is unambiquous. For example, 'daily' can
495 be abbreviated to 'dail', 'dai', or 'da', but not 'd' because 'detail'
496 is also a valid report type and 'd' would not disambiguate the two.
497
498 This function takes a (possibly abbreviated) report type and returns
499 an unabbreviated report type.
500
501 =cut
502
503 1 ▶method deabbrev_report_type :common ($rt) {
Subroutine deabbrev_report_type: called CC=1 SCAR=0.0
Pod documented
504 1 my %r_abbrev = abbrev( @REPORT_TYPE_LIST );
505 1 my $deabbreved = $r_abbrev{ lc $rt };
506 1 return $deabbreved;
507 6 }
508
509 =head2 valid_refresh_option ($refresh, \@opttable)
510
511 This function is used to validate the refresh option. Valid values are
512 defined in the built-in Tk options table, which can be obtained by
513 calling:
514
515 my @opttable = ( Weather::GHCN::Options->get_tk_options_table() );
516
517 =cut
518
519 2 ▶method valid_refresh_option :common ($refresh, $opttable_aref) {
Subroutine valid_refresh_option: called CC=2 SCAR=7.0
Pod documented
520 2 my $choices_href = Weather::GHCN::Options->get_option_choices;
521 # we only validate the non-numeric options
522 2 ▶ return $TRUE if $refresh =~ m{ \A \d+ \Z }xms;
Branch: 1 branch
BranchTrueFalseTotal
if $refresh =~ / \A \d+ \Z /msux 0 2 2
523 2 return $choices_href->{'refresh'}->{ lc $refresh };
524 6 }
525
526 =head2 deabbrev_refresh_option ($refresh)
527
528 The refresh option values can be abbrevated, so long as the abbrevation
529 is unambiquous. For example, 'yearly' can
530 be abbreviated to 'y', 'ye', 'yea', etc.
531
532 This function takes a (possibly abbreviated) refresh option and returns
533 an unabbreviated refresh option.
534
535 =cut
536
537 1 ▶method deabbrev_refresh_option :common ($refresh) {
Subroutine deabbrev_refresh_option: called CC=2 SCAR=7.0
Pod documented
538 # we only deabbreviate the non-numeric options
539 1 ▶ return $refresh if $refresh =~ m{ \A \d+ \Z }xms;
Branch: 1 branch
BranchTrueFalseTotal
if $refresh =~ / \A \d+ \Z /msux 0 1 1
540 1 my %r_abbrev = abbrev( qw(yearly never always) );
541 1 my $deabbreved = $r_abbrev{ lc $refresh };
542 1 return $deabbreved;
543 6 }
544
545 ######################################################################
546 =head1 INSTANCE METHODS
547
548 =over 4
549
550 =item combine_options ( $user_opt_href, $profile_href={} )
551
552 Returns: ($opt_href, $opt_obj)
553
554 This method takes a hash reference containing user options, and optionally
555 a hash reference of profile options, and combines them with default
556 values. The end result is a complete set of all the options
557 supported by Weather::GHCN::StationTable with user-specified options taking
558 precedence over profile options, and profile options taking precedence
559 over defaults.
560
561 This set of options is returned as both a hash reference and as a
562 Hash::Wrap object. The latter is preferred for use by consuming
563 applications, because it provides accessor methods for each option.
564 In addition, an ->defined( "<option>" ) method is provided so that
565 your code can determine whether an option value was set to B<undef>.
566
567 The advantage to using an option object rather than an option hash
568 is that a misspelled option name will cause a runtime error.
569
570 =back
571
572 =cut
573
574 4 ▶method combine_options ( $user_opt_href, $profile_href={} ) {
Subroutine combine_options: called CC=6 SCAR=23.0
Pod documented
575 # assign the class-level tk_options_table aref, generated before BUILD, to the instance field
576 4 $_tk_opt_aref = $Tk_opt_table;
577
578 # start with the user options
579 4 my %merged_options = ( $user_opt_href->%* );
580
581 # merge in the profile options
582 4 ▶ while ( my ($k,$v) = each $profile_href->%* ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$profile_href) 2 4 6
583 2 ▶ $merged_options{$k} //= $v;
Condition33%1/3
$merged_options{$k} //= $v
l!l&&r!l&&!r
020
MC/DC0%0/2
$merged_options{$k} //= $v
$merged_options{$k} $v
Truth table33%1/3
A //= B
A= $merged_options{$k}B= $v
ABresult
1X1
011
000
584 }
585
586 4 my $defaults_href = get_option_defaults();
587
588 # merge in the defaults
589 0 ▶ while ( my ($k,$v) = each $defaults_href->%* ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$defaults_href) 0 0 0
590 0 ▶ $merged_options{$k} //= $v;
Condition0%0/3
$merged_options{$k} //= $v
l!l&&r!l&&!r
000
MC/DC0%0/2
$merged_options{$k} //= $v
$merged_options{$k} $v
Truth table0%0/3
A //= B
A= $merged_options{$k}B= $v
ABresult
1X1
011
000
591 }
592
593 0 $_opt_href = \%merged_options;
594 0 $_opt_obj = _wrap_hash \%merged_options;
595
596 0 return ($_opt_href, $_opt_obj);
597 6 }
598
599 =head2 initialize
600
601 Returns: @errors
602
603 This method initializes options that can't simply be initialized by
604 constants. Specifically:
605
606 =over 4
607
608 =item Aliases
609
610 Alias entries defined in the user profile are matched against
611 the -location option value. If a match is found to the alias name,
612 the alias value is substituted for the location value.
613
614 Alias names must be lowercase letters only. An optional underscore
615 prefix is permitted. Names not matching this rule will be silently
616 ignored by initialize().
617
618 =item country
619
620 The B<country> option value can be:
621
622 * a 2-character GEC (FIPS) country code
623
624 * a 3-character alpha ISO 3166 country code
625
626 * a 3-digit numeric ISO 3166 country number
627
628 * an internet domain country suffix (e.g. '.ca')
629
630 * a 3-character regex string
631
632 If a regex string is given, then it will be matched (unanchored and
633 case insensitve) against country names. If multiple matches are
634 found, then an error is returned and the user will need to provide a
635 more specific pattern.
636
637 =item active
638
639 The B<active> option filters stations according to the years that
640 they were active. If the B<range> option is specified, but the
641 B<active> option is not, then B<initialize> will set the B<active>
642 option value to the B<range> option value so that only stations that
643 were active during the requested data range will be selected.
644
645 =item quality
646
647 The B<quality> option determines whether a station's data will be
648 included in the output when it has missing data. Quality is
649 expressed as a number between 0 and 100, representing the percentage
650 of data that cannot be missing; 90% is the default For example, if
651 you have a range of 3 years (1095 days) when B<quality> is 90, then
652 you need 90% x 1095 = 985 days of data. Anything less and the
653 station is rejected.
654
655 When filters fmonth and fday are used, the amount of data included
656 will typically drop far below 90% thereby rejecting all stations.
657 To avoid this nuisance, B<initialize> will set quality to 0% if
658 either the B<fmonth> or B<fday> options are present.
659
660 =back
661
662 =cut
663
664 0 ▶method initialize () {
Subroutine initialize: not called CC=8 SCAR=42.8
Pod documented
665 0 my @errors;
666
667 0 ▶ if ( $_opt_obj->country ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_opt_obj->country) 0 0 0
668 # using undef as the search type so it will figure it out based
669 # on the value pattern and length
670 0 my @cou = search_country( $_opt_obj->country, undef );
671
672 0 ▶ push @errors, '*E* unrecognized country code or name'
Branch: 1 branch
BranchTrueFalseTotal
unless @cou 0 0 0
673 if not @cou;
674
675 0 ▶ push @errors, '*E* ambiguous country code or name'
Branch: 1 branch
BranchTrueFalseTotal
if @cou > 1 0 0 0
676 if @cou > 1;
677
678 # return the GEC (FIPS) country code, which is what GHCN uses
679 0 $_opt_obj->country = $cou[0]->{gec};
680 }
681
682 # default the station active range to the year filter range if its value is an empty string
683 0 ▶ if ( $_opt_obj->defined('active') and $_opt_obj->active eq $EMPTY ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_opt_obj->defined("active") and $_opt_obj->active eq $EMPTY) 0 0 0
Condition0%0/3
$_opt_obj->defined("active") and $_opt_obj->active eq $EMPTY
!ll&&!rl&&r
000
MC/DC0%0/2
$_opt_obj->defined("active") and $_opt_obj->active eq $EMPTY
$_opt_obj->defined("active") $_opt_obj->active eq $EMPTY
Truth table0%0/3
A and B
A= $_opt_obj->defined("active")B= $_opt_obj->active eq $EMPTY
ABresult
0X0
100
111
684 0 $_opt_obj->active = $_opt_obj->range;
685 }
686
687 0 ▶ $_opt_obj->quality = 0
Branch: 1 branch
BranchTrueFalseTotal
if $_opt_obj->fmonth or $_opt_obj->fday 0 0 0
Condition0%0/3
$_opt_obj->fmonth or $_opt_obj->fday
l!l&&r!l&&!r
000
MC/DC0%0/2
$_opt_obj->fmonth or $_opt_obj->fday
$_opt_obj->fmonth $_opt_obj->fday
Truth table0%0/3
A or B
A= $_opt_obj->fmonthB= $_opt_obj->fday
ABresult
1X1
011
000
688 if $_opt_obj->fmonth or $_opt_obj->fday;
689
690 0 return @errors;
691 6 }
692
693 =head2 options_as_string
694
695 This option returns a string that contains all the options and their
696 values, in a format similar to what they would look like when entered
697 as command-line arguments. For boolean options only the option name
698 is include (no value). Option values containing whitespace are
699 enclosed in double quotes. Option/value pairs are separated by
700 two spaces.
701
702 This method is primarily provided so the consuming application can
703 print the options that were used during a run, perhaps to a log or
704 in the output.
705
706 =cut
707
708 0 ▶method options_as_string () {
Subroutine options_as_string: not called CC=8 SCAR=42.8
Pod documented
709 0 my @options;
710 0 my $boolean = _get_boolean_options($Tk_opt_table);
711
712 0 foreach my $k ( sort keys $_opt_href->%* ) {
713 0 ▶ next if $k eq 'aliases';
Branch: 1 branch
BranchTrueFalseTotal
if $k eq "aliases" 0 0 0
714 0 ▶ next if $k eq 'cachedir';
Branch: 1 branch
BranchTrueFalseTotal
if $k eq "cachedir" 0 0 0
715 0 ▶ next if $k eq 'profile';
Branch: 1 branch
BranchTrueFalseTotal
if $k eq "profile" 0 0 0
716 0 my $v = $_opt_href->{$k};
717 0 ▶ next if not defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 0 0
718
719 0 ▶ if ( $boolean->{$k} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($boolean->{$k}) 0 0 0
720 0 push @options, $DASH . $k;
721 0 next;
722 }
723
724 0 my $val = $v;
725
726 0 ▶ if ( $val =~ m{\A \s* \Z}xms ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val =~ /\A \s* \Z/msux) 0 0 0
727 0 $val = q(") . $val . q(");
728 }
729 0 push @options, $DASH . $k. $SPACE . $val;
730 }
731 0 return join $SPACE x 2, @options;
732 6 }
733
734 =head2 validate
735
736 Returns: @errors
737
738 This method is called by StationTable->set_options to make sure all
739 the options that were provided to B<set_options> are valid. It also
740 handles abbreviations for options color and report. Any errors
741 arising from invalid value or from problems detected during
742 B<intialize> (which is called at the end of B<validate>) are returned
743 in a list.
744
745 =cut
746
747 0 ▶method validate () {
Subroutine validate: not called CC=33 SCAR=69.2
Pod documented
748 0 my @errors;
749 0 my $bad_range_cnt = 0;
750
751 0 ▶ if ( $_opt_obj->defined('aliases') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_opt_obj->defined("aliases")) 0 0 0
752 0 foreach my $alias_name ( keys $_opt_obj->aliases->%* ) {
753 0 my $errmsg = '*E* alias names in profile must be lowercase letters with optional underscore prefix: ' . $alias_name;
754 0 ▶ push @errors, $errmsg
Branch: 1 branch
BranchTrueFalseTotal
unless $alias_name =~ /$ALIAS_NAME_RE/u 0 0 0
755 unless $alias_name =~ $ALIAS_NAME_RE;
756 }
757 }
758
759 0 ▶ if ( $_opt_obj->active ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_opt_obj->active) 0 0 0
760 0 ▶ if ( not $_opt_obj->active =~ m{ \A (18|19|20)\d\d [-] (18|19|20)\d\d }xms ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_opt_obj->active =~ / \A (18|19|20)\d\d [-] (18|19|20)\d\d /msux) 0 0 0
761 0 push @errors, '*E* invalid -active year range ' . $_opt_obj->active;
762 0 $bad_range_cnt++;
763 }
764 }
765
766 0 ▶ if ( $_opt_obj->range ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_opt_obj->range) 0 0 0
767 0 ▶ if ( not $_opt_obj->range =~ m{ \A (18|19|20)\d\d [-,] (18|19|20)\d\d }xms ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_opt_obj->range =~ / \A (18|19|20)\d\d [-,] (18|19|20)\d\d /msux) 0 0 0
768 0 push @errors, '*E* invalid -range ' . $_opt_obj->range;
769 0 $bad_range_cnt++;
770 }
771 }
772
773 0 ▶ push @errors, '*E* invalid 2-character state or province code ' . $_opt_obj->state
Branch: 1 branch
BranchTrueFalseTotal
if $_opt_obj->defined("state") and not $_opt_obj->state =~ / \A [[:alpha:]]{2} \Z /msux 0 0 0
Condition0%0/3
$_opt_obj->defined("state") and not $_opt_obj->state =~ / \A [[:alpha:]]{2} \Z /msux
!ll&&!rl&&r
000
MC/DC0%0/2
$_opt_obj->defined("state") and not $_opt_obj->state =~ / \A [[:alpha:]]{2} \Z /msux
$_opt_obj->defined("state") not $_opt_obj->state =~ / \A [[:alpha:]]{2} \Z /msux
Truth table0%0/3
A and not(B)
A= $_opt_obj->defined("state")B= not $_opt_obj->state =~ / \A [[:alpha:]]{2} \Z /msux
ABresult
0X0
100
111
774 if $_opt_obj->defined('state') and not $_opt_obj->state =~ m{ \A [[:alpha:]]{2} \Z }xms;
775
776 0 ▶ push @errors, '*E* -partial only allowed if -active specified'
Branch: 1 branch
BranchTrueFalseTotal
if $_opt_obj->partial and not $_opt_obj->defined("active") 0 0 0
Condition0%0/3
$_opt_obj->partial and not $_opt_obj->defined("active")
!ll&&!rl&&r
000
MC/DC0%0/2
$_opt_obj->partial and not $_opt_obj->defined("active")
$_opt_obj->partial not $_opt_obj->defined("active")
Truth table0%0/3
A and not(B)
A= $_opt_obj->partialB= not $_opt_obj->defined("active")
ABresult
0X0
100
111
777 if $_opt_obj->partial and not $_opt_obj->defined('active');
778
779 # Note: full Condition Coverage in Devel::Cover seems impossible if these two ifs are combined
780 # (I tried every combination of uncoverable branch and condition I could think of to
781 # to suppress the missing case. In the end, this was the only thing that worked.)
782 0 ▶ if ( $_opt_obj->range and $_opt_obj->active ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_opt_obj->range and $_opt_obj->active) 0 0 0
Condition0%0/3
$_opt_obj->range and $_opt_obj->active
!ll&&!rl&&r
000
MC/DC0%0/2
$_opt_obj->range and $_opt_obj->active
$_opt_obj->range $_opt_obj->active
Truth table0%0/3
A and B
A= $_opt_obj->rangeB= $_opt_obj->active
ABresult
0X0
100
111
783 # uncoverable branch false
784 0 ▶ if ( $bad_range_cnt == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bad_range_cnt == 0) 0 0 0
785 0 my $r = rng_new( $_opt_obj->range );
786 0 my $a = rng_new( $_opt_obj->active );
787
788 0 ▶ push @errors, '*E* -range must be a subset of -active'
Branch: 1 branch
BranchTrueFalseTotal
unless $r->subset($a) 0 0 0
789 if not $r->subset($a);
790 }
791 }
792
793 0 ▶ push @errors, '*E* -gps argument must be decimal lat/long, separated by spaces or punctuation'
Branch: 1 branch
BranchTrueFalseTotal
if $_opt_obj->gps and not $_opt_obj->gps =~ / \A [+-]? \d{1,3} [.] \d+ (?: [[:punct:]] | \s+ ) [+-]? \d{1,3} [.] \d+ \Z /msux 0 0 0
Condition0%0/3
$_opt_obj->gps and not $_opt_obj->gps =~ / \A [+-]? \d{1,3} [.] \d+ (?: [[:punct:]] | \s+ ) [+-]? \d{1,3} [.] \d+ \Z /msux
!ll&&!rl&&r
000
MC/DC0%0/2
$_opt_obj->gps and not $_opt_obj->gps =~ / \A [+-]? \d{1,3} [.] \d+ (?: [[:punct:]] | \s+ ) [+-]? \d{1,3} [.] \d+ \Z /msux
$_opt_obj->gps not $_opt_obj->gps =~ / \A [+-]? \d{1,3} [.] \d+ (?: [[:punct:]] | \s+ ) [+-]? \d{1,3} [.] \d+ \Z /msux
Truth table0%0/3
A and not(B)
A= $_opt_obj->gpsB= not $_opt_obj->gps =~ / \A [+-]? \d{1,3} [.] \d+ (?: [[:punct:]] | \s+ ) [+-]? \d{1,3} [.] \d+ \Z /msux
ABresult
0X0
100
111
794 if $_opt_obj->gps and $_opt_obj->gps !~ m{ \A [+-]? \d{1,3} [.] \d+ (?: [[:punct:]] | \s+ ) [+-]? \d{1,3} [.] \d+ \Z }xms;
795
796 0 my %report_abbrev = abbrev( @REPORT_TYPE_LIST );
797
798 0 my $report = lc $_opt_obj->report;
799
800 # uncoverable branch true
801 0 ▶ croak '*E* undef report type'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $report 0 0 0
802 if not defined $report;
803
804 push @errors, '*E* invalid report option: ' . $report
805 0 ▶ if $report and not $report_abbrev{ $report };
Branch: 1 branch
BranchTrueFalseTotal
if $report and not $report_abbrev{$report} 0 0 0
Condition0%0/3
$report and not $report_abbrev{$report}
!ll&&!rl&&r
000
MC/DC0%0/2
$report and not $report_abbrev{$report}
$report not $report_abbrev{$report}
Truth table0%0/3
A and not(B)
A= $reportB= not $report_abbrev{$report}
ABresult
0X0
100
111
806
807 0 $_opt_obj->report = $report_abbrev{ $report };
808
809
810 0 my %refresh_abbrev = abbrev( qw(yearly never always) );
811
812 0 my $refresh = lc $_opt_obj->refresh;
813
814 # uncoverable branch true
815 0 ▶ croak '*E* undef refresh option'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $refresh 0 0 0
816 if not defined $refresh;
817
818 push @errors, '*E* invalid refresh option: ' . $refresh
819 0 ▶ if $refresh and not $refresh_abbrev{ $refresh };
Branch: 1 branch
BranchTrueFalseTotal
if $refresh and not $refresh_abbrev{$refresh} 0 0 0
Condition0%0/3
$refresh and not $refresh_abbrev{$refresh}
!ll&&!rl&&r
000
MC/DC0%0/2
$refresh and not $refresh_abbrev{$refresh}
$refresh not $refresh_abbrev{$refresh}
Truth table0%0/3
A and not(B)
A= $refreshB= not $refresh_abbrev{$refresh}
ABresult
0X0
100
111
820
821 0 $_opt_obj->refresh = $refresh_abbrev{ $refresh };
822
823 #-----------------------------------------------------------------
824 # end of noted section
825 #-----------------------------------------------------------------
826
827 0 my %color_abbrev = abbrev( qw(blue green azure purple red white yellow) );
828
829 # uncoverable branch false
830 0 ▶ if ( $_opt_obj->defined('kmlcolor') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_opt_obj->defined("kmlcolor")) 0 0 0
831 0 my $kmlcolor = $_opt_obj->kmlcolor;
832 0 ▶ if ( $kmlcolor eq $EMPTY ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kmlcolor eq $EMPTY) { } 0 0 0
833 0 push @errors, '*E* invalid -kmlcolor value ""'
834 } else {
835 push @errors, '*E* invalid -kmlcolor value'
836 0 ▶ if not $color_abbrev{ $kmlcolor };
Branch: 1 branch
BranchTrueFalseTotal
unless $color_abbrev{$kmlcolor} 0 0 0
837 }
838 0 $_opt_obj->kmlcolor = $color_abbrev{ $kmlcolor };
839 }
840
841
842 0 ▶ if ( $_opt_obj->defined('fmonth') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_opt_obj->defined("fmonth")) 0 0 0
843 0 ▶ push @errors, '*E* -fmonth must be a single number or valid range spec (e.g. 1-5,9)'
Branch: 1 branch
BranchTrueFalseTotal
unless rng_valid($_opt_obj->fmonth) and rng_within($_opt_obj->fmonth, "1-12") 0 0 0
Condition0%0/3
rng_valid($_opt_obj->fmonth) and rng_within($_opt_obj->fmonth, "1-12")
!ll&&!rl&&r
000
MC/DC0%0/2
rng_valid($_opt_obj->fmonth) and rng_within($_opt_obj->fmonth, "1-12")
rng_valid($_opt_obj->fmonth) rng_within($_opt_obj->fmonth, "1-12")
Truth table0%0/3
A and B
A= rng_valid($_opt_obj->fmonth)B= rng_within($_opt_obj->fmonth, "1-12")
ABresult
0X0
100
111
844 if not rng_valid($_opt_obj->fmonth)
845 or not rng_within($_opt_obj->fmonth, '1-12');
846 }
847
848 0 ▶ if ( $_opt_obj->defined('fday') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_opt_obj->defined("fday")) 0 0 0
849 0 ▶ push @errors, '*E* -fday must be a single number or valid range spec (e.g. 3,15,20-31)'
Branch: 1 branch
BranchTrueFalseTotal
unless rng_valid($_opt_obj->fday) and rng_within($_opt_obj->fday, "1-31") 0 0 0
Condition0%0/3
rng_valid($_opt_obj->fday) and rng_within($_opt_obj->fday, "1-31")
!ll&&!rl&&r
000
MC/DC0%0/2
rng_valid($_opt_obj->fday) and rng_within($_opt_obj->fday, "1-31")
rng_valid($_opt_obj->fday) rng_within($_opt_obj->fday, "1-31")
Truth table0%0/3
A and B
A= rng_valid($_opt_obj->fday)B= rng_within($_opt_obj->fday, "1-31")
ABresult
0X0
100
111
850 if not rng_valid($_opt_obj->fday)
851 or not rng_within($_opt_obj->fday, '1-31');
852 }
853
854 0 my @init_errors = $self->initialize();
855
856 0 return (@errors, @init_errors);
857 6 }
858
859 =head2 DOES
860
861 Defined by Object::Pad. Included for POD::Coverage.
862
863 =head2 META
864
865 Defined by Object::Pad. Included for POD::Coverage.
866
867 =cut
868
869 ######################################################################
870 # Subroutines
871 ######################################################################
872
873 0 ▶sub _get_boolean_options ($_tk_opt_aref) {
Subroutine _get_boolean_options: not called CC=4 SCAR=30.0
874
875 0 my %boolean;
876
877 0 foreach my $row ( $_tk_opt_aref->@* ) {
878 0 ▶ next unless ref $row eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $row eq "ARRAY" 0 0 0
879 0 my ($name, $type) = $row->@*;
880 0 ▶ $boolean{$name}++ if $type eq $BANG;
Branch: 1 branch
BranchTrueFalseTotal
if $type eq $BANG 0 0 0
881 }
882
883 0 return \%boolean;
884 }
885
886 6 1;
« lib/Weather/GHCN/App/Fetch.pm ↑ Summary lib/Weather/GHCN/StationTable.pm »