| 1 | package Pod::Perldocs; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | require Pod::Perldoc; | |||||||||||||||||||||||||||
| 5 | 1 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use base qw(Pod::Perldoc); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | our ($VERSION); | |||||||||||||||||||||||||||
| 8 | 1 | $VERSION = '0.17'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | ################################################################ | ||||||||||||||||||||||||||||
| 11 | # Change the following to reflect your setup | ||||||||||||||||||||||||||||
| 12 | 1 | my $soap_uri = 'http://theoryx5.uwinnipeg.ca/Apache/DocServer'; | |||||||||||||||||||||||||||
| 13 | 1 | my $soap_proxy = 'http://theoryx5.uwinnipeg.ca/cgi-bin/docserver.cgi'; | |||||||||||||||||||||||||||
| 14 | 1 | my $pod_server = q{http://cpan.uwinnipeg.ca/cgi-bin/podserver.cgi}; | |||||||||||||||||||||||||||
| 15 | ############################################################### | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub grand_search_init { | ||||||||||||||||||||||||||
|
Subroutine
grand_search_init: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 0 | my($self, $pages, @found) = @_; | |||||||||||||||||||||||||||
| 19 | 0 | @found = $self->SUPER::grand_search_init($pages, @found); | |||||||||||||||||||||||||||
| 20 | 0 | ▶ | return @found if @found; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 0 | print STDERR "Searching on remote pod server ...\n"; | |||||||||||||||||||||||||||
| 22 | 0 | my $filename; | |||||||||||||||||||||||||||
| 23 | 0 | ▶ | if ($filename = get_lwp($self, $pages->[0])) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 24 | 0 | push @found, $filename; | |||||||||||||||||||||||||||
| 25 | 0 | return @found; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | elsif ($filename = get_soap($self, $pages->[0])) { | ||||||||||||||||||||||||||||
| 28 | 0 | push @found, $filename; | |||||||||||||||||||||||||||
| 29 | 0 | return @found; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | else { | ||||||||||||||||||||||||||||
| 32 | 0 | return @found; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub get_lwp { | ||||||||||||||||||||||||||
|
Subroutine
get_lwp: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | 0 | my ($self, $mod) = @_; | |||||||||||||||||||||||||||
| 38 | 0 | my $ua = LWP::UserAgent->new; | |||||||||||||||||||||||||||
| 39 | 0 | $ua->agent("Pod/Perldocs 0.16 "); | |||||||||||||||||||||||||||
| 40 | 0 | push @{ $ua->requests_redirectable }, 'POST'; | |||||||||||||||||||||||||||
| 41 | # Create a request | ||||||||||||||||||||||||||||
| 42 | 0 | my $req = HTTP::Request->new(POST => $pod_server); | |||||||||||||||||||||||||||
| 43 | 0 | $req->content_type('application/x-www-form-urlencoded'); | |||||||||||||||||||||||||||
| 44 | 0 | $req->content("mod=$mod"); | |||||||||||||||||||||||||||
| 45 | # Pass request to the user agent and get a response back | ||||||||||||||||||||||||||||
| 46 | 0 | my $res = $ua->request($req); | |||||||||||||||||||||||||||
| 47 | # Check the outcome of the response | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if ($res->is_success) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 0 | my ($fh, $filename) = $self->new_tempfile(); | |||||||||||||||||||||||||||
| 50 | 0 | print $fh $res->content; | |||||||||||||||||||||||||||
| 51 | 0 | return $filename; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | else { | ||||||||||||||||||||||||||||
| 54 | 0 | print STDERR "Remote server returned status code: " . $res->status_line . "\n"; | |||||||||||||||||||||||||||
| 55 | 0 | return; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub get_soap { | ||||||||||||||||||||||||||
|
Subroutine
get_soap: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 60 | 0 | my ($self, $mod) = @_; | |||||||||||||||||||||||||||
| 61 | 0 | ▶ | my $soap = make_soap() or return; # no SOAP::Lite available | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 0 | my $result = $soap->get_doc($mod); | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | defined $result && defined $result->result or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $result and defined $result->result
MC/DC0%0/2
defined $result and defined $result->result
defined $result
defined $result->result
Truth table0%0/3
A and B
A= defined $resultB= defined $result->result
| |||||||||||||||||||||||||||||
| 64 | 0 | print STDERR "No matches found there either.\n"; | |||||||||||||||||||||||||||
| 65 | 0 | return; | |||||||||||||||||||||||||||
| 66 | }; | ||||||||||||||||||||||||||||
| 67 | 0 | my $lines = $result->result(); | |||||||||||||||||||||||||||
| 68 | 0 | ▶ | unless ($lines and ref($lines) eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lines and ref $lines eq "ARRAY"
MC/DC0%0/2
$lines and ref $lines eq "ARRAY"
$lines
ref $lines eq "ARRAY"
Truth table0%0/3
A and B
A= $linesB= ref $lines eq "ARRAY"
| |||||||||||||||||||||||||||||
| 69 | 0 | print STDERR "Documentation not found there either.\n"; | |||||||||||||||||||||||||||
| 70 | 0 | return; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | 0 | my ($fh, $filename) = $self->new_tempfile(); | |||||||||||||||||||||||||||
| 73 | 0 | print $fh @$lines; | |||||||||||||||||||||||||||
| 74 | 0 | return $filename; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub make_soap { | ||||||||||||||||||||||||||
|
Subroutine
make_soap: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | unless (eval { require SOAP::Lite }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | print STDERR "SOAP::Lite is unavailable to make remote call\n"; | |||||||||||||||||||||||||||
| 80 | 0 | return undef; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | return SOAP::Lite | ||||||||||||||||||||||||||||
| 84 | ->uri($soap_uri) | ||||||||||||||||||||||||||||
| 85 | ->proxy($soap_proxy, | ||||||||||||||||||||||||||||
| 86 | options => {compress_threshold => 10000}) | ||||||||||||||||||||||||||||
| 87 | 0 | ▶ | ->on_fault(sub { my($soap, $res) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | print STDERR "SOAP Fault: ", | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | (ref $res ? $res->faultstring | ||||||||||||||||||||||||||||
| 90 | : $soap->transport->status), | ||||||||||||||||||||||||||||
| 91 | "\n"; | ||||||||||||||||||||||||||||
| 92 | 0 | return undef; | |||||||||||||||||||||||||||
| 93 | 0 | }); | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 1 | 1; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =head1 NAME | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | Pod::Perldocs - view remote pod via Pod::Perldoc | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | This is a drop-in replacement for C<perldoc> based on | ||||||||||||||||||||||||||||
| 105 | C<Pod::Perldoc>. Usage is the same, except in the case | ||||||||||||||||||||||||||||
| 106 | when documentation for a module cannot be found on the | ||||||||||||||||||||||||||||
| 107 | local machine, in which case a query (via LWP or SOAP::Lite) will | ||||||||||||||||||||||||||||
| 108 | be made to a remote pod repository and, if the documentation is | ||||||||||||||||||||||||||||
| 109 | found there, the results will be displayed as usual. | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | =head1 NOTE | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | The values of C<$pod_server>, C<$soap_uri> and | ||||||||||||||||||||||||||||
| 114 | C<$soap_proxy> at the top of this script reflect | ||||||||||||||||||||||||||||
| 115 | the location of the remote pod repository. | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =head1 SERVER | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | See the I<CPAN-Search-Lite> project on SourceForge at | ||||||||||||||||||||||||||||
| 120 | L<http://sourceforge.net/projects/cpan-search/> | ||||||||||||||||||||||||||||
| 121 | for the software needed to set up a remote pod | ||||||||||||||||||||||||||||
| 122 | repository used by C<perldocs>. | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | L<Pod::Perldoc>. | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | This software is copyright 2004,2009 by Randy Kobes | ||||||||||||||||||||||||||||
| 131 | E<lt>r.kobes@uwinnipeg.caE<gt>. Usage and redistribution | ||||||||||||||||||||||||||||
| 132 | is under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =head1 CURRENT MAINTAINER | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | Kenichi Ishigaki E<lt>ishigaki@cpan.orgE<gt> | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =cut | ||||||||||||||||||||||||||||