File Coverage

blib/lib/IO/Handle/Prototype.pm
Criterion Covered Total %
statement 31 40 77.5
branch 4 4 100.0
condition n/a
subroutine 17 26 65.3
pod 0 21 0.0
total 52 91 57.1


line stmt bran cond sub pod time code
1             package IO::Handle::Prototype;
2              
3 3     3   16508 use strict;
  3         6  
  3         71  
4 3     3   10 use warnings;
  3         4  
  3         68  
5              
6 3     3   10 use Carp ();
  3         4  
  3         48  
7              
8 3     3   597 use parent qw(IO::Handle::Util::Overloading);
  3         277  
  3         18  
9              
10             sub new {
11 20     20 0 42 my ( $class, @args ) = @_;
12              
13 20 100       47 my $cb = @args == 1 ? $args[0] : {@args};
14              
15 20         75 bless {
16             cb => $cb,
17             }, $class;
18             }
19              
20             sub _cb {
21 247     247   221 my $self = shift;
22 247         175 my $name = shift;
23              
24 247 100       561 if ( my $cb = $self->{cb}{$name} ) {
25 226         441 return $self->$cb(@_);
26             } else {
27 21         2333 Carp::croak("No implementation of '$name' provided for $self");
28             }
29             }
30              
31 0     0 0 0 sub open { shift->_cb(open => @_) }
32              
33 69     69 0 7468 sub getline { shift->_cb(getline => @_) }
34 5     5 0 12 sub getlines { shift->_cb(getlines => @_) }
35 38     38 0 3379 sub read { shift->_cb(read => @_) }
36 0     0 0 0 sub sysread { shift->_cb(sysread => @_) }
37 13     13 0 4850 sub getc { shift->_cb(getc => @_) }
38 5     5 0 18 sub ungetc { shift->_cb(ungetc => @_) }
39              
40 8     8 0 4665 sub say { shift->_cb(say => @_) }
41 23     23 0 14073 sub print { shift->_cb(print => @_) }
42 3     3 0 2252 sub printf { shift->_cb(printf => @_) }
43              
44 0     0 0 0 sub format_write { shift->_cb(format_write => @_) }
45 10     10 0 2699 sub write { shift->_cb(write => @_) }
46 9     9 0 2084 sub syswrite { shift->_cb(syswrite => @_) }
47              
48 0     0 0 0 sub ioctl { shift->_cb(ioctl => @_) }
49 0     0 0 0 sub fcntl { shift->_cb(fcntl => @_) }
50              
51 0     0 0 0 sub truncate { shift->_cb(truncate => @_) }
52              
53 0     0 0 0 sub stat { shift->_cb(stat => @_) }
54 0     0 0 0 sub fileno { shift->_cb(fileno => @_) }
55              
56 50     50 0 3706 sub eof { shift->_cb(eof => @_) }
57              
58 0     0 0   sub close { shift->_cb(close => @_) }
59              
60             __PACKAGE__
61              
62             # ex: set sw=4 et:
63              
64             __END__