File Coverage

blib/lib/Perldoc/Writer.pm
Criterion Covered Total %
statement 17 29 58.6
branch 1 6 16.6
condition n/a
subroutine 5 8 62.5
pod 0 2 0.0
total 23 45 51.1


line stmt bran cond sub pod time code
1             package Perldoc::Writer;
2 1     1   5 use Perldoc::Base -Base;
  1         2  
  1         8  
3 1     1   706  
  1     1   2  
  1         27  
  1         5  
  1         2  
  1         452  
4             field 'stringref';
5             field 'filehandle';
6             field 'filepath';
7             field 'handle' => -init => '$self->open_handle';
8              
9 25     25 0 142 sub print {
10 25         505 for my $target (qw(stringref filepath filehandle)) {
11 25 50       70 if (defined $self->{$target}) {
12 25         250 my $method = "_print_$target";
13 25         76 return $self->$method(@_);
14             }
15             }
16 0         0 die "No destination for Perldoc::Writer to write to";
17             }
18              
19 25     25   36 sub _print_stringref {
20 25         30 ${$self->stringref} .= shift(@_);
  25         793  
21             }
22              
23 0     0     sub _print_filepath {
24 0           my $filehandle = $self->handle;
25 0           print $filehandle shift(@_);
26             }
27              
28 0     0     sub _print_filehandle {
29 0           my $filehandle = $self->filehandle;
30 0           print $filehandle shift(@_);
31             }
32              
33 0     0 0   sub open_handle {
34 0           my $filepath = $self->filepath;
35 0 0         $filepath = "> $filepath"
36             unless $filepath =~ /^>/;
37 0 0         open my $ouput, $filepath
38             or die "Can't open '$filepath' for output:\n$!";
39 0           return $filepath;
40             }
41              
42             =head1 NAME
43              
44             Perldoc::Writer - Writer Class for Perldoc Parsers
45              
46             =head1 SYNOPSIS
47              
48             package Perldoc::Writer;
49              
50             =head1 DESCRIPTION
51              
52             Uniform writing interface.
53              
54             XXX - Should be a mixin for Emitters.
55              
56             =head1 AUTHOR
57              
58             Ingy döt Net
59              
60             Audrey wrote the original code for this parser.
61              
62             =head1 COPYRIGHT
63              
64             Copyright (c) 2006. Ingy döt Net. All rights reserved.
65              
66             This program is free software; you can redistribute it and/or modify it
67             under the same terms as Perl itself.
68              
69             See L
70              
71             =cut