line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Image::TextMode::Writer; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
2890
|
use Moo; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
47
|
|
4
|
7
|
|
|
7
|
|
1555
|
use Carp 'croak'; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
1489
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Image::TextMode::Writer - A base class for file writers |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
This module provides some of the basic functionality for all writer classes. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 METHODS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head2 new( %args ) |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Creates a new instance. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 write( $image, $file, \%options ) |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Writes the contents of C<$image> to C<$file> via the subclass's C<_write()> |
23
|
|
|
|
|
|
|
method. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub write { ## no critic (Subroutines::ProhibitBuiltinHomonyms) |
28
|
7
|
|
|
7
|
1
|
538
|
my ( $self, $image, $fh, $options ) = @_; |
29
|
7
|
|
50
|
|
|
51
|
$options ||= {}; |
30
|
7
|
|
|
|
|
16
|
$fh = _get_fh( $fh ); |
31
|
|
|
|
|
|
|
|
32
|
7
|
|
|
|
|
59
|
$self->_write( $image, $fh, $options ); |
33
|
|
|
|
|
|
|
|
34
|
7
|
50
|
|
|
|
211
|
$image->sauce->write( $fh ) if $image->has_sauce; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _get_fh { |
38
|
7
|
|
|
7
|
|
12
|
my ( $file ) = @_; |
39
|
|
|
|
|
|
|
|
40
|
7
|
|
|
|
|
8
|
my $fh = $file; |
41
|
7
|
50
|
|
|
|
29
|
if ( !ref $fh ) { |
42
|
0
|
|
|
|
|
0
|
undef $fh; |
43
|
0
|
0
|
|
|
|
0
|
open $fh, '>', $file ## no critic (InputOutput::RequireBriefOpen) |
44
|
|
|
|
|
|
|
or croak "Unable to open '$file': $!"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
7
|
|
|
|
|
16
|
binmode( $fh ); |
48
|
7
|
|
|
|
|
12
|
return $fh; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 AUTHOR |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Brian Cassidy Ebricas@cpan.orgE |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Copyright 2008-2015 by Brian Cassidy |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
60
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |