File Coverage

blib/lib/Net/Gnats/Command/DELETE.pm
Criterion Covered Total %
statement 20 21 95.2
branch 1 2 50.0
condition n/a
subroutine 8 8 100.0
pod 2 3 66.6
total 31 34 91.1


line stmt bran cond sub pod time code
1             package Net::Gnats::Command::DELETE;
2 40     40   174 use parent 'Net::Gnats::Command';
  40         52  
  40         174  
3 40     40   2046 use strictures;
  40         51  
  40         168  
4             BEGIN {
5 40     40   2861 $Net::Gnats::Command::DELETE::VERSION = '0.20';
6             }
7 40     40   170 use vars qw($VERSION);
  40         68  
  40         1689  
8              
9 40     40   191 use Net::Gnats::Constants qw(CODE_OK CODE_NO_ACCESS CODE_LOCKED_PR CODE_GNATS_LOCKED);
  40         66  
  40         6862  
10              
11             =head1 NAME
12              
13             Net::Gnats::Command::DELETE
14              
15             =head1 DESCRIPTION
16              
17             Deletes the specified PR. The user making the request must have
18             admin privileges (see Controlling access to databases). If
19             successful, the PR is removed from the filesystem and the index
20             file; a gap will be left in the numbering sequence for PRs. No
21             checks are made that the PR is closed.
22              
23             =head1 PROTOCOL
24              
25             DELETE [PR NUMBER]
26              
27             =head1 RESPONSES
28              
29             The possible responses are:
30              
31             210 (CODE_OK)
32              
33             The PR was successfully deleted.
34              
35             422 (CODE_NO_ACCESS)
36              
37             The user requesting the delete does not have admin privileges.
38              
39             430 (CODE_LOCKED_PR)
40              
41             The PR is locked by another session.
42              
43             431 (CODE_GNATS_LOCKED)
44              
45             The database has been locked, and no PRs may be updated until the
46             lock is cleared.
47              
48             6xx (internal error)
49              
50             The PR could not be successfully deleted, usually because of
51             permission or other filesystem-related problems.
52              
53             =cut
54              
55             my $c = 'DELETE';
56              
57             sub new {
58 1     1 1 3 my ( $class, %options ) = @_;
59              
60 1         3 my $self = bless \%options, $class;
61 1         3 return $self;
62             }
63              
64             sub as_string {
65 2     2 1 1 my $self = shift;
66 2         11 return $c . ' ' . $self->{pr_number};
67             }
68              
69             sub is_ok {
70 1     1 0 2 my $self = shift;
71 1 50       2 return 1 if $self->response->code == CODE_OK;
72 0           return 0;
73             }
74              
75             1;