| 1 | package Net::Gnats::Command::CHDB; | ||||||||||
| 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::CHDB::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_OK CODE_NO_ACCESS CODE_INVALID_DATABASE); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | =head1 NAME | ||||||||||
| 12 | |||||||||||
| 13 | Net::Gnats::Command::CHDB | ||||||||||
| 14 | |||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||
| 16 | |||||||||||
| 17 | Switches the current database to the name specified in the command. | ||||||||||
| 18 | |||||||||||
| 19 | =head1 PROTOCOL | ||||||||||
| 20 | |||||||||||
| 21 | CHDB [database] | ||||||||||
| 22 | |||||||||||
| 23 | =head1 RESPONSES | ||||||||||
| 24 | |||||||||||
| 25 | The possible responses are: | ||||||||||
| 26 | |||||||||||
| 27 | 422 (CODE_NO_ACCESS) | ||||||||||
| 28 | |||||||||||
| 29 | The user does not have permission to access the requested database. | ||||||||||
| 30 | |||||||||||
| 31 | 417 (CODE_INVALID_DATABASE) | ||||||||||
| 32 | |||||||||||
| 33 | The database specified does not exist, or one or more configuration | ||||||||||
| 34 | errors in the database were encountered. | ||||||||||
| 35 | |||||||||||
| 36 | 210 (CODE_OK) | ||||||||||
| 37 | |||||||||||
| 38 | The current database is now database. Any operations performed will | ||||||||||
| 39 | now be applied to database. | ||||||||||
| 40 | |||||||||||
| 41 | =cut | ||||||||||
| 42 | |||||||||||
| 43 | 40 | my $c = 'CHDB'; | |||||||||
| 44 | |||||||||||
| 45 | 2 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 46 | 2 | my ( $class, %options ) = @_; | |||||||||
| 47 | 2 | my $self = bless \%options, $class; | |||||||||
| 48 | 2 | return $self; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 3 | ▶ | sub as_string { | ||||||||
|
Subroutine
as_string: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 52 | 3 | my ($self) = @_; | |||||||||
| 53 | 3 | ▶ | return undef if not defined $self->{database}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 2 | return $c . ' ' . $self->{database}; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 2 | ▶ | sub is_ok { | ||||||||
|
Subroutine
is_ok: called CC=4 SCAR=14.6
Pod
undocumented
| |||||||||||
| 58 | 2 | my ($self) = @_; | |||||||||
| 59 | # command not issued yet | ||||||||||
| 60 | 2 | ▶ | return 0 if not defined $self->response; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | |||||||||||
| 62 | # command received malformed response | ||||||||||
| 63 | 1 | ▶ | return 0 if not defined $self->response->code; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 1 | ▶ | return 1 if $self->response->code == CODE_OK; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 0 | return 0; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 40 | 1; | |||||||||