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   171 use parent 'Net::Gnats::Command';
  40         62  
  40         186  
3 40     40   2104 use strictures;
  40         62  
  40         179  
4             BEGIN {
5 40     40   2836 $Net::Gnats::Command::LKDB::VERSION = '0.20';
6             }
7 40     40   183 use vars qw($VERSION);
  40         47  
  40         1630  
8              
9 40     40   190 use Net::Gnats::Constants qw(CODE_OK CODE_CMD_ERROR CODE_GNATS_LOCKED);
  40         65  
  40         6126  
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 5 my ( $class ) = @_;
47 4         6 my $self = bless {}, $class;
48 4         5 return $self;
49             }
50              
51             sub as_string {
52 8     8 1 21 return $c;
53             }
54              
55             sub is_ok {
56 4     4 0 5 my $self = shift;
57 4 100       9 return 1 if $self->response->code == CODE_OK;
58 3         12 return 0;
59             }
60              
61             1;