From: Matt S Trout Date: Tue, 16 Nov 2010 02:33:13 +0000 (+0000) Subject: Makefile.PL and maint code X-Git-Tag: 0.009001 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=253d7c999a98368a6ecbdd7b1cc914d65e3bce65;p=gitmo%2FRole-Tiny.git Makefile.PL and maint code --- diff --git a/Makefile.PL b/Makefile.PL index fdc8ba7..a2a7465 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,7 +1,8 @@ use strict; use warnings FATAL => 'all'; -use 5.008001; +use 5.008003; use ExtUtils::MakeMaker; +(do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml'; unless (-e 'META.yml') { warn "MYMETA.yml is going to be completely wrong. Sorry.\n"; @@ -24,8 +25,6 @@ my $mymeta = do { no warnings; $ExtUtils::MakeMaker::VERSION >= 6.5702 }; WriteMakefile( NAME => 'Moo', VERSION_FROM => 'lib/Moo.pm', - ABSTRACT_FROM => 'lib/Moo.pm', - AUTHOR => 'Matt S Trout ', PREREQ_PM => { %RUN_DEPS, ($] >= 5.010 ? () : ('MRO::Compat' => 0)), diff --git a/maint/Makefile.PL.include b/maint/Makefile.PL.include new file mode 100644 index 0000000..53e335d --- /dev/null +++ b/maint/Makefile.PL.include @@ -0,0 +1,60 @@ +use strict; +use warnings FATAL => 'all'; + +{ + package MY; + + { + no warnings 'once'; push @ExtUtils::MakeMaker::Overridable, 'find_tests'; + } + + sub find_tests { + shift->SUPER::find_tests.' xt/*.t'; + } + + sub postamble { 'include maint/Makefile.include' } +} + +{ + no warnings 'redefine'; + sub WriteMakefile { + my %args = @_; + ExtUtils::MakeMaker::WriteMakefile( + %args, + AUTHOR => 'Matt S Trout ', + ABSTRACT_FROM => $args{VERSION_FROM}, + ); + } +} + +sub manifest_include { + use autodie; + my @files = @_; + my @parts; + while (my ($dir, $spec) = splice(@files, 0, 2)) { + my $re = ($dir ? $dir.'/' : ''). + ((ref($spec) eq 'Regexp') + ? $spec + : !ref($spec) + ? ".*\Q${spec}\E" + : die "spec must be string or regexp, was: ${spec} (${\ref $spec})"); + push @parts, $re; + } + my $final = '^(?!'.join('|', map "${_}\$", @parts).')'; + open my $skip, '>', 'MANIFEST.SKIP'; + print $skip "${final}\n"; + close $skip; +} + +manifest_include( + 'lib' => '.pm', + 't' => '.t', + 't/lib' => '.pm', + 'xt' => '.t', + 'xt/lib' => '.pm', + '' => qr{([^/]+).PL}, + '' => qr{Changes|MANIFEST|README|META\.yml}, + 'maint' => qr{[^.].*}, +); + +1; diff --git a/maint/Makefile.include b/maint/Makefile.include new file mode 100644 index 0000000..0c1e6d5 --- /dev/null +++ b/maint/Makefile.include @@ -0,0 +1,13 @@ +bump: + maint/bump-version + rm Makefile +bumpminor: + maint/bump-version minor + rm Makefile +bumpmajor: + maint/bump-version major + rm Makefile +readme: + pod2text lib/Moo.pm >README +upload: $(DISTVNAME).tar$(SUFFIX) + cpan-upload $< diff --git a/maint/bump-version b/maint/bump-version new file mode 100755 index 0000000..26de88b --- /dev/null +++ b/maint/bump-version @@ -0,0 +1,36 @@ +#!/usr/bin/env perl + +use 5.010; +use strict; +use warnings FATAL => 'all'; +use autodie; + +chomp(my $LATEST = qx(grep '^[0-9]' Changes | head -1 | awk '{print \$1}')); + +my @parts = split /\./, $LATEST; + +my $OLD_DECIMAL = sprintf('%i.%03i%03i', @parts); + +my %bump_part = (major => 0, minor => 1, bugfix => 2); + +my $bump_this = + $bump_part{$ARGV[0]||'bugfix'} + // die "no idea which part to bump - $ARGV[0] means nothing to me"; + +my @new_parts = @parts; + +$new_parts[$bump_this]++; + +my $NEW_DECIMAL = sprintf('%i.%03i%03i', @new_parts); + +warn "Bumping $OLD_DECIMAL -> $NEW_DECIMAL\n"; + +my $PM_FILE = 'lib/Module/Metadata.pm'; + +my $file = do { local (@ARGV, $/) = ($PM_FILE); <> }; + +$file =~ s/(?<=\$VERSION = ')${\quotemeta $OLD_DECIMAL}/${NEW_DECIMAL}/; + +open my $out, '>', $PM_FILE; + +print $out $file;