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   7241 use 5.008;
  4         10  
  4         135  
4              
5 4     4   15 use strict;
  4         7  
  4         106  
6 4     4   16 use warnings;
  4         5  
  4         109  
7              
8 4     4   16 use CPAN::Access::AdHoc::Util qw{ __load };
  4         4  
  4         513  
9              
10             our $VERSION = '0.000_194';
11              
12             my $configured = eval {
13             __load( 'CPAN' );
14             1;
15             };
16              
17             sub get_default {
18 2     2 1 3 my ( $class ) = @_;
19              
20 2 50       5 $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   20 no warnings qw{ once redefine }; ## no critic (ProhibitNoWarnings)
  4         7  
  4         431  
  2         3  
44 2     0   11 local *CPAN::HandleConfig::missing_config_data = sub { return };
  0         0  
45 2         9 CPAN::HandleConfig->load();
46             }
47              
48 2         6 exists $CPAN::Config->{urllist}
49 2 50 33     7 and @{ $CPAN::Config->{urllist} }
50             or return;
51              
52 2         2 return @{ $CPAN::Config->{urllist} };
  2         9  
53             }
54              
55             1;
56              
57             __END__