Gnats/Command/INPUTDEFAULT.pm

filter: Statementstmt 94.1% 32 / 34 Branchbran 85.7% 12 / 14 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 8 / 8 Podpod 66.6% 2 / 3 totaltotal 89.0% 57 / 64 CC 9 SCAR 11.6
CC
9
Cov
90%
is_ok
5.2
new
4.0
as_string
2.0
CRAP 3.2
« Gnats/Command/FIELDFLAGS.pm ↑ Summary Gnats/Command/LIST.pm »
1 package Net::Gnats::Command::INPUTDEFAULT;
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::INPUTDEFAULT::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_INFORMATION CODE_INVALID_FIELD_NAME);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 =head1 NAME
12  
13 Net::Gnats::Command::INPUTDEFAULT
14  
15 =head1 DESCRIPTION
16  
17 Like the FDSC and FTYP commands, multiple field names may be listed
18 with the command, and a response line will be returned for each one
19 in the order that the fields appear on the command line.
20  
21 =head1 PROTOCOL
22  
23 INPUTDEFAULT [fields...]
24  
25 =head1 RESPONSES
26  
27 Returns the suggested default value for a field when a PR is
28 initially created. The possible responses are either 410
29 (CODE_INVALID_FIELD_NAME), meaning that the specified field is
30 invalid or nonexistent, or 350 (CODE_INFORMATION) which contains the
31 default value for the field.
32  
33 =cut
34  
35 40 my $c = 'INPUTDEFAULT';
36  
37 41 ▶sub new {
Subroutine new: called CC=4 SCAR=14.0
Pod documented
38 41 my ( $class, %options ) = @_;
39  
40 41 my $self = bless \%options, $class;
41 41 $self->{requests_multi} = 0;
42 41 ▶ return $self if not defined $self->{fields};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"fields"} 1 40 41
43  
44 40 ▶ if (ref $self->{fields} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'fields'} eq 'ARRAY') { } 40 0 40
45 40 ▶ $self->{requests_multi} = 1 if scalar @{ $self->{fields} } > 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$self->{"fields"};} > 1 39 1 40
46 }
47 else {
48 0 $self->{fields} = [ $self->{fields} ];
49 }
50 40 return $self;
51 }
52  
53 85 ▶sub as_string {
Subroutine as_string: called CC=2 SCAR=6.9
Pod documented
54 85 my ($self) = @_;
55 85 ▶ return undef if not defined $self->{fields};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"fields"} 1 84 85
56 84 return $c . ' ' . join ( ' ', @{$self->{fields}} );
57 }
58  
59 # this command can take multiple fields, each getting their own response.
60 # so, we check that 'everything' is okay by looking at the parent response.
61 3 ▶sub is_ok {
Subroutine is_ok: called CC=5 SCAR=16.5
Pod undocumented
62 3 my $self = shift;
63 3 ▶ return 0 if not defined $self->response;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->response 1 2 3
64 2 ▶ if ( $self->{requests_multi} == 0 and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"requests_multi"} == 0 and $self->response->code == 350) 1 1 2
Condition66%2/3
$self->{"requests_multi"} == 0 and $self->response->code == 350
!ll&&!rl&&r
101
MC/DC50%1/2
$self->{"requests_multi"} == 0 and $self->response->code == 350
$self->{"requests_multi"} == 0 $self->response->code == 350
Truth table66%2/3
A and B
A= $self->{"requests_multi"} == 0B= $self->response->code == 350
ABresult
0X0
100
111
65 $self->response->code == CODE_INFORMATION) {
66 1 return 1;
67 }
68 1 ▶ return 1 if $self->response->code == CODE_INFORMATION;
Branch: 1 branch
BranchTrueFalseTotal
if $self->response->code == 350 1 0 1
69 0 return 0;
70 }
71  
72 40 1;
« Gnats/Command/FIELDFLAGS.pm ↑ Summary Gnats/Command/LIST.pm »