File Coverage

blib/lib/Pod/Perldoc/BaseTo.pm
Criterion Covered Total %
statement 28 61 45.9
branch 20 50 40.0
condition n/a
subroutine 7 18 38.8
pod 0 8 0.0
total 55 137 40.1


line stmt bran cond sub pod time code
1             package Pod::Perldoc::BaseTo;
2 2     2   1204 use strict;
  2         4  
  2         59  
3 2     2   8 use warnings;
  2         2  
  2         50  
4              
5 2     2   7 use vars qw($VERSION);
  2         2  
  2         84  
6             $VERSION = '3.28';
7              
8 2     2   7 use Carp qw(croak carp);
  2         2  
  2         122  
9 2     2   7 use Config qw(%Config);
  2         1  
  2         59  
10 2     2   442 use File::Spec::Functions qw(catfile);
  2         715  
  2         591  
11              
12 0     0 0   sub is_pageable { '' }
13 0     0 0   sub write_with_binmode { 1 }
14              
15 0     0 0   sub output_extension { 'txt' } # override in subclass!
16              
17             # sub new { my $self = shift; ... }
18             # sub parse_from_file( my($class, $in, $out) = ...; ... }
19              
20             #sub new { return bless {}, ref($_[0]) || $_[0] }
21              
22             # this is also in Perldoc.pm, but why look there when you're a
23             # subclass of this?
24             sub TRUE () {1}
25 0     0 0   sub FALSE () {return}
26              
27             BEGIN {
28 2 50   2   20 *is_vms = $^O eq 'VMS' ? \&TRUE : \&FALSE unless defined &is_vms;
    50          
29 2 50       9 *is_mswin32 = $^O eq 'MSWin32' ? \&TRUE : \&FALSE unless defined &is_mswin32;
    50          
30 2 50       11 *is_dos = $^O eq 'dos' ? \&TRUE : \&FALSE unless defined &is_dos;
    50          
31 2 50       9 *is_os2 = $^O eq 'os2' ? \&TRUE : \&FALSE unless defined &is_os2;
    50          
32 2 50       8 *is_cygwin = $^O eq 'cygwin' ? \&TRUE : \&FALSE unless defined &is_cygwin;
    50          
33 2 50       13 *is_linux = $^O eq 'linux' ? \&TRUE : \&FALSE unless defined &is_linux;
    50          
34 2 50       12 *is_hpux = $^O =~ m/hpux/ ? \&TRUE : \&FALSE unless defined &is_hpux;
    50          
35 2 50       6 *is_openbsd = $^O =~ m/openbsd/ ? \&TRUE : \&FALSE unless defined &is_openbsd;
    50          
36 2 50       10 *is_freebsd = $^O =~ m/freebsd/ ? \&TRUE : \&FALSE unless defined &is_freebsd;
    50          
37 2 50       759 *is_bitrig = $^O =~ m/bitrig/ ? \&TRUE : \&FALSE unless defined &is_bitrig;
    50          
38             }
39              
40             sub _perldoc_elem {
41 0     0     my($self, $name) = splice @_,0,2;
42 0 0         if(@_) {
43 0           $self->{$name} = $_[0];
44             } else {
45 0           $self->{$name};
46             }
47             }
48              
49             sub debugging {
50 0     0 0   my( $self, @messages ) = @_;
51              
52 0 0         ( defined(&Pod::Perldoc::DEBUG) and &Pod::Perldoc::DEBUG() )
53             }
54              
55             sub debug {
56 0     0 0   my( $self, @messages ) = @_;
57 0 0         return unless $self->debugging;
58 0           print STDERR map { "DEBUG $_" } @messages;
  0            
59             }
60              
61             sub warn {
62 0     0 0   my( $self, @messages ) = @_;
63 0           carp join "\n", @messages, '';
64             }
65              
66             sub die {
67 0     0 0   my( $self, @messages ) = @_;
68 0           croak join "\n", @messages, '';
69             }
70              
71             sub _get_path_components {
72 0     0     my( $self ) = @_;
73              
74 0           my @paths = split /\Q$Config{path_sep}/, $ENV{PATH};
75              
76 0           return @paths;
77             }
78              
79             sub _find_executable_in_path {
80 0     0     my( $self, $program ) = @_;
81              
82 0           my @found = ();
83 0           foreach my $dir ( $self->_get_path_components ) {
84 0           my $binary = catfile( $dir, $program );
85 0           $self->debug( "Looking for $binary\n" );
86 0 0         next unless -e $binary;
87 0 0         unless( -x $binary ) {
88 0           $self->warn( "Found $binary but it's not executable. Skipping.\n" );
89 0           next;
90             }
91 0           $self->debug( "Found $binary\n" );
92 0           push @found, $binary;
93             }
94              
95 0           return @found;
96             }
97              
98             1;
99              
100             __END__