File Coverage

blib/lib/Net/Gnats/Command/QUER.pm
Criterion Covered Total %
statement 25 25 100.0
branch 6 6 100.0
condition n/a
subroutine 8 8 100.0
pod 2 3 66.6
total 41 42 97.6


line stmt bran cond sub pod time code
1             package Net::Gnats::Command::QUER;
2 40     40   173 use parent 'Net::Gnats::Command';
  40         55  
  40         195  
3 40     40   2323 use strictures;
  40         68  
  40         664  
4             BEGIN {
5 40     40   3607 $Net::Gnats::Command::QUER::VERSION = '0.21';
6             }
7 40     40   215 use vars qw($VERSION);
  40         67  
  40         1781  
8              
9 40     40   195 use Net::Gnats::Constants qw(CODE_PR_READY CODE_INVALID_QUERY_FORMAT CODE_NO_PRS_MATCHED);
  40         53  
  40         8990  
10              
11             =head1 NAME
12              
13             Net::Gnats::Command::QUER
14              
15             =head1 DESCRIPTION
16              
17             Searches the contents of the database for PRs that match the
18             (optional) specified expressions with the EXPR command. If no
19             expressions were specified with EXPR, the entire set of PRs is
20             returned.
21              
22             If one or more PRs are specified on the command line, only those PRs
23             will be searched and/or output.
24              
25             The format of the output from the command is determined by the query
26             format selected with the QFMT command.
27              
28             =head1 PROTOCOL
29              
30             QUER [pr...]
31              
32             =head1 RESPONSES
33              
34             The possible responses are:
35              
36             418 (CODE_INVALID_QUERY_FORMAT)
37             A valid format was not specified with the QFMT command prior to invoking QUER.
38              
39             300 (CODE_PR_READY) One or more PRs will be output using the
40             requested query format. The PR text is quoted using the normal
41             quoting mechanisms for PRs.
42              
43             220 (CODE_NO_PRS_MATCHED) No PRs met the specified criteria.
44              
45             =cut
46              
47             my $c = 'QUER';
48              
49             sub new {
50 15     15 1 34 my ( $class, %options ) = @_;
51              
52 15         44 my $self = bless \%options, $class;
53 15 100       56 $self->{pr_numbers} = [] if not defined $self->{pr_numbers};
54 15         42 return $self;
55             }
56              
57             sub as_string {
58 27     27 1 38 my $self = shift;
59 16         56 return $c . ' ' . join ' ', @{ $self->{pr_numbers}}
  27         78  
60 27 100       24 if ( scalar @{$self->{pr_numbers}} != 0);
61 11         26 return $c;
62             }
63              
64             sub is_ok {
65 5     5 0 5 my $self = shift;
66 5 100       11 return 1 if $self->response->code == CODE_PR_READY;
67 2         26 return 0;
68             }
69              
70             1;