Gnats/Command/QUER.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 66.6% 2 / 3 totaltotal 97.7% 43 / 44 CC 4 SCAR 4.4
CC
4
Cov
100%
new
2.0
as_string
2.0
is_ok
2.0
CRAP 1.5
« Gnats/Schema.pm ↑ Summary Gnats/Command/DBDESC.pm »
1 package Net::Gnats::Command::QUER;
2 40 ▶use parent 'Net::Gnats::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 40 ▶use strictures;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
5 40 $Net::Gnats::Command::QUER::VERSION = '0.22';
6 }
7 40 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 40 ▶use Net::Gnats::Constants qw(CODE_PR_READY CODE_INVALID_QUERY_FORMAT CODE_NO_PRS_MATCHED);
Subroutine BEGIN: called CC=1 SCAR=0.0
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 40 my $c = 'QUER';
48  
49 15 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
50 15 my ( $class, %options ) = @_;
51  
52 15 my $self = bless \%options, $class;
53 15 ▶ $self->{pr_numbers} = [] if not defined $self->{pr_numbers};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"pr_numbers"} 6 9 15
54 15 return $self;
55 }
56  
57 27 ▶sub as_string {
Subroutine as_string: called CC=2 SCAR=6.9
Pod documented
58 27 my $self = shift;
59 16 return $c . ' ' . join ' ', @{ $self->{pr_numbers}}
60 27 ▶ if ( scalar @{$self->{pr_numbers}} != 0);
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$self->{"pr_numbers"};} != 0 16 11 27
61 11 return $c;
62 }
63  
64 5 ▶sub is_ok {
Subroutine is_ok: called CC=2 SCAR=6.9
Pod undocumented
65 5 my $self = shift;
66 5 ▶ return 1 if $self->response->code == CODE_PR_READY;
Branch: 1 branch
BranchTrueFalseTotal
if $self->response->code == 300 3 2 5
67 2 return 0;
68 }
69  
70 40 1;
« Gnats/Schema.pm ↑ Summary Gnats/Command/DBDESC.pm »