blib/lib/Complete/TZ.pm

filter: Statementstmt 71.4% 30 / 42 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 6 / 9 Podpod 100% 2 / 2 totaltotal 62.3% 38 / 61 CC 4 SCAR 12.5
CC
4
Cov
62%
complete_tz_name
6.0
__ANON__
6.0
complete_tz_offset
6.0
CRAP 3.5
↑ Summary
1 package Complete::TZ;
2  
3 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4 1 our $DATE = '2020-02-27'; # DATE
5 1 our $DIST = 'Complete-TZ'; # DIST
6 1 our $VERSION = '0.081'; # VERSION
7  
8 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Complete::Common qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Complete::Util qw(hashify_answer);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Sah::Schema::date::tz_offset;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 require Exporter;
17 1 our @ISA = qw(Exporter);
18 1 our @EXPORT_OK = qw(
19 complete_tz_name
20 complete_tz_offset
21 complete_tz
22 );
23  
24 1 our %SPEC;
25  
26 1 $SPEC{':package'} = {
27 v => 1.1,
28 summary => 'Timezone-related completion routines',
29 };
30  
31 $SPEC{complete_tz_name} = {
32 1 v => 1.1,
33 summary => 'Complete from list of timezone names',
34 description => <<'_',
35  
36 Currently implemented via looking at `/usr/share/zoneinfo`, so this only works
37 on systems that have that.
38  
39 _
40 args => {
41 %arg_word,
42 },
43 result_naked => 1,
44 result => {
45 schema => 'array',
46 },
47 };
48 0 ▶sub complete_tz_name {
Subroutine complete_tz_name: not called CC=2 SCAR=17.9
Pod documented
49 0 require Complete::File;
50  
51 0 my %args = @_;
52 0 ▶ my $word = $args{word} // "";
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
53  
54 my $res = hashify_answer(Complete::File::complete_file(
55 starting_path => '/usr/share/zoneinfo',
56 handle_tilde => 0,
57 allow_dot => 0,
58 0 ▶ filter => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
59 0 ▶ return 0 if $_[0] =~ /\.tab$/;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /\.tab$/ 0 0 0
60 0 1;
61 },
62  
63 0 word => $word,
64 ));
65 0 $res->{path_sep} = '/';
66 0 $res;
67 }
68  
69 # old name
70 1 *complete_tz = \&complete_tz_name;
71  
72 $SPEC{complete_tz_offset} = {
73 1 v => 1.1,
74 summary => 'Complete from list of existing timezone offsets (in the form of -HH:MM(:SS)? or +HH:MM(:SS)?)',
75 description => <<'_',
76  
77 _
78 args => {
79 %arg_word,
80 },
81 result_naked => 1,
82 result => {
83 schema => 'array',
84 },
85 };
86 0 ▶sub complete_tz_offset {
Subroutine complete_tz_offset: not called CC=2 SCAR=17.9
Pod documented
87 0 require Complete::Util;
88  
89 0 my %args = @_;
90 0 ▶ my $word = $args{word} // "";
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
91  
92 0 Complete::Util::complete_array_elem(
93 word => $word,
94 array => \@Sah::Schema::date::tz_offset::TZ_STRING_OFFSETS,
95 );
96 }
97  
98 1 1;
99 # ABSTRACT: Timezone-related completion routines
100  
101 __END__
↑ Summary