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