File Coverage

blib/lib/Net/Gnats/Command/VFLD.pm
Criterion Covered Total %
statement 22 23 95.6
branch 5 6 83.3
condition n/a
subroutine 8 8 100.0
pod 2 3 66.6
total 37 40 92.5


line stmt bran cond sub pod time code
1             package Net::Gnats::Command::VFLD;
2 40     40   168 use parent 'Net::Gnats::Command';
  40         61  
  40         190  
3 40     40   2190 use strictures;
  40         87  
  40         176  
4             BEGIN {
5 40     40   3088 $Net::Gnats::Command::VFLD::VERSION = '0.20';
6             }
7 40     40   178 use vars qw($VERSION);
  40         62  
  40         1704  
8              
9 40     40   186 use Net::Gnats::Constants qw(CODE_OK CODE_SEND_TEXT CODE_INVALID_FIELD_NAME);
  40         58  
  40         7784  
10              
11             =head1 NAME
12              
13             Net::Gnats::Command::VFLD
14              
15             =head1 DESCRIPTION
16              
17             VFLD can be used to validate a given value for a field in the
18             database. The client issues the VFLD command with the name of the
19             field to validate as an argument. The server will either respond
20             with 212 (CODE_SEND_TEXT), or 410 (CODE_INVALID_FIELD_NAME) if the
21             specified field does not exist.
22              
23             Once the 212 response is received from the server, the client should
24             then send the line(s) of text to be validated, using the normal
25             quoting mechanism described for PRs. The final line of text is
26             followed by a line containing a single period, again as when sending
27             PR text.
28              
29             The server will then either respond with 210 (CODE_OK), indicating
30             that the text is acceptable, or one or more error codes describing
31             the problems with the field contents.
32              
33             =head1 PROTOCOL
34              
35             VFLD
36            
37              
38             =head1 RESPONSES
39              
40             CODE_SEND_TEXT
41             CODE_INVALID_FIELD_NAME
42              
43             =cut
44              
45             my $c = 'VFLD';
46              
47             sub new {
48 2     2 1 6 my ( $class, %options ) = @_;
49 2         4 my $self = bless \%options, $class;
50 2         6 return $self;
51             }
52              
53             sub as_string {
54 5     5 1 7 my ($self) = @_;
55 5 100       29 return undef if not defined $self->{field};
56 3         18 return $c . ' ' . $self->field->name;
57             }
58              
59             sub is_ok {
60 2     2 0 3 my ($self) = @_;
61 2 100       15 return 0 if not defined $self->response;
62 1 50       4 return 1 if $self->response->code == CODE_OK;
63 0           return 0;
64             }
65              
66             1;