| 1 | package POE::Component::Archive::Any; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use POE (qw( Filter::Reference Filter::Line Wheel::Run )); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | sub spawn { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spawn: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | croak "$package requires an even number of arguments" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | if @_ & 1; | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | $params{ lc $_ } = delete $params{ $_ } for keys %params; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | delete $params{options} | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | unless ref $params{options} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | my $self = bless \%params, $package; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | $self->{session_id} = POE::Session->create( | ||||||||||||||||||||||||||||||||||||||||||
| 26 | object_states => [ | ||||||||||||||||||||||||||||||||||||||||||
| 27 | $self => { | ||||||||||||||||||||||||||||||||||||||||||
| 28 | extract => '_extract', | ||||||||||||||||||||||||||||||||||||||||||
| 29 | shutdown => '_shutdown', | ||||||||||||||||||||||||||||||||||||||||||
| 30 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | $self => [ | ||||||||||||||||||||||||||||||||||||||||||
| 32 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 33 | _child_error | ||||||||||||||||||||||||||||||||||||||||||
| 34 | _child_closed | ||||||||||||||||||||||||||||||||||||||||||
| 35 | _child_stdout | ||||||||||||||||||||||||||||||||||||||||||
| 36 | _child_stderr | ||||||||||||||||||||||||||||||||||||||||||
| 37 | _sig_child | ||||||||||||||||||||||||||||||||||||||||||
| 38 | _start | ||||||||||||||||||||||||||||||||||||||||||
| 39 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 40 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | ( defined $params{options} ? ( options => $params{options} ) : () ), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | )->ID(); | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | sub _start { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_start: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | $self->{session_id} = $_[SESSION]->ID(); | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | if ( $self->{alias} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $kernel->alias_set( $self->{alias} ); | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | $kernel->refcount_increment( $self->{session_id} => __PACKAGE__ ); | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | $self->{wheel} = POE::Wheel::Run->new( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | Program => \&_wheel, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | ErrorEvent => '_child_error', | ||||||||||||||||||||||||||||||||||||||||||
| 63 | CloseEvent => '_child_close', | ||||||||||||||||||||||||||||||||||||||||||
| 64 | StdoutEvent => '_child_stdout', | ||||||||||||||||||||||||||||||||||||||||||
| 65 | StderrEvent => '_child_stderr', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | StdioFilter => POE::Filter::Reference->new, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | StderrFilter => POE::Filter::Line->new, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | ( $^O eq 'MSWin32' ? ( CloseOnCall => 0 ) : ( CloseOnCall => 1 ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | $kernel->yield('shutdown') | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | unless $self->{wheel}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | $kernel->sig_child( $self->{wheel}->PID(), '_sig_child' ); | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | sub _sig_child { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sig_child: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | $poe_kernel->sig_handled; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub session_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | return $_[0]->{session_id}; | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | sub extract { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | $poe_kernel->post( $self->{session_id} => 'extract' => @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | ▶ | sub _extract { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract: called CC=12 SCAR=34.7
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | my $sender = $_[SENDER]->ID; | |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | return | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | if $self->{shutdown}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | my $args; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | ▶ | if ( ref $_[ARG0] eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | $args = { %{ $_[ARG0] } }; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | carp "First parameter must be a hashref, trying to adjust..."; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $args = { @_[ARG0 .. $#_] }; | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | $args->{ lc $_ } = delete $args->{ $_ } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | for grep { !/^_/ } keys %$args; | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | ▶ | unless ( $args->{event} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | carp "Missing 'event' parameter to extract"; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | unless ( $args->{file} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | carp "Missing 'file' parameter to extract"; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | ▶ | if ( defined $args->{dir} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $args->{"dir"} and not defined $args->{"just_info"} and not -e $args->{"dir"}
defined $args->{"dir"} and not defined $args->{"just_info"}
MC/DC0%0/3
defined $args->{"dir"} and not defined $args->{"just_info"} and not -e $args->{"dir"}
defined $args->{"dir"}
not defined $args->{"just_info"}
not -e $args->{"dir"}
Truth table25%1/4
A and not(B) and not(C)
A= defined $args->{"dir"}B= not defined $args->{"just_info"}C= not -e $args->{"dir"}
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | and not defined $args->{just_info} | ||||||||||||||||||||||||||||||||||||||||||
| 122 | and not -e $args->{dir} | ||||||||||||||||||||||||||||||||||||||||||
| 123 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | unless ( mkdir $args->{dir} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | carp "Directory `$args->{dir}` did not exist and I failed" | |||||||||||||||||||||||||||||||||||||||||
| 126 | . "to create it ($!)"; | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | ▶ | if ( $args->{session} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if ( my $ref = $kernel->alias_resolve( $args->{session} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $args->{sender} = $ref->ID; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | carp "Could not resolve 'session' parameter to a valid" | |||||||||||||||||||||||||||||||||||||||||
| 137 | . " POE session"; | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | $args->{sender} = $sender; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | $kernel->refcount_increment( $args->{sender} => __PACKAGE__ ); | |||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | $self->{wheel}->put( $args ); | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | sub shutdown { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shutdown: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | $poe_kernel->call( $self->{session_id} => 'shutdown' => @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | ▶ | sub _shutdown { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shutdown: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | $kernel->alarm_remove_all; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | $kernel->alias_remove( $_ ) for $kernel->alias_list; | |||||||||||||||||||||||||||||||||||||||||
| 160 | $kernel->refcount_decrement( $self->{session_id} => __PACKAGE__ ) | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | unless $self->{alias}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | $self->{shutdown} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | $self->{wheel}->shutdown_stdin | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | if $self->{wheel}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | sub _child_closed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_child_closed: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | carp "_child_closed called (@_[ARG0..$#_])\n" | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | delete $self->{wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 176 | $kernel->yield('shutdown') | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | unless $self->{shutdown}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | ▶ | sub _child_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_child_error: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; | |||||||||||||||||||||||||||||||||||||||||
| 184 | carp "_child_error called (@_[ARG0..$#_])\n" | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | ▶ | if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | delete $self->{wheel}; | |||||||||||||||||||||||||||||||||||||||||
| 188 | $kernel->yield('shutdown') | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | ▶ | unless $self->{shutdown}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | sub _child_stderr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_child_stderr: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; | |||||||||||||||||||||||||||||||||||||||||
| 196 | carp "_child_stderr: $_[ARG0]\n" | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | sub _child_stdout { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_child_stdout: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | my ( $kernel, $self, $input ) = @_[ KERNEL, OBJECT, ARG0 ]; | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | my $session = delete $input->{sender}; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | my $event = delete $input->{event}; | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | $kernel->post( $session, $event, $input ); | |||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | $kernel->refcount_decrement( $session => __PACKAGE__ ); | |||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub _wheel { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wheel: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if ( $^O eq 'MSWin32' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | binmode STDIN; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | binmode STDOUT; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $raw; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $size = 4096; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $filter = POE::Filter::Reference->new; | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | while ( sysread STDIN, $raw, $size ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my $requests = $filter->get( [ $raw ] ); | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | foreach my $req_ref ( @$requests ) { | |||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | _process_request( $req_ref ); # changes $req_ref | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $response = $filter->put( [ $req_ref ] ); | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | print STDOUT @$response; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | sub _process_request { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_request: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $req_ref = shift; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | require Archive::Any; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $ar = Archive::Any->new( $req_ref->{file} ); | |||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | unless ( defined $ar ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $req_ref->{error} = 'Failed to create the ' | |||||||||||||||||||||||||||||||||||||||||
| 242 | . 'Archive::Any object.'; | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | unless ( -f $req_ref->{file} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $req_ref->{error} .= q| Specified `file` doesn't exist|; | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | unless ( $req_ref->{just_info} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $ar->extract( $req_ref->{dir} ); | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | @$req_ref{ qw(files type is_impolite is_naughty) } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | = ( | ||||||||||||||||||||||||||||||||||||||||||
| 256 | [ $ar->files ], | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | ## TODO when the bug in Archive::Any is fixed, change this to | ||||||||||||||||||||||||||||||||||||||||||
| 259 | ## simple $ar->mime->type() | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | ($ar->{type} || $ar->mime_type ), | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ar->{'type'} || $ar->mime_type
MC/DC0%0/2
$ar->{'type'} || $ar->mime_type
$ar->{'type'}
$ar->mime_type
Truth table0%0/3
A || B
A= $ar->{'type'}B= $ar->mime_type
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | scalar $ar->is_impolite, | ||||||||||||||||||||||||||||||||||||||||||
| 262 | scalar $ar->is_naughty, | ||||||||||||||||||||||||||||||||||||||||||
| 263 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 270 | __END__ | ||||||||||||||||||||||||||||||||||||||||||