File Coverage

Makefile.PL
Criterion Covered Total %
statement 7 74 9.4
branch 0 48 0.0
condition 0 6 0.0
subroutine 3 8 37.5
pod n/a
total 10 136 7.3


line stmt bran cond sub pod time code
1             # -*- mode: perl; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2              
3 1     1   455 use strict;
  1         2  
  1         29  
4 1     1   764 use ExtUtils::MakeMaker qw(WriteMakefile);
  1         103616  
  1         1119  
5             # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6             # the contents of the Makefile that is written.
7              
8             # Normalize version strings like 6.30_02 to 6.3002,
9             # so that we can do numerical comparisons on it.
10             my $eumm_version = $ExtUtils::MakeMaker::VERSION;
11             $eumm_version =~ s/_//;
12              
13             my $module = 'SQL::Type::Guess';
14             (my $main_file = "lib/$module.pm" ) =~ s!::!/!g;
15             (my $distbase = $module) =~ s!::!-!g;
16              
17             my @tests = map { glob $_ } 't/*.t', 't/*/*.t';
18              
19             my %module = (
20             NAME => $module,
21             AUTHOR => q{Max Maischein <corion@cpan.org>},
22             VERSION_FROM => $main_file,
23             ABSTRACT_FROM => $main_file,
24             META_MERGE => {
25             "meta-spec" => { version => 2 },
26             resources => {
27             repository => {
28             web => "https://github.com/Corion/\L$distbase",
29             url => "git://github.com/Corion/\L$distbase.git",
30             type => 'git',
31             }
32             },
33             dynamic_config => 0, # we promise to keep META.* up-to-date
34             x_static_install => 1, # we are pure Perl and don't do anything fancy
35             },
36              
37             MIN_PERL_VERSION => '5.014', # The module needs 5.008, but the script needs 5.014
38              
39             'LICENSE'=> 'perl',
40              
41             PL_FILES => {
42             },
43             BUILD_REQUIRES => {
44             'ExtUtils::MakeMaker' => 0,
45             },
46              
47             EXE_FILES => [
48             glob 'bin/*',
49             ],
50              
51             PREREQ_PM => {
52             'strict' => 0,
53             'warnings' => 0,
54             'Pod::Usage' => 0,
55             'Text::CleanFragment' => 0,
56             'Spreadsheet::Read' => 0,
57             'File::Glob' => 0,
58             },
59             TEST_REQUIRES => {
60             'Test::More' => 0,
61             'Data::Dumper' => 0,
62             },
63              
64             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
65             clean => { FILES => "$distbase-*" },
66              
67             test => { TESTS => join( ' ', @tests ) },
68             );
69              
70             # This is so that we can do
71             # require 'Makefile.PL'
72             # and then call get_module_info
73              
74 1     1   12 sub get_module_info { %module }
75              
76             if( ! caller ) {
77             # I should maybe use something like Shipwright...
78             regen_README($main_file);
79             regen_EXAMPLES() if -d 'examples';
80             WriteMakefile1(get_module_info);
81             };
82              
83             1;
84              
85             sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
86 0     0     my %params=@_;
87 0           my $eumm_version=$ExtUtils::MakeMaker::VERSION;
88 0           $eumm_version=eval $eumm_version;
89 0 0         die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
90 0 0         die "License not specified" if not exists $params{LICENSE};
91 0 0 0       if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
92             #EUMM 6.5502 has problems with BUILD_REQUIRES
93 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
  0            
  0            
94 0           delete $params{BUILD_REQUIRES};
95             }
96 0 0 0       if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
97 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
  0            
  0            
