File Coverage

inc/My_Build.pm
Criterion Covered Total %
statement 9 26 34.6
branch 0 10 0.0
condition n/a
subroutine 3 4 75.0
pod 0 1 0.0
total 12 41 29.2


line stmt bran cond sub pod time code
1             #---------------------------------------------------------------------
2             package inc::My_Build;
3             #
4             # Copyright 2010 Christopher J. Madsen
5             #
6             # Author: Christopher J. Madsen
7             #
8             # This program is free software; you can redistribute it and/or modify
9             # it under the same terms as Perl itself.
10             #
11             # This program is distributed in the hope that it will be useful,
12             # but WITHOUT ANY WARRANTY; without even the implied warranty of
13             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the
14             # GNU General Public License or the Artistic License for more details.
15             #
16             # Customize Module::Build for WebService::NFSN
17             #---------------------------------------------------------------------
18              
19 1     1   10 use strict;
  1         5  
  1         57  
20 1     1   7 use warnings;
  1         6  
  1         165  
21              
22 1     1   752 use parent 'Module::Build';
  1         468  
  1         7  
23              
24             #=====================================================================
25             # Package Global Variables:
26              
27             our $VERSION = '1.04'; # VERSION
28              
29             #---------------------------------------------------------------------
30             # Explain that JSON 2 can substitute for JSON::XS:
31              
32             sub prereq_failures
33             {
34 0     0 0   my $self = shift @_;
35              
36 0           my $out = $self->SUPER::prereq_failures(@_);
37              
38 0 0         return $out unless $out;
39              
40 0 0         if (my $attrib = $out->{requires}{'JSON::XS'}) {
41 0           my $message;
42              
43 0 0         if (do { local $@; eval "use JSON 2 (); 1" }) {
  0            
  0            
44             # JSON 2.0 or later is an acceptable replacement for JSON::XS:
45 0           delete $out->{requires}{'JSON::XS'};
46              
47             # Update requirements for MYMETA:
48 0           my $req = $self->requires;
49 0           delete $req->{'JSON::XS'};
50 0           $req->{'JSON'} = 2;
51              
52             # Clean out empty hashrefs:
53 0 0         delete $out->{requires} unless %{$out->{requires}};
  0            
54 0 0         undef $out unless %$out;
55             } else {
56 0           $attrib->{message} .= "\n\n" . <<'';
57             JSON 2.0 or later can substitute for JSON::XS, but its pure-Perl
58             implementation is slower, and you don't have it installed either.
59              
60             } # end else we couldn't load JSON 2 either
61             } # end if JSON::XS failed
62              
63 0           return $out;
64             } # end prereq_failures
65              
66             #=====================================================================
67             # Package Return Value:
68              
69             1;