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   166 use parent 'Net::Gnats::Command';
  40         45  
  40         179  
3 40     40   2017 use strictures;
  40         50  
  40         160  
4             BEGIN {
5 40     40   2787 $Net::Gnats::Command::SUBM::VERSION = '0.20';
6             }
7 40     40   174 use vars qw($VERSION);
  40         56  
  40         1693  
8              
9 40     40   199 use Net::Gnats::Constants qw(CODE_GNATS_LOCKED CODE_SEND_PR CODE_INFORMATION_FILLER CODE_INFORMATION);
  40         67  
  40         8286  
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 14 my ( $class, %options ) = @_;
47              
48 7         18 my $self = bless \%options, $class;
49 7         21 return $self;
50             }
51              
52             sub as_string {
53 13     13 1 12 my ($self) = @_;
54 13 100       43 return undef if not defined $self->{pr};
55 12         34 return $c;
56             }
57              
58             sub is_ok {
59 7     7 0 9 my ($self) = @_;
60             # command not run yet
61 7 100       16 return 0 if not defined $self->response;
62             # malformed response
63 6 50       14 return 0 if not defined $self->response->code;
64 6 50       14 return 1 if $self->response->code == CODE_INFORMATION;
65 0           return 0;
66             }
67              
68             1;