Gnats/Command/LIST.pm

filter: Statementstmt 97.5% 39 / 40 Branchbran 60.0% 6 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 50.0% 2 / 4 totaltotal 88.8% 56 / 63 CC 7 SCAR 8.9
CC
7
Cov
90%
formatted
4.0
is_ok
3.5
as_string
2.0
CRAP 2.4
« Gnats/Command/INPUTDEFAULT.pm ↑ Summary Gnats/Command/LOCK.pm »
1 package Net::Gnats::Command::LIST;
2 40 ▶use parent 'Net::Gnats::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 40 ▶use strictures;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
5 40 $Net::Gnats::Command::LIST::VERSION = '0.22';
6 }
7 40 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 40 ▶use Net::Gnats::Constants qw(CODE_TEXT_READY CODE_INVALID_LIST);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 =head1 NAME
12  
13 Net::Gnats::Command::LIST
14  
15 =head1 DESCRIPTION
16  
17  
18 Describes various aspects of the database. The lists are returned as
19 a list of records, one per line. Each line may contain a number of
20 colon-separated fields.
21  
22 Possible values for list type include
23  
24 Categories : Describes the legal categories for the database.
25  
26 Submitters : Describes the set of submitters for the database.
27  
28 Responsible : Lists the names in the responsible administrative
29 file, including their full names and email addresses.
30  
31 States
32  
33 Lists the states listed in the state administrative file, including
34 the state type (usually blank for most states; the closed state has
35 a special type).
36  
37 FieldNames Lists the entire set of PR fields.
38  
39 InitialInputFields : Lists the fields that should be present when a
40 PR is initially entered.
41  
42 InitialRequiredFields : Lists fields that have to be present and
43 nonempty when a PR is initially entered (fields containing only
44 blank characters such as spaces or newlines are considered empty.)
45  
46 Databases : Lists the set of databases.
47  
48 =head1 PROTOCOL
49  
50 LIST [list type]
51  
52 =head1 RESPONSES
53  
54 The possible responses are:
55  
56 301 (CODE_TEXT_READY) Normal response, followed by the records
57 making up the list as described above.
58  
59 416 (CODE_INVALID_LIST) The requested list does not exist.
60  
61 =cut
62  
63 40 my $c = 'LIST';
64  
65 40 my $s = { databases => ['name', 'desc', 'path'],
66 categories => ['name', 'desc', 'contact', 'notify'],
67 submitters => ['name', 'desc', 'contract', 'response',
68 'contact', 'othernotify'],
69 responsible => ['name', 'realname', 'email'],
70 states => ['name', 'type', 'desc'],
71 };
72  
73 133 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
74 133 my ( $class, %options ) = @_;
75 133 my $self = bless \%options, $class;
76 133 return $self;
77 }
78  
79 279 ▶sub as_string {
Subroutine as_string: called CC=2 SCAR=6.9
Pod documented
80 279 my $self = shift;
81 279 ▶ return undef if not defined $self->{subcommand};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"subcommand"} 2 277 279
82 277 return $c . ' ' . $self->{subcommand};
83 }
84  
85 8 ▶sub is_ok {
Subroutine is_ok: called CC=3 SCAR=12.5
Pod undocumented
86 8 my $self = shift;
87 8 ▶ return 0 if not defined $self->response;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->response 0 8 8
88 8 ▶ return 1 if $self->response->code == CODE_TEXT_READY;
Branch: 1 branch
BranchTrueFalseTotal
if $self->response->code == 301 8 0 8
89 0 return 0;
90 }
91  
92 10 ▶sub formatted {
Subroutine formatted: called CC=4 SCAR=13.9
Pod undocumented
93 10 my $self = shift;
94 10 ▶ return [] if not defined $self->response;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->response 0 10 10
95 10 ▶ return [] if $self->response->code != CODE_TEXT_READY;
Branch: 1 branch
BranchTrueFalseTotal
if $self->response->code != 301 0 10 10
96  
97 10 my $keynames = $s->{lc $self->{subcommand}};
98  
99 10 my $result = [];
100 10 foreach my $row (@{ $self->response->as_list }) {
101 14 my @parts = split ':', $row;
102 14 push @{ $result}, { map { @{ $keynames }[$_] =>
103 14 $parts[$_] } 0..( scalar @{$keynames} - 1) };
104 }
105 10 return $result;
106 }
107  
108 40 1;
« Gnats/Command/INPUTDEFAULT.pm ↑ Summary Gnats/Command/LOCK.pm »