File Coverage

blib/lib/PerlIO/via/QuotedPrint.pm
Criterion Covered Total %
statement 13 13 100.0
branch 3 4 75.0
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 22 25 88.0


line stmt bran cond sub pod time code
1             # Copyright (C) 2002-2004, 2012 Elizabeth Mattijsen. All rights reserved.
2             # Copyright (C) 2015 Steve Hay. All rights reserved.
3              
4             # This module is free software; you can redistribute it and/or modify it under
5             # the same terms as Perl itself, i.e. under the terms of either the GNU General
6             # Public License or the Artistic License, as specified in the F file.
7              
8             package PerlIO::via::QuotedPrint;
9              
10 1     1   62610 use 5.008001;
  1         16  
11              
12             # be as strict as possible
13 1     1   5 use strict;
  1         2  
  1         43  
14              
15             our $VERSION = '0.10';
16              
17             # modules that we need
18 1     1   464 use MIME::QuotedPrint (); # no need to pollute this namespace
  1         1296  
  1         135  
19              
20             # satisfy -require-
21             1;
22              
23             #-------------------------------------------------------------------------------
24             #
25             # Standard Perl features
26             #
27             #-------------------------------------------------------------------------------
28             # IN: 1 class to bless with
29             # 2 mode string (ignored)
30             # 3 file handle of PerlIO layer below (ignored)
31             # OUT: 1 blessed object
32              
33 2     2 0 1890 sub PUSHED { bless \*PUSHED,$_[0] } #PUSHED
34              
35             #-------------------------------------------------------------------------------
36             # IN: 1 instantiated object (ignored)
37             # 2 handle to read from
38             # OUT: 1 decoded string
39              
40             sub FILL {
41              
42             # decode and return
43 4     4 0 29 my $line= readline( $_[1] );
44 4 100       35 return ( defined $line )
45             ? MIME::QuotedPrint::decode_qp($line)
46             : undef;
47             } #FILL
48              
49             #-------------------------------------------------------------------------------
50             # IN: 1 instantiated object (ignored)
51             # 2 buffer to be written
52             # 3 handle to write to
53             # OUT: 1 number of bytes written
54              
55             sub WRITE {
56              
57             # encode and write to handle: indicate result
58 1 50   1   3 return ( print { $_[2] } MIME::QuotedPrint::encode_qp( $_[1] ) )
  1         21  
59             ? length( $_[1] )
60             : -1;
61             } #WRITE
62              
63             #-------------------------------------------------------------------------------
64              
65             __END__