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   205 use parent 'Net::Gnats::Command';
  40         73  
  40         218  
3 40     40   2183 use strictures;
  40         73  
  40         292  
4             BEGIN {
5 40     40   8832 $Net::Gnats::Command::LKDB::VERSION = '0.22';
6             }
7 40     40   211 use vars qw($VERSION);
  40         70  
  40         1546  
8              
9 40     40   208 use Net::Gnats::Constants qw(CODE_OK CODE_CMD_ERROR CODE_GNATS_LOCKED);
  40         87  
  40         7113  
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 6 my ( $class ) = @_;
47 4         9 my $self = bless {}, $class;
48 4         10 return $self;
49             }
50              
51             sub as_string {
52 8     8 1 27 return $c;
53             }
54              
55             sub is_ok {
56 4     4 0 5 my $self = shift;
57 4 100       13 return 1 if $self->response->code == CODE_OK;
58 3         13 return 0;
59             }
60              
61             1;