File Coverage

blib/lib/Net/Gnats/Command/REPL.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::REPL;
2 40     40   203 use parent 'Net::Gnats::Command';
  40         68  
  40         220  
3 40     40   2192 use strictures;
  40         71  
  40         215  
4             BEGIN {
5 40     40   8864 $Net::Gnats::Command::REPL::VERSION = '0.22';
6             }
7 40     40   199 use vars qw($VERSION);
  40         72  
  40         1858  
8              
9 40     40   254 use Net::Gnats::Constants qw(CODE_OK CODE_NONEXISTENT_PR CODE_INVALID_FIELD_NAME CODE_UNREADABLE_PR CODE_GNATS_LOCKED CODE_LOCKED_PR CODE_INVALID_FIELD_CONTENTS);
  40         76  
  40         11151  
10              
11             =head1 NAME
12              
13             Net::Gnats::Command::REPL
14              
15             =head1 DESCRIPTION
16              
17             Appends to or replaces the contents of field in PR with the supplied
18             text. The command returns a 201 (CODE_SEND_TEXT) response; the
19             client should then transmit the new field contents using the
20             standard PR quoting mechanism. After the server has read the new
21             contents, it then attempts to make the requested change to the PR.
22              
23             =head1 PROTOCOL
24              
25             REPL
26            
27              
28             =head1 RESPONSES
29              
30             The possible responses are:
31              
32             200 (CODE_OK) The PR field was successfully changed.
33              
34             400 (CODE_NONEXISTENT_PR) The PR specified does not exist.
35              
36             410 (CODE_INVALID_FIELD_NAME) The specified field does not exist.
37              
38             402 (CODE_UNREADABLE_PR) The PR could not be read.
39              
40             431 (CODE_GNATS_LOCKED) The database has been locked, and no PRs may
41             be updated until the lock is cleared.
42              
43             430 (CODE_LOCKED_PR) The PR is locked, and may not be altered until
44             the lock is cleared.
45              
46             413 (CODE_INVALID_FIELD_CONTENTS) The supplied (or resulting) field
47             contents are not valid for the field.
48              
49             6xx (internal error) An internal error occurred, usually because of
50             permission or other filesystem-related problems. The PR may or may
51             not have been altered.
52              
53             =cut
54              
55             my $c = 'REPL';
56              
57             sub new {
58 9     9 1 32 my ( $class, %options ) = @_;
59              
60 9         17 my $self = bless \%options, $class;
61 9         35 return $self;
62             }
63              
64             sub as_string {
65 15     15 1 24 my ($self) = @_;
66 15 100       64 return undef if not defined $self->{pr_number};
67 13 100       39 return undef if not defined $self->{field};
68 12         46 return $c . ' ' . $self->{pr_number} . ' ' . $self->{field}->name;
69             }
70              
71             sub is_ok {
72 9     9 0 16 my ($self) = @_;
73 9 100       31 return 0 if not defined $self->response;
74 6 50       18 return 1 if $self->response->code == CODE_OK;
75 0           return 0;
76             }
77              
78             1;