File Coverage

blib/lib/Net/Gnats/Command/CHEK.pm
Criterion Covered Total %
statement 19 22 86.3
branch 2 4 50.0
condition n/a
subroutine 7 8 87.5
pod 2 3 66.6
total 30 37 81.0


line stmt bran cond sub pod time code
1             package Net::Gnats::Command::CHEK;
2 40     40   164 use parent 'Net::Gnats::Command';
  40         53  
  40         173  
3 40     40   2097 use strictures;
  40         61  
  40         161  
4             BEGIN {
5 40     40   2971 $Net::Gnats::Command::CHEK::VERSION = '0.20';
6             }
7 40     40   182 use vars qw($VERSION);
  40         47  
  40         1493  
8              
9 40     40   179 use Net::Gnats::Constants qw(CODE_SEND_PR CODE_OK CODE_CMD_ERROR);
  40         54  
  40         7600  
10              
11             =head1 NAME
12              
13             Net::Gnats::Command::CHEK
14              
15             =head1 DESCRIPTION
16              
17             Used to check the text of an entire PR for errors. Unlike the VFLD
18             command, it accepts an entire PR at once instead of the contents of an
19             individual field.
20              
21             The initial argument indicates that the PR text to be checked is for a
22             PR that will be newly created, rather than an edit or replacement of
23             an existing PR.
24              
25             =heads EXAMPLES
26              
27             # Check an initial PR
28             Net::Gnats::Command::CHEK(pr => $pr, type = 'initial');
29              
30             # Check a modified PR
31             Net::Gnats::Command::CHEK(pr => $pr);
32              
33             # Issue to Gnats
34             $session->issue(Net::Gnats::Command::CHEK(pr => $pr))->is_ok;
35              
36             # If running from Net::Gnats object
37             $g->session->issue(Net::Gnats::Command::CHEK(pr => $pr))->is_ok;
38              
39             =head1 PROTOCOL
40              
41             CHEK [initial]
42              
43             =head1 RESPONSES
44              
45             After the CHEK command is issued, the server will respond with either
46             a 440 (CODE_CMD_ERROR) response indicating that the command arguments
47             were incorrect, or a 211 (CODE_SEND_PR) response code will be sent.
48              
49             Once the 211 response is received from the server, the client should
50             send the PR using the normal PR quoting mechanism; the final line of
51             the PR is then followed by a line containing a single period, as
52             usual.
53              
54             The server will then respond with either a 200 (CODE_OK) response,
55             indicating there were no problems with the supplied text, or one or
56             more error codes listing the problems with the PR.
57              
58             =cut
59              
60             my $c = 'CHEK';
61              
62             sub new {
63 3     3 1 16 my ( $class, %options ) = @_;
64 3         9 my $self = bless \%options, $class;
65 3         11 return $self;
66             }
67              
68             sub as_string {
69 4     4 1 3 my $self = shift;
70 4 100       24 return $c . ' ' . $self->{type} if defined $self->{type};
71 1         6 return $c;
72             }
73              
74             sub is_ok {
75 0     0 0   my $self = shift;
76 0 0         return 1 if $self->response->code == CODE_OK;
77 0           return 0;
78             }
79              
80             1;