File Coverage

lib/Devel/Trepan/IO/NullOutput.pm
Criterion Covered Total %
statement 21 31 67.7
branch n/a
condition 0 2 0.0
subroutine 7 13 53.8
pod 0 6 0.0
total 28 52 53.8


line stmt bran cond sub pod time code
1             # -*- coding: utf-8 -*-
2             # Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org>
3              
4             # Nukes output. Used for example in sourcing where you don't want
5             # to see output.
6             #
7              
8             # require_relative 'base_io'
9              
10 12     12   87 use warnings; use strict;
  12     12   35  
  12         387  
  12         75  
  12         36  
  12         258  
11 12     12   87 use Exporter;
  12         28  
  12         555  
12              
13             package Devel::Trepan::IO::NullOutput;
14 12     12   78 use rlib '../../..';
  12         33  
  12         79  
15 12     12   4328 use Devel::Trepan::Util qw(hash_merge);
  12         33  
  12         551  
16 12     12   77 use Devel::Trepan::IO;
  12         32  
  12         305  
17              
18 12     12   65 use vars qw(@EXPORT @ISA);
  12         31  
  12         3771  
19             @ISA = qw(Devel::Trepan::IO::OutputBase Exporter);
20              
21             sub new($;$$) {
22 0     0 0   my ($class, $out, $opts) = @_;
23 0   0       $opts ||= {};
24 0           my $self = {closed => 0};
25 0           Devel::Trepan::IO::OutputBase->new($out, $opts);
26 0           bless ($self, $class);
27 0           return $self;
28             }
29              
30             sub close($) {
31 0     0 0   my($self) = @_;
32 0           $self->{closed} = 1;
33             }
34              
35             sub is_closed($) {
36 0     0 0   my($self) = @_;
37 0           $self->{closed};
38             }
39              
40       0 0   sub flush($) {;}
41              
42             # Use this to set where to write to. output can be a
43             # file object or a string. This code raises IOError on error.
44       0 0   sub write($) {;}
45              
46             # used to write to a debugger that is connected to this
47             # `str' written will have a newline added to it
48             #
49       0 0   sub writeline($$) { ; }
50              
51             # Demo it
52             if( __FILE__ eq $0) {
53             my $output = Devel::Trepan::IO::NullOutput->new(*STDOUT);
54             require Data::Dumper;
55             import Data::Dumper;
56             print Dumper($output);
57             $output->write("Invisible");
58             $output->writeline("Invisible");
59             }
60              
61             1;