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   163 use parent 'Net::Gnats::Command';
  40         52  
  40         185  
3 40     40   2156 use strictures;
  40         65  
  40         544  
4             BEGIN {
5 40     40   3282 $Net::Gnats::Command::QUER::VERSION = '0.20';
6             }
7 40     40   201 use vars qw($VERSION);
  40         55  
  40         1682  
8              
9 40     40   186 use Net::Gnats::Constants qw(CODE_PR_READY CODE_INVALID_QUERY_FORMAT CODE_NO_PRS_MATCHED);
  40         54  
  40         8034  
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 14     14 1 123 my ( $class, %options ) = @_;
51              
52 14         176 my $self = bless \%options, $class;
53 14 100       254 $self->{pr_numbers} = [] if not defined $self->{pr_numbers};
54 14         213 return $self;
55             }
56              
57             sub as_string {
58 25     25 1 39 my $self = shift;
59 14         54 return $c . ' ' . join ' ', @{ $self->{pr_numbers}}
  25         85  
60 25 100       27 if ( scalar @{$self->{pr_numbers}} != 0);
61 11         44 return $c;
62             }
63              
64             sub is_ok {
65 5     5 0 8 my $self = shift;
66 5 100       17 return 1 if $self->response->code == CODE_PR_READY;
67 2         44 return 0;
68             }
69              
70             1;