98 0           delete $params{TEST_REQUIRES};
99             }
100 0 0         delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
101 0 0         delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
102 0 0         delete $params{META_MERGE} if $eumm_version < 6.46;
103 0 0         delete $params{META_ADD} if $eumm_version < 6.46;
104 0 0         delete $params{LICENSE} if $eumm_version < 6.31;
105 0 0         delete $params{AUTHOR} if $] < 5.005;
106 0 0         delete $params{ABSTRACT_FROM} if $] < 5.005;
107 0 0         delete $params{BINARY_LOCATION} if $] < 5.005;
108              
109 0           WriteMakefile(%params);
110             }
111              
112             sub regen_README {
113             # README is the short version that just tells people what this is
114             # and how to install it
115 0     0     eval {
116             # Get description
117 0           my $readme = join "\n",
118             pod_section($_[0], 'NAME', 'no heading' ),
119             pod_section($_[0], 'DESCRIPTION' ),
120             <<INSTALL,
121              
122             INSTALLATION
123              
124             This is a Perl module distribution. It should be installed with whichever
125             tool you use to manage your installation of Perl, e.g. any of
126              
127             cpanm .
128             cpan .
129             cpanp -i .
130              
131             Consult http://www.cpan.org/modules/INSTALL.html for further instruction.
132             Should you wish to install this module manually, the procedure is
133              
134             perl Makefile.PL
135             make
136             make test
137             make install
138              
139             INSTALL
140             pod_section($_[0], 'REPOSITORY'),
141             pod_section($_[0], 'SUPPORT'),
142             pod_section($_[0], 'TALKS'),
143             pod_section($_[0], 'KNOWN ISSUES'),
144             pod_section($_[0], 'BUG TRACKER'),
145             pod_section($_[0], 'CONTRIBUTING'),
146             pod_section($_[0], 'SEE ALSO'),
147             pod_section($_[0], 'AUTHOR'),
148             pod_section($_[0], 'LICENSE' ),
149             pod_section($_[0], 'COPYRIGHT' ),
150             ;
151 0           update_file( 'README', $readme );
152             };
153             # README.mkdn is the documentation that will be shown as the main
154             # page of the repository on Github. Hence we recreate the POD here
155             # as Markdown
156 0           eval {
157 0           require Pod::Markdown;
158              
159 0           my $parser = Pod::Markdown->new();
160              
161             # Read POD from Module.pm and write to README
162 0           $parser->parse_from_file($_[0]);
163 0           my $readme_mkdn = <<STATUS . $parser->as_markdown;
164              
165             [![Travis Build Status](https://travis-ci.org/Corion/\L$distbase.svg?branch=master)](https://travis-ci.org/Corion/\L$distbase)
166             [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/Corion/\L$distbase?branch=master&svg=true)](https://ci.appveyor.com/project/Corion/\L$distbase)
167              
168             STATUS
169 0           update_file( 'README.mkdn', $readme_mkdn );
170             };
171             }
172              
173             sub pod_section {
174 0     0     my( $filename, $section, $remove_heading ) = @_;
175 0 0         open my $fh, '<', $filename
176             or die "Couldn't read '$filename': $!";
177              
178             my @section =
179 0           grep { /^=head1\s+$section/.../^=/ } <$fh>;
  0            
180              
181             # Trim the section
182 0 0         if( @section ) {
183 0 0         pop @section if $section[-1] =~ /^=/;
184 0 0         shift @section if $remove_heading;
185              
186             pop @section
187 0           while $section[-1] =~ /^\s*$/;
188             shift @section
189 0           while $section[0] =~ /^\s*$/;
190             };
191              
192 0           @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
  0            
  0            
193 0           return join "", @section;
194             }
195              
196             sub regen_EXAMPLES {
197 0     0     my $perl = $^X;
198 0 0         if ($perl =~/\s/) {
199 0           $perl = qq{"$perl"};
200             };
201 0           (my $example_file = $main_file) =~ s!\.pm$!/Examples.pm!;
202 0           my $examples = `$perl -w examples/gen_examples_pod.pl`;
203 0 0         if ($examples) {
204 0           warn "(Re)Creating $example_file\n";
205 0           $examples =~ s/\r\n/\n/g;
206 0           update_file( $example_file, $examples );
207             };
208             };
209              
210             sub update_file {
211 0     0     my( $filename, $new_content ) = @_;
212 0           my $content;
213 0 0         if( -f $filename ) {
214 0 0         open my $fh, '<', $filename
215             or die "Couldn't read '$filename': $!";
216 0           binmode $fh;
217 0           local $/;
218 0           $content = <$fh>;
219             };
220              
221 0 0         if( $content ne $new_content ) {
222 0 0         if( open my $fh, '>', $filename ) {
223 0           binmode $fh;
224 0           print $fh $new_content;
225             } else {
226 0           warn "Couldn't (re)write '$filename': $!";
227             };
228             };
229             }