File Coverage

blib/lib/CPAN/Access/AdHoc/Default/CPAN/CPAN.pm
Criterion Covered Total %
statement 24 25 96.0
branch 2 4 50.0
condition 1 3 33.3
subroutine 6 7 85.7
pod 1 1 100.0
total 34 40 85.0


line stmt bran cond sub pod time code
1             package CPAN::Access::AdHoc::Default::CPAN::CPAN;
2              
3 4     4   11111 use 5.008;
  4         14  
  4         229  
4              
5 4     4   23 use strict;
  4         8  
  4         130  
6 4     4   20 use warnings;
  4         9  
  4         142  
7              
8 4     4   25 use CPAN::Access::AdHoc::Util qw{ __load };
  4         8  
  4         543  
9              
10             our $VERSION = '0.000_18';
11              
12             my $configured = eval {
13             __load( 'CPAN' );
14             1;
15             };
16              
17             sub get_default {
18 2     2 1 13 my ( $class ) = @_;
19              
20 2 50       18 $configured
21             or return;
22              
23             {
24             # Okay, here's the deal on the monkey patch.
25             #
26             # There is, to the best of my research, no supported way to
27             # prevent CPAN from initializing itself; there are just various
28             # unsupported ways. As of CPAN::HandleConfig 5.5003 (with CPAN
29             # 1.9800 07-Aug-2011) they are:
30             #
31             # * The monkey patch actually used. This exploits the fact that
32             # the load() method returns if the do_init argument is false
33             # (which it is by default) and there are no missing
34             # configuration items (which the monkey patch takes care of)
35             # * Set $CPAN::HandleConfig::loading to a positive number. This
36             # is a guard against accidental recursion.
37             #
38             # Parse::CPAN::Packages::Fast by Slaven Rezic seems to make the
39             # assumption you can get the same effect by setting
40             # $CPAN::Be_Silent to a true value, but that is not how I read
41             # the CPAN code.
42              
43 4     4   23 no warnings qw{ once redefine }; ## no critic (ProhibitNoWarnings)
  4         10  
  4         603  
  2         6  
44 2     0   18 local *CPAN::HandleConfig::missing_config_data = sub { return };
  0         0  
45 2         24 CPAN::HandleConfig->load();
46             }
47              
48 2         14 exists $CPAN::Config->{urllist}
49 2 50 33     23 and @{ $CPAN::Config->{urllist} }
50             or return;
51              
52 2         6 return @{ $CPAN::Config->{urllist} };
  2         12  
53             }
54              
55             1;
56              
57             __END__