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   206 use parent 'Net::Gnats::Command';
  40         71  
  40         214  
3 40     40   2179 use strictures;
  40         72  
  40         499  
4             BEGIN {
5 40     40   8769 $Net::Gnats::Command::QUER::VERSION = '0.22';
6             }
7 40     40   216 use vars qw($VERSION);
  40         75  
  40         1629  
8              
9 40     40   207 use Net::Gnats::Constants qw(CODE_PR_READY CODE_INVALID_QUERY_FORMAT CODE_NO_PRS_MATCHED);
  40         88  
  40         9809  
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 37 my ( $class, %options ) = @_;
51              
52 15         33 my $self = bless \%options, $class;
53 15 100       61 $self->{pr_numbers} = [] if not defined $self->{pr_numbers};
54 15         56 return $self;
55             }
56              
57             sub as_string {
58 27     27 1 39 my $self = shift;
59 16         70 return $c . ' ' . join ' ', @{ $self->{pr_numbers}}
60 27 100       31 if ( scalar @{$self->{pr_numbers}} != 0);
  27         87  
61 11         38 return $c;
62             }
63              
64             sub is_ok {
65 5     5 0 7 my $self = shift;
66 5 100       16 return 1 if $self->response->code == CODE_PR_READY;
67 2         28 return 0;
68             }
69              
70             1;