File Coverage

blib/lib/POE/Component/SmokeBox/Job.pm
Criterion Covered Total %
statement 32 35 91.4
branch 4 6 66.6
condition 2 3 66.6
subroutine 9 10 90.0
pod 2 2 100.0
total 49 56 87.5


line stmt bran cond sub pod time code
1             package POE::Component::SmokeBox::Job;
2             $POE::Component::SmokeBox::Job::VERSION = '0.58';
3             #ABSTRACT: Object defining a SmokeBox job.
4              
5 21     21   1416899 use strict;
  21         108  
  21         632  
6 21     21   958 use warnings;
  21         49  
  21         832  
7 21     21   5936 use Params::Check qw(check);
  21         40787  
  21         1106  
8 21     21   147 use base qw(Object::Accessor);
  21         69  
  21         6803  
9 21     21   72323 use vars qw($VERBOSE);
  21         48  
  21         12688  
10              
11             sub new {
12 44     44 1 3597 my $package = shift;
13              
14 44         1191 my $tmpl = {
15             idle => { allow => qr/^\d+$/, default => 600, },
16             timeout => { allow => qr/^\d+$/, default => 3600, },
17             type => { defined => 1, default => 'CPANPLUS::YACSmoke', },
18             command => { allow => [ qw(check index smoke) ], default => 'check', },
19             module => { defined => 1 },
20             no_log => { defined => 1, allow => qr/^(?:0|1)$/, default => 0, },
21             delay => { defined => 1, allow => qr/^\d+$/, default => 0, },
22             check_warnings => { defined => 1, allow => qr/^(?:0|1)$/, default => 1, },
23             };
24              
25 44 50       260 my $args = check( $tmpl, { @_ }, 1 ) or return;
26 44 50 66     8276 if ( $args->{command} eq 'smoke' and !$args->{module} ) {
27 0         0 warn "${package}::new expects 'module' to be set when command is 'smoke'";
28 0         0 return;
29             }
30 44         127 my $self = bless { }, $package;
31             my $accessor_map = {
32             idle => qr/^\d+$/,
33             timeout => qr/^\d+$/,
34 44     44   15015 type => sub { defined $_[0]; },
35             command => [ qw(check index smoke) ],
36 25     25   6480 module => sub { defined $_[0]; },
37 0     0   0 id => sub { defined $_[0]; },
38 44         1048 no_log => qr/^(?:0|1)$/,
39             delay => qr/^\d+$/,
40             check_warnings => qr/^(?:0|1)$/,
41             };
42 44         359 $self->mk_accessors( $accessor_map );
43 44         3658 $self->$_( $args->{$_} ) for keys %{ $args };
  44         397  
44 44         14566 return $self;
45             }
46              
47             sub dump_data {
48 85     85 1 3041 my $self = shift;
49 85         1024 my @returns = qw(idle timeout type command no_log check_warnings);
50 85 100       798 push @returns, 'module' if $self->command() eq 'smoke';
51 85         10839 return map { ( $_ => $self->$_ ) } @returns;
  535         42453  
52             }
53              
54             1;
55              
56             __END__