| 1 | package Net::Gnats::Command::EDIT; | ||||||||||
| 2 | 40 | ▶ | use parent 'Net::Gnats::Command'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 40 | ▶ | use strictures; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 40 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 40 | $Net::Gnats::Command::EDIT::VERSION = '0.22'; | |||||||||
| 6 | } | ||||||||||
| 7 | 40 | ▶ | use vars qw($VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 40 | ▶ | use Net::Gnats::Constants qw(CODE_SEND_PR CODE_OK CODE_GNATS_LOCKED CODE_NONEXISTENT_PR CODE_SEND_PR); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | =head1 NAME | ||||||||||
| 12 | |||||||||||
| 13 | Net::Gnats::Command::EDIT | ||||||||||
| 14 | |||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||
| 16 | |||||||||||
| 17 | Verifies the replacement text for PR. If the command is successful, | ||||||||||
| 18 | the contents of PR are completely replaced with the supplied text. The | ||||||||||
| 19 | PR must previously have been locked with the LOCK command. | ||||||||||
| 20 | |||||||||||
| 21 | =head1 PROTOCOL | ||||||||||
| 22 | |||||||||||
| 23 | EDIT [PR NUMBER] | ||||||||||
| 24 | [PR CONTENTS] | ||||||||||
| 25 | |||||||||||
| 26 | =head1 RESPONSES | ||||||||||
| 27 | |||||||||||
| 28 | The possible responses are: | ||||||||||
| 29 | |||||||||||
| 30 | 431 (CODE_GNATS_LOCKED) | ||||||||||
| 31 | |||||||||||
| 32 | The database has been locked, and no PRs may be updated until the lock | ||||||||||
| 33 | is cleared. | ||||||||||
| 34 | |||||||||||
| 35 | 433 (CODE_PR_NOT_LOCKED) | ||||||||||
| 36 | |||||||||||
| 37 | The PR was not previously locked with the LOCK command. | ||||||||||
| 38 | |||||||||||
| 39 | 400 (CODE_NONEXISTENT_PR) | ||||||||||
| 40 | |||||||||||
| 41 | The specified PR does not currently exist. The SUBM command should be | ||||||||||
| 42 | used to create new PRs. | ||||||||||
| 43 | |||||||||||
| 44 | 211 (CODE_SEND_PR) | ||||||||||
| 45 | |||||||||||
| 46 | The client should now transmit the replacement PR text using the | ||||||||||
| 47 | normal PR quoting mechanism. After the PR has been sent, the server | ||||||||||
| 48 | will respond with either 200 (CODE_OK) indicating that the edit was | ||||||||||
| 49 | successful, or one or more error codes listing problems either with | ||||||||||
| 50 | the replacement PR text or errors encountered while updating the PR | ||||||||||
| 51 | file or index. | ||||||||||
| 52 | |||||||||||
| 53 | =cut | ||||||||||
| 54 | |||||||||||
| 55 | 40 | my $c = 'EDIT'; | |||||||||
| 56 | |||||||||||
| 57 | 5 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 58 | 5 | my ( $class, %options ) = @_; | |||||||||
| 59 | |||||||||||
| 60 | 5 | my $self = bless \%options, $class; | |||||||||
| 61 | 5 | ▶ | $self->{pr_number} = '-1' if not defined $self->{pr_number}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 5 | return $self; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 8 | ▶ | sub as_string { | ||||||||
|
Subroutine
as_string: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 66 | 8 | my ($self) = @_; | |||||||||
| 67 | 8 | ▶ | return undef if not defined $self->{pr_number}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | 8 | ▶ | return undef if not defined $self->{pr}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | 6 | return $c . ' ' . $self->{pr_number}; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 5 | ▶ | sub is_ok { | ||||||||
|
Subroutine
is_ok: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||
| 73 | 5 | my ($self) = @_; | |||||||||
| 74 | # returned undef because command could not be run | ||||||||||
| 75 | 5 | ▶ | return 0 if not defined $self->response; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | |||||||||||
| 77 | 3 | ▶ | return 1 if $self->response->code == CODE_OK; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | 0 | return 0; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | 40 | 1; | |||||||||