File Coverage

blib/lib/Net/Gnats/Command/APPN.pm
Criterion Covered Total %
statement 23 24 95.8
branch 7 8 87.5
condition n/a
subroutine 8 8 100.0
pod 2 3 66.6
total 40 43 93.0


line stmt bran cond sub pod time code
1             package Net::Gnats::Command::APPN;
2 40     40   173 use parent 'Net::Gnats::Command';
  40         58  
  40         334  
3 40     40   2296 use strictures;
  40         53  
  40         187  
4             BEGIN {
5 40     40   3223 $Net::Gnats::Command::APPN::VERSION = '0.21';
6             }
7 40     40   188 use vars qw($VERSION);
  40         58  
  40         2085  
8              
9 40         10820 use Net::Gnats::Constants qw(CODE_SEND_TEXT CODE_OK CODE_NONEXISTENT_PR CODE_INVALID_FIELD_NAME
10             CODE_UNREADABLE_PR CODE_GNATS_LOCKED CODE_LOCKED_PR
11 40     40   993 CODE_INVALID_FIELD_CONTENTS);
  40         52  
12              
13             =head1 NAME
14              
15             Net::Gnats::Command::APPN
16              
17             =head1 DESCRIPTION
18              
19             The APPN command appends to the contents of field in PR with the supplied
20             text.
21              
22             When first issued, it returns a 212 (CODE_SEND_TEXT). The client
23             should then transmit the new field contents using the standard PR
24             quoting mechanism. After the server has read the new contents, it then
25             attempts to make the requested change to the PR.
26              
27             The command returns a 210 (CODE_OK) when it does not require a Change Reason.
28              
29             When the command returns a 213 () it expects a Change Reason. The
30             Change Reason is a multiText value. After successful submit of the
31             Change Reason, it returns a 210 (CODE_OK).
32              
33             =head1 PROTOCOL
34              
35             When making a change that does not require a change reason:
36              
37             APPN
38             <-- 212
39            
40             <-- 210
41              
42             When making a change that requires a change reason:
43              
44             APPN
45             <-- 212
46            
47             <-- 213
48            
49             <-- 210
50              
51             =head1 RESPONSES
52              
53             The possible responses are:
54              
55             210 (CODE_OK) The PR field was successfully changed.
56              
57             400 (CODE_NONEXISTENT_PR) The PR specified does not exist.
58              
59             410 (CODE_INVALID_FIELD_NAME) The specified field does not exist.
60              
61             402 (CODE_UNREADABLE_PR) The PR could not be read.
62              
63             431 (CODE_GNATS_LOCKED) The database has been locked, and no PRs may
64             be updated until the lock is cleared.
65              
66             430 (CODE_LOCKED_PR) The PR is locked, and may not be altered until
67             the lock is cleared.
68              
69             413 (CODE_INVALID_FIELD_CONTENTS) The supplied (or resulting) field
70             contents are not valid for the field.
71              
72             6xx (internal error) An internal error occurred, usually because of
73             permission or other filesystem-related problems. The PR may or may
74             not have been altered.
75              
76             =cut
77              
78             my $c = 'APPN';
79              
80             sub new {
81 4     4 1 8 my ( $class, %options ) = @_;
82              
83 4         6 my $self = bless \%options, $class;
84 4         7 return $self;
85             }
86              
87             # Actually two commands, send this first and then the contents of the
88             # field.
89             sub as_string {
90 5     5 1 6 my ($self) = @_;
91 5 100       24 return undef if not defined $self->{pr_number};
92 3 100       13 return undef if not defined $self->{field};
93 2         9 return $c . ' ' . $self->{pr_number} . ' ' . $self->{field}->name;
94             }
95              
96             sub is_ok {
97 4     4 0 5 my ($self) = @_;
98 4 100       13 return 0 if not defined $self->response;
99 1 50       4 return 1 if $self->response->code == CODE_OK;
100 0           return 0;
101             }
102              
103             1;