File Coverage

blib/lib/Net/Gnats/Command/SUBM.pm
Criterion Covered Total %
statement 23 24 95.8
branch 6 8 75.0
condition n/a
subroutine 8 8 100.0
pod 2 3 66.6
total 39 43 90.7


line stmt bran cond sub pod time code
1             package Net::Gnats::Command::SUBM;
2 40     40   178 use parent 'Net::Gnats::Command';
  40         57  
  40         199  
3 40     40   2289 use strictures;
  40         60  
  40         180  
4             BEGIN {
5 40     40   3143 $Net::Gnats::Command::SUBM::VERSION = '0.21';
6             }
7 40     40   197 use vars qw($VERSION);
  40         109  
  40         2071  
8              
9 40     40   367 use Net::Gnats::Constants qw(CODE_GNATS_LOCKED CODE_SEND_PR CODE_INFORMATION_FILLER CODE_INFORMATION);
  40         69  
  40         9150  
10              
11             =head1 NAME
12              
13             Net::Gnats::Command::SUBM
14              
15             =head1 DESCRIPTION
16              
17             Submits a new PR into the database. The supplied text is verified for
18             correctness, and if no problems are found a new PR is created.
19              
20             =head1 PROTOCOL
21              
22             SUBM
23            
24              
25             =head1 RESPONSES
26              
27             The possible responses are:
28              
29             431 (CODE_GNATS_LOCKED) The database has been locked, and no PRs may
30             be submitted until the lock is cleared.
31              
32             211 (CODE_SEND_PR) The client should now transmit the new PR text
33             using the normal quoting mechanism. After the PR has been sent, the
34             server will respond with either
35              
36             351 (CODE_INFORMATION_FILLER) and
37             350 (CODE_INFORMATION) responses indicating that the new PR has been
38             created and supplying the number assigned to it, or one or more
39             error codes listing problems with the new PR text.
40              
41             =cut
42              
43             my $c = 'SUBM';
44              
45             sub new {
46 7     7 1 21 my ( $class, %options ) = @_;
47              
48 7         26 my $self = bless \%options, $class;
49 7         31 return $self;
50             }
51              
52             sub as_string {
53 13     13 1 17 my ($self) = @_;
54 13 100       55 return undef if not defined $self->{pr};
55 12         41 return $c;
56             }
57              
58             sub is_ok {
59 7     7 0 12 my ($self) = @_;
60             # command not run yet
61 7 100       24 return 0 if not defined $self->response;
62             # malformed response
63 6 50       19 return 0 if not defined $self->response->code;
64 6 50       20 return 1 if $self->response->code == CODE_INFORMATION;
65 0           return 0;
66             }
67              
68             1;