File Coverage

blib/lib/POE/Component/App/PNGCrush.pm
Criterion Covered Total %
statement 19 39 48.7
branch 0 12 0.0
condition 0 4 0.0
subroutine 7 11 63.6
pod 1 1 100.0
total 27 67 40.3


line stmt bran cond sub pod time code
1             package POE::Component::App::PNGCrush;
2              
3 1     1   271794 use warnings;
  1         2  
  1         26  
4 1     1   6 use strict;
  1         2  
  1         41  
5              
6             our $VERSION = '1.001004'; # VERSION
7              
8 1     1   5 use Carp;
  1         2  
  1         53  
9 1     1   5 use POE;
  1         1  
  1         8  
10 1     1   319 use base 'POE::Component::NonBlockingWrapper::Base';
  1         2  
  1         74  
11 1     1   12 use App::PNGCrush;
  1         2  
  1         333  
12              
13             sub _methods_define {
14 1     1   427 return ( run => '_wheel_entry' );
15             }
16              
17             sub run {
18 0     0 1   $poe_kernel->post( shift->{session_id} => run => @_ );
19             }
20              
21             sub _check_args {
22 0     0     my ( $self, $args_ref ) = @_;
23              
24 0 0 0       exists $args_ref->{in}
25             or carp "Missing `in` argument"
26             and return;
27              
28 0 0 0       exists $args_ref->{options}
29             or carp "Missing `options` argument"
30             and return;
31              
32 0           return 1;
33             }
34              
35             sub _prepare_wheel {
36 0     0     my $self = shift;
37 0 0         $self->{crush} = App::PNGCrush->new( %{ $self->{obj_args} || {} } );
  0            
38             }
39              
40             sub _process_request {
41 0     0     my ( $self, $in_ref ) = @_;
42 0 0         unless ( ref $in_ref->{in} eq 'ARRAY' ) {
43 0           $in_ref->{in} = [ $in_ref->{in} ];
44             }
45              
46 0           my $crush = $self->{crush};
47              
48 0 0         $crush->set_options( @{ $in_ref->{options} || [] } );
  0            
49              
50 0           for ( @{ $in_ref->{in} } ) {
  0            
51 0           my $out_ref = $crush->run( $_ );
52 0 0         unless ( defined $out_ref ) {
53 0           $out_ref = $crush->error;
54             }
55 0           $in_ref->{out}{ $_ } = $out_ref;
56             }
57             }
58              
59             1;
60             __END__