Gnats/Command/FTYP.pm

filter: Statementstmt 100% 35 / 35 Branchbran 93.7% 15 / 16 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 8 / 8 Podpod 66.6% 2 / 3 totaltotal 97.0% 65 / 67 CC 10 SCAR 12.8
CC
10
Cov
98%
is_ok
6.0
new
4.0
as_string
2.0
CRAP 3.6
« Gnats/Session.pm ↑ Summary Gnats/Command/FDSC.pm »
1 package Net::Gnats::Command::FTYP;
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::FTYP::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::FTYP
14  
15 =head1 DESCRIPTION
16  
17 Describes the type of data held in the field(s) specified with the
18 command.
19  
20 If multiple field names were given, multiple response lines will be
21 sent, one for each field, using the standard continuation protocol;
22 each response except the last will have a dash - immedately after
23 the response code.
24  
25 The currently defined data types are:
26  
27 Text
28  
29 A plain text field, containing exactly one line.
30  
31 MultiText
32  
33 A text field possibly containing multiple lines of text.
34  
35 Enum
36  
37 An enumerated data field; the value is restricted to one entry out
38 of a list of values associated with the field.
39  
40 MultiEnum
41  
42 The field contains one or more enumerated values. Values are
43 separated with spaces or colons :.
44  
45 Integer
46  
47 The field contains an integer value, possibly signed.
48  
49 Date
50  
51 The field contains a date.
52  
53 TextWithRegex
54  
55 The value in the field must match one or more regular expressions
56 associated with the field.
57  
58 =head1 PROTOCOL
59  
60 FTYP [fields...]
61  
62 =head1 RESPONSES
63  
64 The possible responses are:
65  
66 350 (CODE_INFORMATION)
67  
68 The normal response; the supplied text is the data type.
69  
70 410 (CODE_INVALID_FIELD_NAME)
71  
72 The specified field does not exist.
73  
74 =cut
75  
76  
77 40 my $c = 'FTYP';
78  
79 46 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod documented
80 46 my ( $class, %options ) = @_;
81 46 my $self = bless \%options, $class;
82 46 $self->{requests_multi} = 0;
83 46 ▶ return $self if not defined $self->{fields};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"fields"} 1 45 46
84  
85 45 ▶ if (ref $self->{fields} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'fields'} eq 'ARRAY') { } 42 3 45
86 42 ▶ $self->{requests_multi} = 1 if scalar @{ $self->{fields} } > 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$self->{"fields"};} > 1 40 2 42
87 }
88 else {
89 3 $self->{fields} = [ $self->{fields} ];
90 }
91 45 return $self;
92 }
93  
94 97 ▶sub as_string {
Subroutine as_string: called CC=2 SCAR=6.9
Pod documented
95 97 my ($self) = @_;
96 97 ▶ return undef if not defined $self->{fields};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"fields"} 1 96 97
97 96 return $c . ' ' . join ( ' ', @{$self->{fields}} );
98 }
99  
100 # this command can take multiple fields, each getting their own response.
101 # so, we check that 'everything' is okay by looking at the parent response.
102 8 ▶sub is_ok {
Subroutine is_ok: called CC=6 SCAR=17.9
Pod undocumented
103 8 my $self = shift;
104 8 ▶ return 0 if not defined $self->response;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->response 1 7 8
105 7 ▶ return 0 if not defined $self->response->code;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->response->code 0 7 7
106  
107 7 ▶ if ( $self->{requests_multi} == 0 and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"requests_multi"} == 0 and $self->response->code == 350) 4 3 7
Condition100%3/3
$self->{"requests_multi"} == 0 and $self->response->code == 350
!ll&&!rl&&r
214
MC/DC100%2/2
$self->{"requests_multi"} == 0 and $self->response->code == 350
$self->{"requests_multi"} == 0 $self->response->code == 350
Truth table100%3/3
A and B
A= $self->{"requests_multi"} == 0B= $self->response->code == 350
ABresult
0X0
100
111
108 $self->response->code == CODE_INFORMATION) {
109 4 return 1;
110 }
111 3 ▶ return 1 if $self->response->code == CODE_INFORMATION;
Branch: 1 branch
BranchTrueFalseTotal
if $self->response->code == 350 2 1 3
112 1 return 0;
113 }
114  
115  
116 40 1;
« Gnats/Session.pm ↑ Summary Gnats/Command/FDSC.pm »