« blib/lib/Devel/Trepan/CmdProcessor/Command/Show_Subcmd/Version.pm
↑ Summary
blib/lib/Devel/Trepan/Interface/ComCodes.pm »
| 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 | use warnings; use strict; | ||
| 11 | use Exporter; | ||
| 12 | |||
| 13 | package Devel::Trepan::IO::NullOutput; | ||
| 14 | use rlib '../../..'; | ||
| 15 | use Devel::Trepan::Util qw(hash_merge); | ||
| 16 | use Devel::Trepan::IO; | ||
| 17 | |||
| 18 | use vars qw(@EXPORT @ISA); | ||
| 19 | @ISA = qw(Devel::Trepan::IO::OutputBase Exporter); | ||
| 20 | |||
| 21 | sub new($;$$) { | ||
| 22 | my ($class, $out, $opts) = @_; | ||
| 23 | $opts ||= {}; | ||
| 24 | my $self = {closed => 0}; | ||
| 25 | Devel::Trepan::IO::OutputBase->new($out, $opts); | ||
| 26 | bless ($self, $class); | ||
| 27 | return $self; | ||
| 28 | } | ||
| 29 | |||
| 30 | sub close($) { | ||
| 31 | my($self) = @_; | ||
| 32 | $self->{closed} = 1; | ||
| 33 | } | ||
| 34 | |||
| 35 | sub is_closed($) { | ||
| 36 | my($self) = @_; | ||
| 37 | $self->{closed}; | ||
| 38 | } | ||
| 39 | |||
| 40 | 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 | 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 | 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; |