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   181 use parent 'Net::Gnats::Command';
  40         54  
  40         187  
3 40     40   2182 use strictures;
  40         57  
  40         184  
4             BEGIN {
5 40     40   3185 $Net::Gnats::Command::DELETE::VERSION = '0.21';
6             }
7 40     40   192 use vars qw($VERSION);
  40         67  
  40         1834  
8              
9 40     40   217 use Net::Gnats::Constants qw(CODE_OK CODE_NO_ACCESS CODE_LOCKED_PR CODE_GNATS_LOCKED);
  40         71  
  40         8151  
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 4 my ( $class, %options ) = @_;
59              
60 1         2 my $self = bless \%options, $class;
61 1         4 return $self;
62             }
63              
64             sub as_string {
65 2     2 1 2 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       3 return 1 if $self->response->code == CODE_OK;
72 0           return 0;
73             }
74              
75             1;