line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Image::TextMode::Reader; |
2
|
|
|
|
|
|
|
|
3
|
19
|
|
|
19
|
|
9660
|
use Moo; |
|
19
|
|
|
|
|
36
|
|
|
19
|
|
|
|
|
108
|
|
4
|
|
|
|
|
|
|
|
5
|
19
|
|
|
19
|
|
5346
|
use Carp 'croak'; |
|
19
|
|
|
|
|
30
|
|
|
19
|
|
|
|
|
4942
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Image::TextMode::Reader - A base class for file readers |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This module provides some of the basic functionality for all reader classes. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 METHODS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head2 new( %args ) |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Creates a new instance. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 read( $image, $file, \%options ) |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Reads the contents of C<$file> into C<$image> via the subclass's C<_read()> |
24
|
|
|
|
|
|
|
method. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub read { ## no critic (Subroutines::ProhibitBuiltinHomonyms) |
29
|
38
|
|
|
38
|
1
|
7734
|
my ( $self, $image, $fh, $options ) = @_; |
30
|
38
|
|
50
|
|
|
281
|
$options ||= {}; |
31
|
38
|
|
|
|
|
114
|
$fh = _get_fh( $fh ); |
32
|
|
|
|
|
|
|
|
33
|
38
|
|
|
|
|
732
|
$image->sauce->read( $fh ); |
34
|
|
|
|
|
|
|
|
35
|
38
|
|
|
|
|
583
|
seek( $fh, 0, 2 ); |
36
|
38
|
|
|
|
|
97
|
$options->{ filesize } = tell $fh; |
37
|
38
|
|
|
|
|
80
|
seek( $fh, 0, 0 ); |
38
|
|
|
|
|
|
|
|
39
|
38
|
100
|
|
|
|
513
|
if( $image->has_sauce ) { |
40
|
1
|
50
|
|
|
|
74
|
if ( !$options->{ width } ) { |
41
|
1
|
|
|
|
|
16
|
$options->{ width } = $image->sauce->tinfo1; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
32
|
$options->{ filesize } -= $image->sauce->record_size; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
38
|
|
|
|
|
19046
|
seek( $fh, 0, 0 ); |
48
|
|
|
|
|
|
|
|
49
|
38
|
|
|
|
|
197
|
$self->_read( $image, $fh, $options ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _get_fh { |
53
|
38
|
|
|
38
|
|
70
|
my ( $file ) = @_; |
54
|
|
|
|
|
|
|
|
55
|
38
|
|
|
|
|
72
|
my $fh = $file; |
56
|
38
|
100
|
|
|
|
127
|
if ( !ref $fh ) { |
57
|
32
|
|
|
|
|
55
|
undef $fh; |
58
|
32
|
50
|
|
|
|
1484
|
open $fh, '<', $file ## no critic (InputOutput::RequireBriefOpen) |
59
|
|
|
|
|
|
|
or croak "Unable to open '$file': $!"; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
38
|
|
|
|
|
109
|
binmode( $fh ); |
63
|
38
|
|
|
|
|
99
|
return $fh; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 AUTHOR |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Brian Cassidy Ebricas@cpan.orgE |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Copyright 2008-2015 by Brian Cassidy |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
75
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |