File Coverage

blib/lib/Net/Gnats/Command/LKDB.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod 2 3 66.6
total 32 33 96.9


line stmt bran cond sub pod time code
1             package Net::Gnats::Command::LKDB;
2 40     40   184 use parent 'Net::Gnats::Command';
  40         108  
  40         202  
3 40     40   2355 use strictures;
  40         64  
  40         199  
4             BEGIN {
5 40     40   3257 $Net::Gnats::Command::LKDB::VERSION = '0.21';
6             }
7 40     40   206 use vars qw($VERSION);
  40         64  
  40         1720  
8              
9 40     40   226 use Net::Gnats::Constants qw(CODE_OK CODE_CMD_ERROR CODE_GNATS_LOCKED);
  40         63  
  40         6890  
10              
11             =head1 NAME
12              
13             Net::Gnats::Command::LKDB
14              
15             =head1 DESCRIPTION
16              
17             Locks the main gnats database. No subsequent database locks will
18             succeed until the lock is removed. Sessions that attempt to write to
19             the database will fail.
20              
21             =head1 PROTOCOL
22              
23             LKDB
24              
25             =head1 RESPONSES
26              
27             The possible responses are:
28              
29             210 (CODE_OK) The lock has been established.
30              
31             440 (CODE_CMD_ERROR) One or more arguments were supplied to the
32             command.
33              
34             431 (CODE_GNATS_LOCKED) The database is already locked, and the lock
35             could not be obtained after 10 seconds.
36              
37             6xx (internal error) An internal error occurred, usually because of
38             permission or other filesystem-related problems. The lock may or may
39             not have been established.
40              
41             =cut
42              
43             my $c = 'LKDB';
44              
45             sub new {
46 4     4 1 4 my ( $class ) = @_;
47 4         6 my $self = bless {}, $class;
48 4         7 return $self;
49             }
50              
51             sub as_string {
52 8     8 1 22 return $c;
53             }
54              
55             sub is_ok {
56 4     4 0 3 my $self = shift;
57 4 100       22 return 1 if $self->response->code == CODE_OK;
58 3         12 return 0;
59             }
60              
61             1;