blib/lib/Test/Smoke/App/HandleQueue.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 44 / 44 CC 3 SCAR 3.4
CC
3
Cov
100%
new
2.0
run
2.0
BEGIN
1.0
CRAP 1.4
« lib/Test/Smoke/ObjectBase.pm ↑ Summary blib/lib/Test/Smoke/App/Archiver.pm »
1 package Test::Smoke::App::HandleQueue;
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '0.001';
7  
8 1 ▶use base 'Test::Smoke::App::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Test::Smoke::Poster;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Test::Smoke::PostQueue;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 =head1 NAME
14  
15 Test::Smoke::App::HadleQueue - Queue handler for reports that failed to POST to CoreSmokeDB
16  
17 =head1 SYNOPSIS
18  
19 use Test::Smoke::App::Options;
20 use Test::Smoke::App::HandleQueue;
21  
22 my $app = Test::Smoke::App::HandleQueue->new(
23 Test::Smoke::App::Options->handlequeue_config
24 );
25 $app->run();
26  
27 =head1 DESCRIPTION
28  
29 This applet reads the current queue and tries to send every report in it. On
30 success the item is removed, on failure it stiks around. After all items in the
31 queue have been looked at, the ones that do not exist in the archive directory
32 will also be removed from the queue.
33  
34 =head2 Test::Smoke::App::HandleQueue->new(%arguments)
35  
36 Create an instance of the app.
37  
38 =head3 Arguments
39  
40 Named, list:
41  
42 =over
43  
44 =item B<qfile>
45  
46 The file where the queue is kept.
47  
48 =item B<adir>
49  
50 The directory where the archive is.
51  
52 =item B<smokedb_url>
53  
54 Where to send the reports.
55  
56 =item B<poster>
57  
58 The type of HTTP client to use for sending the report to C<smokedb_url>
59  
60 =item B<poster-options>
61  
62 Each of the HTTP clients has its own set of options, See
63 L<Test::Smoke::Poster::Curl>, L<Test::Smoke::Poster::HTTP_Tiny> and
64 L<Test::Smoke::Poster::LWP_UserAgent>.
65  
66 =back
67  
68 =cut
69  
70 2 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
71 2 my $class = shift;
72 2 my $self = $class->SUPER::new(@_);
73  
74 2 ▶ if (defined($self->option('qfile'))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->option("qfile")) 1 1 2
75 1 $self->{_poster} = Test::Smoke::Poster->new(
76 $self->option('poster') => $self->options,
77  
78 # We will need to fake 'ddir' in order to get the reports from the
79 # archive
80 ddir => $self->option('adir'),
81 v => $self->option('verbose'),
82 );
83 1 $self->{_queue} = Test::Smoke::PostQueue->new(
84 adir => $self->option('adir'),
85 qfile => $self->option('qfile'),
86 v => $self->option('verbose'),
87 poster => $self->poster,
88 );
89 }
90  
91 2 return $self;
92 }
93  
94 =head2 $handle_queue->run()
95  
96 Try to send all items in the queue and remove items that are no longer in the archive.
97  
98 =cut
99  
100 2 ▶sub run {
Subroutine run: called CC=2 SCAR=6.9
Pod documented
101 2 my $self = shift;
102  
103 2 ▶ return unless defined($self->{_queue});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_queue"} 1 1 2
104 1 $self->queue->handle();
105 1 $self->queue->purge();
106 }
107  
108 1 1;
109  
110 =head1 COPYRIGHT
111  
112 (c) 2002-2013, Abe Timmerman <abeltje@cpan.org> All rights reserved.
113  
114 With contributions from Jarkko Hietaniemi, Merijn Brand, Campo
115 Weijerman, Alan Burlison, Allen Smith, Alain Barbet, Dominic Dunlop,
116 Rich Rauenzahn, David Cantrell.
117  
118 This library is free software; you can redistribute it and/or modify
119 it under the same terms as Perl itself.
120  
121 See:
122  
123 =over 4
124  
125 =item * L<http://www.perl.com/perl/misc/Artistic.html>
126  
127 =item * L<http://www.gnu.org/copyleft/gpl.html>
128  
129 =back
130  
131 This program is distributed in the hope that it will be useful,
132 but WITHOUT ANY WARRANTY; without even the implied warranty of
133 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
134  
135 =cut
« lib/Test/Smoke/ObjectBase.pm ↑ Summary blib/lib/Test/Smoke/App/Archiver.pm »