TextMode/Reader/Bin.pm

filter: Statementstmt 85.7% 18 / 21 Branchbran 62.5% 5 / 8 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 69.2% 27 / 39 CC 7 SCAR 20.2
CC
7
Cov
74%
_read
8.5
BEGIN
1.0
CRAP 7.5
« TextMode/Reader/Tundra.pm ↑ Summary TextMode/Canvas.pm »
1 package Image::TextMode::Reader::Bin;
2  
3 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 extends 'Image::TextMode::Reader';
6  
7 sub _read {
8 2 ▶ my ( $self, $image, $fh, $options ) = @_;
Subroutine _read: called CC=7 SCAR=21.4
9  
10 2 ▶ if ( $image->has_sauce ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($image->has_sauce) 0 2 2
11 0 $image->render_options->{ blink_mode } = ($image->sauce->flags_id & 1) ^ 1;
12 }
13  
14 2 ▶ my $width = $options->{ width } || 160;
Condition50%1/2
$options->{'width'} || 160
l!l
02
MC/DC0%0/1
$options->{'width'} || 160
$options->{'width'}
Truth table50%1/2
A
A= $options->{'width'}
Aresult
11
00
15 2 my ( $x, $y ) = ( 0, 0 );
16 2 my $eof = chr( 26 );
17 2 my $chardata;
18 2 ▶ while ( read( $fh, $chardata, 2 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (read $fh, $chardata, 2) 8 2 10
19 8 my @data = unpack( 'aC', $chardata );
20 8 ▶ last if tell( $fh ) > $options->{ filesize } || $data[ 0 ] eq $eof;
Branch: 1 branch
BranchTrueFalseTotal
if tell $fh > $options->{"filesize"} or $data[0] eq $eof 0 8 8
Condition33%1/3
tell $fh > $options->{"filesize"} or $data[0] eq $eof
l!l&&r!l&&!r
008
MC/DC0%0/2
tell $fh > $options->{"filesize"} or $data[0] eq $eof
tell $fh > $options->{"filesize"} $data[0] eq $eof
Truth table33%1/3
A or B
A= tell $fh > $options->{"filesize"}B= $data[0] eq $eof
ABresult
1X1
011
000
21 8 $image->putpixel( { char => $data[ 0 ], attr => $data[ 1 ] }, $x,
22 $y );
23  
24 8 $x++;
25 8 ▶ if ( $x == $width ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x == $width) 0 8 8
26 0 $x = 0;
27 0 $y++;
28 }
29 }
30  
31 2 return $image;
32 }
33  
34 =head1 NAME
35  
36 Image::TextMode::Reader::Bin - Reads Bin files
37  
38 =head1 DESCRIPTION
39  
40 Provides reading capabilities for the Bin format.
41  
42 =head1 AUTHOR
43  
44 Brian Cassidy E<lt>bricas@cpan.orgE<gt>
45  
46 =head1 COPYRIGHT AND LICENSE
47  
48 Copyright 2008-2015 by Brian Cassidy
49  
50 This library is free software; you can redistribute it and/or modify
51 it under the same terms as Perl itself.
52  
53 =cut
54  
55 2 1;
« TextMode/Reader/Tundra.pm ↑ Summary TextMode/Canvas.pm »